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

This commit is contained in:
chappuis.daniel 2009-08-04 12:21:15 +00:00
parent 1e85d940bd
commit 5489b3db18
3 changed files with 19 additions and 22 deletions

View File

@ -30,10 +30,10 @@ using namespace reactphysics3d;
Context::Context() {
// We add some objects in the context at the beginning ---> THESE THINGS WILL BE STORE IN A TEXT FILE
Cube* cube1 = new Cube(Vector3D(-6.0, 15, -6.0), 3.0, Kilogram(30.0));
Cube* cube2 = new Cube(Vector3D(-6.0, 13, 1.0), 3.0, Kilogram(2.0));
//Cube* cube3 = new Cube(Vector3D(4.0, 17, -2.0), 2.0, Kilogram(11.0));
Plane* plane1 = new Plane(Vector3D(0.0, 0.0, 0.0), 20.0, 30.0, Vector3D(-1.0, 0.0, 0.0), Vector3D(0.0, 0.0, 1.0), Kilogram(10.0));
Cube* cube1 = new Cube(Vector3D(0.0, 13, 3.0), Quaternion(0.5, 1.0, 1.0, 0.0), 3.0, Kilogram(30.0));
Cube* cube2 = new Cube(Vector3D(0.0, 17, 8.0), Quaternion(0.0, 1.0, 0.0, 0.0), 3.0, Kilogram(2.0));
//Cube* cube3 = new Cube(Vector3D(4.0, 17, -2.0), Quaternion(0.0, 1.0, 0.0, 0.0), 2.0, Kilogram(11.0));
Plane* plane1 = new Plane(Vector3D(0.0, 0.0, 0.0), Quaternion(0.0, 1.0, 0.0, 0.0), 20.0, 30.0, Vector3D(-1.0, 0.0, 0.0), Vector3D(0.0, 0.0, 1.0), Kilogram(10.0));
addObject(cube1);
addObject(cube2);

View File

@ -30,8 +30,8 @@
// ----- Class Object ----- //
// Constructor of the class Object
Object::Object(const Vector3D& position, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb)
:rigidBody(new RigidBody(position, mass, inertiaTensor, obb)) {
Object::Object(const Vector3D& position, const Quaternion& orientation, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb)
:rigidBody(new RigidBody(position, orientation, mass, inertiaTensor, obb)) {
}
@ -52,8 +52,8 @@ RigidBody* Object::getRigidBody() {
const Matrix3x3 Cube::inertiaTensor;
// Constructor of the class Cube
Cube::Cube(const Vector3D& position, float size, const Kilogram& mass)
:Object(position, mass, Matrix3x3(1.0/12.0*mass.getValue()*2*size*size, 0.0, 0.0,
Cube::Cube(const Vector3D& position, const Quaternion& orientation, float size, const Kilogram& mass)
:Object(position, orientation, mass, Matrix3x3(1.0/12.0*mass.getValue()*2*size*size, 0.0, 0.0,
0.0, 1.0/12.0*mass.getValue()*2*size*size, 0.0,
0.0, 0.0, 1.0/12.0*mass.getValue()*2*size*size), OBB(position, Vector3D(1.0, 0.0, 0.0), Vector3D(0.0, 1.0, 0.0), Vector3D(0.0, 0.0, 1.0),
size/2, size/2, size/2)) {
@ -95,8 +95,8 @@ void Cube::draw() const {
// ----- Class Plane ----- //
// Constructor of the class Plane
Plane::Plane(const Vector3D& position, float width, float height, const Vector3D& d1, const Vector3D& d2, const Kilogram& mass)
:Object(position, mass, Matrix3x3(1.0/12.0*mass.getValue()*height*height, 0.0, 0.0,
Plane::Plane(const Vector3D& position, const Quaternion& orientation, float width, float height, const Vector3D& d1, const Vector3D& d2, const Kilogram& mass)
:Object(position, orientation, mass, Matrix3x3(1.0/12.0*mass.getValue()*height*height, 0.0, 0.0,
0.0, 1.0/12.0*mass.getValue()*(width*width+height*height), 0.0,
0.0, 0.0, 1.0/12.0*mass.getValue()*width*width), OBB(position, Vector3D(1.0, 0.0, 0.0), Vector3D(0.0, 1.0, 0.0), Vector3D(0.0, 0.0, 1.0),
width/2, 0.5, height/2)) { // TODO : Change the height of the OBB
@ -149,7 +149,4 @@ void Plane::draw() const {
glVertex3f(x - d1.getX() * halfWidth + d2.getX() * halfHeight , y - d1.getY() * halfWidth + d2.getY() * halfHeight
, z - d1.getZ() * halfWidth + d2.getZ() * halfHeight);
glEnd();
}
}

View File

@ -37,8 +37,8 @@ class Object {
RigidBody* rigidBody; // Rigid Body that represents the object
public :
Object(const Vector3D& position, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb); // Constructor of the class Object
virtual ~Object(); // Destructor of the class Object
Object(const Vector3D& position, const Quaternion& orientation, const Kilogram& mass, const Matrix3x3& inertiaTensor, const OBB& obb); // Constructor of the class Object
virtual ~Object(); // Destructor of the class Object
virtual void draw() const =0; // pure virtual method to draw the object
RigidBody* getRigidBody(); // Return the pointer to the rigid body
@ -51,9 +51,9 @@ class Cube : public Object {
float size; // Size of a side in the cube
static const Matrix3x3 inertiaTensor; // Inertia tensor of a cube
public :
Cube(const Vector3D& position, float size, const Kilogram& mass); // Constructor of the class cube
virtual ~Cube(); // Destructor of the class cube
virtual void draw() const; // Method to draw the cube
Cube(const Vector3D& position, const Quaternion& orientation, float size, const Kilogram& mass); // Constructor of the class cube
virtual ~Cube(); // Destructor of the class cube
virtual void draw() const; // Method to draw the cube
};
@ -68,9 +68,9 @@ class Plane : public Object {
Vector3D normalVector; // Unit normal vector of the plane
public :
Plane(const Vector3D& position, float width, float height, const Vector3D& d1, const Vector3D& d2, const Kilogram& mass); // Constructor of the class Plane
virtual ~Plane(); // Destructor of the class Plane
virtual void draw() const; // Method to draw the plane
Plane(const Vector3D& position, const Quaternion& orientation, float width, float height, const Vector3D& d1, const Vector3D& d2, const Kilogram& mass); // Constructor of the class Plane
virtual ~Plane(); // Destructor of the class Plane
virtual void draw() const; // Method to draw the plane
};
#endif