From 5489b3db187b58396f99414616f97d25b8766c81 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Tue, 4 Aug 2009 12:21:15 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@189 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/demo/Context.cpp | 8 ++++---- sources/demo/Objects.cpp | 17 +++++++---------- sources/demo/Objects.h | 16 ++++++++-------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/sources/demo/Context.cpp b/sources/demo/Context.cpp index 7a58f5d5..102188e4 100755 --- a/sources/demo/Context.cpp +++ b/sources/demo/Context.cpp @@ -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); diff --git a/sources/demo/Objects.cpp b/sources/demo/Objects.cpp index 5ce60ae0..3d6637d3 100755 --- a/sources/demo/Objects.cpp +++ b/sources/demo/Objects.cpp @@ -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(); -} - - - +} diff --git a/sources/demo/Objects.h b/sources/demo/Objects.h index d1117163..5b57c290 100755 --- a/sources/demo/Objects.h +++ b/sources/demo/Objects.h @@ -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