Merge branch 'GamePhysics' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-10 14:52:46 +01:00
commit 1b5e8e11cb
3 changed files with 34 additions and 0 deletions

View File

@ -38,6 +38,33 @@ SimpleRigidBody::~SimpleRigidBody()
this->rigidBody = NULL;
}
SimpleRigidBody::State SimpleRigidBody::GetState() const
{
return this->state;
}
SimpleRigidBody::State& SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
{
targetMem = this->state;
return targetMem;
}
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
{
btTransform trans;
this->motionState->getWorldTransform(trans);
trans.setRotation(btQuaternion(state.quaternion.imaginary.x, state.quaternion.imaginary.y, state.quaternion.imaginary.z, state.quaternion.real));
trans.setOrigin(btVector3(state.centerPos.x, state.centerPos.y, state.centerPos.z));
this->motionState->setWorldTransform(trans);
this->rigidBody->setFriction(state.staticFrictionCoeff);
this->rigidBody->setRestitution(state.restitutionCoeff);
btVector3 fallInertia(0, 0, 0);
collisionShape->calculateLocalInertia(state.mass, fallInertia);
this->rigidBody->setMassProps(state.mass, fallInertia);
this->state = state;
}
void SimpleRigidBody::SetCollisionShape(btCollisionShape* shape)
{
this->collisionShape = shape;

View File

@ -14,6 +14,10 @@ namespace Oyster
SimpleRigidBody();
virtual ~SimpleRigidBody();
State GetState() const;
State& GetState( State &targetMem ) const;
void SetState( const State &state );
void SetCollisionShape(btCollisionShape* shape);
void SetMotionState(btDefaultMotionState* motionState);
void SetRigidBody(btRigidBody* rigidBody);

View File

@ -123,6 +123,9 @@ namespace Oyster
virtual ~ICustomBody() {};
virtual State GetState() const = 0;
virtual State & GetState( State &targetMem ) const = 0;
virtual void SetState( const State &state ) = 0;
virtual void SetSubscription(EventAction_AfterCollisionResponse function) = 0;
virtual void SetSubscription(EventAction_Move function) = 0;