From 40cb2dc7fdd94ff820c81d3a65733e9b01f518bf Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Sun, 29 Nov 2009 14:14:58 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@223 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/demo/Context.cpp | 44 +++++++++++++++++++------------------ sources/demo/Simulation.cpp | 20 +++++++++++++---- sources/demo/Simulation.h | 4 ++-- sources/demo/main.cpp | 2 +- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/sources/demo/Context.cpp b/sources/demo/Context.cpp index 67d1660d..55dff409 100755 --- a/sources/demo/Context.cpp +++ b/sources/demo/Context.cpp @@ -1,21 +1,21 @@ /**************************************************************************** - * Copyright (C) 2009 Daniel Chappuis * - **************************************************************************** - * This file is part of ReactPhysics3D. * - * * - * ReactPhysics3D is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published * - * by the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * ReactPhysics3D is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with ReactPhysics3D. If not, see . * - ***************************************************************************/ +* Copyright (C) 2009 Daniel Chappuis * +**************************************************************************** +* This file is part of ReactPhysics3D. * +* * +* ReactPhysics3D is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* ReactPhysics3D is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with ReactPhysics3D. If not, see . * +***************************************************************************/ // Libraries #include "Context.h" @@ -29,13 +29,15 @@ using namespace reactphysics3d; // Constructor of the class 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* cube2 = new Cube(Vector3D(0.0, 17, 8.0), Quaternion(0.0, 1.0, 0.0, 0.0), 3.0, Kilogram(2.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)); + 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)); 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); + //addObject(cube2); //addObject(cube3); addObject(plane1); } @@ -59,7 +61,7 @@ Object& Context::getObject(int objectIndex) const { // Method for adding an object into the context void Context::addObject(Object* object) { - if (object != NULL) { + if (object != 0) { // Add the object into the context vectObjects.push_back(object); } diff --git a/sources/demo/Simulation.cpp b/sources/demo/Simulation.cpp index e0395b57..fd1b7aed 100755 --- a/sources/demo/Simulation.cpp +++ b/sources/demo/Simulation.cpp @@ -27,7 +27,7 @@ using namespace reactphysics3d; // Constructor of the class 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; mouseButtonPressed = false; nbFrame = 0; @@ -66,7 +66,9 @@ void Simulation::start() { pEngine->initializeDisplayTime(Time(SDL_GetTicks()/1000.0)); // Start the physics simulation - pEngine->start(); + pEngine->start(); + + //double time = 1.0; // Main loop of the simulation while(simRunning) { @@ -74,7 +76,9 @@ void Simulation::start() { checkEvents(); 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 pEngine->updateDisplayTime(Time(time)); @@ -87,7 +91,7 @@ void Simulation::start() { // Compute the fps (framerate) computeFps(); - std::cout << "FPS : " << fps << std::endl; + //std::cout << "FPS : " << fps << std::endl; /* 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 << "quaternion orientation 2 : " << velocity2.getX() << ", " << velocity2.getY() << ", " << velocity2.getZ() << ", " << velocity2.getW() << ")" << std::endl;; */ + + /* + double a; + if (time > 5.0) { + std::cin >> a; + } + */ + } } diff --git a/sources/demo/Simulation.h b/sources/demo/Simulation.h index cc906ca4..4704bf2a 100755 --- a/sources/demo/Simulation.h +++ b/sources/demo/Simulation.h @@ -30,8 +30,8 @@ class Simulation { private : Scene scene; // Scene object for displaying the simulation Context context; // Context of the simulation - rp3d::CollisionWorld* world; // Pointer to the collision world that contains bodies of the simulation - rp3d::CollisionEngine engine; // Collision engine for the physics of the simulation + rp3d::DynamicWorld* world; // Pointer to the collision world that contains bodies 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 mouseButtonPressed; // True if the left mouse button is pressed double lastFrameTime; // Last frame time diff --git a/sources/demo/main.cpp b/sources/demo/main.cpp index c0a593c9..0a5dff67 100755 --- a/sources/demo/main.cpp +++ b/sources/demo/main.cpp @@ -87,7 +87,7 @@ int initSDL() { } // 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 int nValue;