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

This commit is contained in:
lindaandersson 2014-02-11 13:12:35 +01:00
commit f9a4fce5aa
3 changed files with 13 additions and 1 deletions

View File

@ -139,6 +139,12 @@ void SimpleRigidBody::SetAngularFactor(Float factor)
this->rigidBody->setAngularFactor(factor); this->rigidBody->setAngularFactor(factor);
} }
void SimpleRigidBody::SetGravity(Float3 gravity)
{
this->rigidBody->setGravity(btVector3(gravity.x, gravity.y, gravity.z));
this->gravity = gravity;
}
void SimpleRigidBody::SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right) void SimpleRigidBody::SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right)
{ {
btTransform trans; btTransform trans;
@ -167,7 +173,6 @@ void SimpleRigidBody::SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math:
rotation[1] = upVector.normalized(); rotation[1] = upVector.normalized();
rotation[2] = forwardVector.normalized(); rotation[2] = forwardVector.normalized();
rotation[0] = forwardVector.cross(upVector).normalized(); rotation[0] = forwardVector.cross(upVector).normalized();
trans = this->rigidBody->getWorldTransform(); trans = this->rigidBody->getWorldTransform();
trans.setBasis(rotation); trans.setBasis(rotation);
this->rigidBody->setWorldTransform(trans); this->rigidBody->setWorldTransform(trans);

View File

@ -32,6 +32,8 @@ namespace Oyster
void SetRotation(Math::Float3 eulerAngles); void SetRotation(Math::Float3 eulerAngles);
void SetAngularFactor(Math::Float factor); void SetAngularFactor(Math::Float factor);
void SetGravity(Math::Float3 gravity);
void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right); void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right);
void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward); void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward);
@ -51,6 +53,7 @@ namespace Oyster
void* GetCustomTag() const; void* GetCustomTag() const;
private: private:
btCollisionShape* collisionShape; btCollisionShape* collisionShape;
btDefaultMotionState* motionState; btDefaultMotionState* motionState;
btRigidBody* rigidBody; btRigidBody* rigidBody;
@ -61,6 +64,8 @@ namespace Oyster
EventAction_Move onMovement; EventAction_Move onMovement;
void *customTag; void *customTag;
::Oyster::Math::Float3 gravity;
}; };
} }
} }

View File

@ -139,6 +139,8 @@ namespace Oyster
virtual void SetRotation(::Oyster::Math::Float3 eulerAngles) = 0; virtual void SetRotation(::Oyster::Math::Float3 eulerAngles) = 0;
virtual void SetAngularFactor(::Oyster::Math::Float factor) = 0; virtual void SetAngularFactor(::Oyster::Math::Float factor) = 0;
virtual void SetGravity(::Oyster::Math::Float3 gravity) = 0;
virtual void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right) = 0; virtual void SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right) = 0;
virtual void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward) = 0; virtual void SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward) = 0;