git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@223 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
8e9b7a682a
commit
40cb2dc7fd
|
@ -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 <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -68,13 +68,17 @@ void Simulation::start() {
|
|||
// Start the physics simulation
|
||||
pEngine->start();
|
||||
|
||||
//double time = 1.0;
|
||||
|
||||
// Main loop of the simulation
|
||||
while(simRunning) {
|
||||
// Check if an SDL event occured and make the apropriate actions
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user