git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@190 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2009-08-04 12:22:07 +00:00
parent 5489b3db18
commit 0624c33c28
5 changed files with 18 additions and 15 deletions

View File

@ -26,9 +26,8 @@
using namespace reactphysics3d;
// Constructor
BodyState::BodyState(const Vector3D& position, const Matrix3x3& inertiaTensorInverse, const Kilogram& massInverse)
: position(position), orientation(Quaternion(0,1,0, 0.0)), inertiaTensorInverse(inertiaTensorInverse), massInverse(massInverse) {
// TODO : orientation will be initialized in another way
BodyState::BodyState(const Vector3D& position, const Quaternion& orientation, const Matrix3x3& inertiaTensorInverse, const Kilogram& massInverse)
: position(position), orientation(orientation), inertiaTensorInverse(inertiaTensorInverse), massInverse(massInverse) {
// Recalculate the secondary values from the primary values
recalculate();
@ -92,5 +91,5 @@ Vector3D BodyState::computeForce(Time time) const {
// Return the torque on the body at time
Vector3D BodyState::computeTorque(Time time) const {
// TODO : Implement this method
return force + Vector3D(0.0, 0.0 ,0.0);
return Vector3D(0.0, 0.0 ,0.0);
}

View File

@ -49,12 +49,12 @@ class BodyState {
// Constants
Matrix3x3 inertiaTensorInverse; // Inverse of the inertia tensor of the body
Kilogram massInverse; // Inverse of the mass of the body
Kilogram massInverse; // Inverse of the mass of the body
public :
BodyState(const Vector3D& position, const Matrix3x3& inertiaTensorInverse, const Kilogram& massInverse); // Constructor
BodyState(const BodyState& bodyState); // Copy-constructor
virtual ~BodyState(); // Destructor
BodyState(const Vector3D& position, const Quaternion& orientation, const Matrix3x3& inertiaTensorInverse, const Kilogram& massInverse); // Constructor
BodyState(const BodyState& bodyState); // Copy-constructor
virtual ~BodyState(); // Destructor
Vector3D getPosition() const; // Return the position of the body
void setPosition(const Vector3D& position); // Set the position of the body

View File

@ -124,7 +124,7 @@ void OBB::draw() const {
glVertex3f(s6.getX(), s6.getY(), s6.getZ());
glVertex3f(center.getX(), center.getY(), center.getZ());
glVertex3f(center.getX() + 8.0 * axis[1].getX(), center.getY() + 8.0 * axis[1].getY(), center.getZ() + 8.0 * axis[1].getZ());
glVertex3f(center.getX() + 8.0 * axis[2].getX(), center.getY() + 8.0 * axis[2].getY(), center.getZ() + 8.0 * axis[2].getZ());
glEnd();
}

View File

@ -24,16 +24,20 @@
using namespace reactphysics3d;
// Constructor
RigidBody::RigidBody(const Vector3D& position, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb)
RigidBody::RigidBody(const Vector3D& position, const Quaternion& orientation, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb)
: Body(mass), inertiaTensor(inertiaTensor), obb(obb),
currentBodyState(position, inertiaTensor.getInverse(),Kilogram(1.0/mass.getValue())),
previousBodyState(position, inertiaTensor.getInverse(), Kilogram(1.0/mass.getValue())) {
currentBodyState(position, orientation, inertiaTensor.getInverse(),Kilogram(1.0/mass.getValue())),
previousBodyState(position, orientation, inertiaTensor.getInverse(), Kilogram(1.0/mass.getValue())) {
isMotionEnabled = true;
isCollisionEnabled = true;
interpolationFactor = 0.0;
// Set the body pointer to the OBB
this->obb.setBodyPointer(this);
// Update the orientation of the OBB according to the orientation of the rigid body
this->update();
}
// Copy-constructor

View File

@ -49,9 +49,9 @@ class RigidBody : public Body {
OBB obb; // Oriented bounding box that contains the rigid body
public :
RigidBody(const Vector3D& position, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb); // Constructor
RigidBody(const RigidBody& rigidBody); // Copy-constructor
virtual ~RigidBody(); // Destructor
RigidBody(const Vector3D& position, const Quaternion& orientation, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb); // Constructor
RigidBody(const RigidBody& rigidBody); // Copy-constructor
virtual ~RigidBody(); // Destructor
Matrix3x3 getInertiaTensor() const; // Return the inertia tensor of the body
void setInertiaTensor(const Matrix3x3& inertiaTensor); // Set the inertia tensor of the body