~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to source/gameengine/Physics/Sumo/SumoPhysicsController.cpp

  • Committer: Dietrich Bollmann
  • Date: 2009-07-26 14:27:44 UTC
  • mfrom: (184.1.1008)
  • Revision ID: dietrich@formgames.org-20090726142744-75hivjratygfz7q3
Update to state of blender repository from 2009-07-26 revision 21911 (launchpad: 1192).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * @file $Id: SumoPhysicsController.cpp 20239 2009-05-17 12:51:51Z ben2610 $
 
2
 * @file $Id: SumoPhysicsController.cpp 20952 2009-06-17 08:36:37Z ben2610 $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
402
402
        
403
403
void    SumoPhysicsController::WriteMotionStateToDynamics(bool)
404
404
{
405
 
 
 
405
        float tmp[4];
 
406
        m_MotionState->getWorldPosition(tmp[0], tmp[1], tmp[2]);
 
407
        MT_Point3 pos(tmp);
 
408
        m_sumoObj->setPosition(pos);
 
409
        m_MotionState->getWorldOrientation(tmp[0], tmp[1], tmp[2], tmp[3]);
 
410
        MT_Quaternion quat(tmp);
 
411
        m_sumoObj->setOrientation(quat);
406
412
}
407
413
// this is the actual callback from sumo, and the position/orientation
408
414
//is written to the scenegraph, using the motionstate abstraction
493
499
        return 0.f;
494
500
 
495
501
}
 
502
 
 
503
///////////////////////////////////////////////////////////
 
504
///A small utility class, SumoDefaultMotionState
 
505
///
 
506
///////////////////////////////////////////////////////////
 
507
 
 
508
SumoDefaultMotionState::SumoDefaultMotionState()
 
509
{
 
510
        m_worldTransform.setIdentity();
 
511
        m_localScaling.setValue(1.f,1.f,1.f);
 
512
}
 
513
 
 
514
 
 
515
SumoDefaultMotionState::~SumoDefaultMotionState()
 
516
{
 
517
 
 
518
}
 
519
 
 
520
void    SumoDefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
 
521
{
 
522
        posX = m_worldTransform.getOrigin().x();
 
523
        posY = m_worldTransform.getOrigin().y();
 
524
        posZ = m_worldTransform.getOrigin().z();
 
525
}
 
526
 
 
527
void    SumoDefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
 
528
{
 
529
        scaleX = m_localScaling.x();
 
530
        scaleY = m_localScaling.y();
 
531
        scaleZ = m_localScaling.z();
 
532
}
 
533
 
 
534
void    SumoDefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
 
535
{
 
536
        MT_Quaternion quat = m_worldTransform.getRotation();
 
537
        quatIma0 = quat.x();
 
538
        quatIma1 = quat.y();
 
539
        quatIma2 = quat.z();
 
540
        quatReal = quat.w();
 
541
}
 
542
                
 
543
void    SumoDefaultMotionState::getWorldOrientation(float* ori)
 
544
{
 
545
        m_worldTransform.getBasis().getValue(ori);
 
546
}
 
547
 
 
548
void    SumoDefaultMotionState::setWorldOrientation(const float* ori)
 
549
{
 
550
        m_worldTransform.getBasis().setValue(ori);
 
551
}
 
552
void    SumoDefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
 
553
{
 
554
        MT_Point3 pos(posX,posY,posZ);
 
555
        m_worldTransform.setOrigin( pos );
 
556
}
 
557
 
 
558
void    SumoDefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
 
559
{
 
560
        MT_Quaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
 
561
        m_worldTransform.setRotation( orn );
 
562
}
 
563
                
 
564
void    SumoDefaultMotionState::calculateWorldTransformations()
 
565
{
 
566
 
 
567
}
 
568