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

This commit is contained in:
chappuis.daniel 2009-11-29 14:14:58 +00:00
parent 8e9b7a682a
commit 40cb2dc7fd
4 changed files with 42 additions and 28 deletions

View File

@ -29,13 +29,15 @@ using namespace reactphysics3d;
// Constructor of the class Context // Constructor of the class Context
Context::Context() { Context::Context() {
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* cube1 = new Cube(Vector3D(0.0,14.0, 5.0), Quaternion(0.0, 1.0, 0.0, 0.0), 3.0, Kilogram(3.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)); cube1->getRigidBody()->setLinearVelocity(Vector3D(0.0, -5.0, 0.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)); //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)); 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(cube1);
addObject(cube2); //addObject(cube2);
//addObject(cube3); //addObject(cube3);
addObject(plane1); addObject(plane1);
} }
@ -59,7 +61,7 @@ Object& Context::getObject(int objectIndex) const {
// Method for adding an object into the context // Method for adding an object into the context
void Context::addObject(Object* object) { void Context::addObject(Object* object) {
if (object != NULL) { if (object != 0) {
// Add the object into the context // Add the object into the context
vectObjects.push_back(object); vectObjects.push_back(object);
} }

View File

@ -27,7 +27,7 @@ using namespace reactphysics3d;
// Constructor of the class Simulation // Constructor of the class Simulation
Simulation::Simulation() Simulation::Simulation()
:world(new CollisionWorld(Vector3D(0.0, -1.0, 0.0))), engine(world, Time(0.01)) { :world(new DynamicWorld(Vector3D(0.0, -0.6, 0.0))), engine(world, Time(0.01)) {
simRunning = false; simRunning = false;
mouseButtonPressed = false; mouseButtonPressed = false;
nbFrame = 0; nbFrame = 0;
@ -68,13 +68,17 @@ void Simulation::start() {
// Start the physics simulation // Start the physics simulation
pEngine->start(); pEngine->start();
//double time = 1.0;
// Main loop of the simulation // Main loop of the simulation
while(simRunning) { while(simRunning) {
// Check if an SDL event occured and make the apropriate actions // Check if an SDL event occured and make the apropriate actions
checkEvents(); checkEvents();
double time = SDL_GetTicks()/1000.0; double time = SDL_GetTicks()/1000.0;
std::cout << "Time : " << time << std::endl; //time += 0.01;
//std::cout << "************************************************* Time : " << time << std::endl;
// Update the display time // Update the display time
pEngine->updateDisplayTime(Time(time)); pEngine->updateDisplayTime(Time(time));
@ -87,7 +91,7 @@ void Simulation::start() {
// Compute the fps (framerate) // Compute the fps (framerate)
computeFps(); computeFps();
std::cout << "FPS : " << fps << std::endl; //std::cout << "FPS : " << fps << std::endl;
/* /*
BodyState state = context.getObject(0).getRigidBody()->getInterpolatedState(); BodyState state = context.getObject(0).getRigidBody()->getInterpolatedState();
@ -117,6 +121,14 @@ void Simulation::start() {
std::cout << "Position Cube 2: (" << x2 << ", " << y2 << ", " << z2 << ")" << std::endl; std::cout << "Position Cube 2: (" << x2 << ", " << y2 << ", " << z2 << ")" << std::endl;
std::cout << "quaternion orientation 2 : " << velocity2.getX() << ", " << velocity2.getY() << ", " << velocity2.getZ() << ", " << velocity2.getW() << ")" << std::endl;; std::cout << "quaternion orientation 2 : " << velocity2.getX() << ", " << velocity2.getY() << ", " << velocity2.getZ() << ", " << velocity2.getW() << ")" << std::endl;;
*/ */
/*
double a;
if (time > 5.0) {
std::cin >> a;
}
*/
} }
} }

View File

@ -30,8 +30,8 @@ class Simulation {
private : private :
Scene scene; // Scene object for displaying the simulation Scene scene; // Scene object for displaying the simulation
Context context; // Context of the simulation Context context; // Context of the simulation
rp3d::CollisionWorld* world; // Pointer to the collision world that contains bodies of the simulation rp3d::DynamicWorld* world; // Pointer to the collision world that contains bodies of the simulation
rp3d::CollisionEngine engine; // Collision engine for the physics of the simulation rp3d::DynamicEngine engine; // Collision engine for the physics of the simulation
bool simRunning; // True if the simulation is running and false otherwise bool simRunning; // True if the simulation is running and false otherwise
bool mouseButtonPressed; // True if the left mouse button is pressed bool mouseButtonPressed; // True if the left mouse button is pressed
double lastFrameTime; // Last frame time double lastFrameTime; // Last frame time

View File

@ -87,7 +87,7 @@ int initSDL() {
} }
// Define the window title and the window icon // Define the window title and the window icon
SDL_WM_SetCaption("React Demo 0.02", NULL); SDL_WM_SetCaption("ReactPhysics3D Demo 0.01", NULL);
// Get the state of the Double Buffer parameter // Get the state of the Double Buffer parameter
int nValue; int nValue;