git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@85 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
85b1e36914
commit
3df1383951
57
sources/reactphysics3d/engine/DynamicEngine.cpp
Normal file
57
sources/reactphysics3d/engine/DynamicEngine.cpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* 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 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include "DynamicEngine.h"
|
||||||
|
|
||||||
|
// We want to use the ReactPhysics3D namespace
|
||||||
|
using namespace reactphysics3d;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
DynamicEngine::DynamicEngine(DynamicsWorld& world, const Time& timeStep)
|
||||||
|
:PhysicsEngine(world, timeStep) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy-constructor
|
||||||
|
DynamicEngine::DynamicEngine(const DynamicEngine& engine)
|
||||||
|
:PhysicsEngine(engine) {
|
||||||
|
numericalIntegrator = engine.numericalIntegrator;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
DynamicEngine::~DynamicEngine() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the interpolation state between the previous body state and the current body state
|
||||||
|
// This is used to avoid visual stuttering when the display and physics framerates are out of synchronization
|
||||||
|
BodyState DynamicEngine::interpolateState(const BodyState& previousBodyState, const BodyState& currentBodyState) const {
|
||||||
|
// TODO : Implement this method
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the state of a rigid body
|
||||||
|
void DynamicEngine::updateBodyState(RigidBody* const rigidBody) {
|
||||||
|
// TODO : Implement this method
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the physics simulation
|
||||||
|
void DynamicEngine::update() {
|
||||||
|
// TODO : Implement this method
|
||||||
|
}
|
57
sources/reactphysics3d/engine/DynamicEngine.h
Normal file
57
sources/reactphysics3d/engine/DynamicEngine.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* 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 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DYNAMICENGINE_H
|
||||||
|
#define DYNAMICENGINE_H
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include "PhysicsEngine.h"
|
||||||
|
#include "NumericalIntegrator.h"
|
||||||
|
#include "../body/Body.h"
|
||||||
|
#include "../body/RigidBody.h"
|
||||||
|
#include "../body/BodyState.h"
|
||||||
|
|
||||||
|
// Namespace ReactPhysics3D
|
||||||
|
namespace reactphysics3d {
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
Class DynamicEngine :
|
||||||
|
This class that represents a physics engine where we use
|
||||||
|
the dynamics to simulate the movement of bodies. The class
|
||||||
|
DynamicEngine inherits from the class PhysicsEngine.
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
class DynamicEngine : public PhysicsEngine {
|
||||||
|
protected :
|
||||||
|
NumericalIntegrator numericalIntegrator; // Numerical integrator used to solve differential equations of movement
|
||||||
|
|
||||||
|
BodyState interpolateState(const BodyState& previousBodyState, const BodyState& currentBodyState) const; // Compute the interpolation state
|
||||||
|
void updateBodyState(RigidBody* const rigidBody); // Update the state of a rigid body
|
||||||
|
|
||||||
|
public :
|
||||||
|
DynamicEngine(DynamicsWorld& world, const Time& timeStep); // Constructor
|
||||||
|
DynamicEngine(const DynamicEngine& engine); // Copy-constructor
|
||||||
|
virtual ~DynamicEngine(); // Destructor
|
||||||
|
|
||||||
|
void update(); // Update the physics simulation
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
42
sources/reactphysics3d/engine/DynamicWorld.h
Normal file
42
sources/reactphysics3d/engine/DynamicWorld.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* 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 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DYNAMICWORLD_H
|
||||||
|
#define DYNAMICWORLD_H
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include "PhysicsWorld.h"
|
||||||
|
|
||||||
|
// Namespace ReactPhysics3D
|
||||||
|
namespace reactphysics3d {
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
Class DynamicWorld :
|
||||||
|
This class represents the world of the physics engine where
|
||||||
|
bodies can moves. This class inherits from the class
|
||||||
|
PhysicsWorld.
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
class DynamicWorld : public PhysicsWorld {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
35
sources/reactphysics3d/engine/PhysicsEngine.cpp
Normal file
35
sources/reactphysics3d/engine/PhysicsEngine.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* 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 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include "PhysicsEngine.h"
|
||||||
|
|
||||||
|
// We want to use the ReactPhysics3D namespace
|
||||||
|
using namespace reactphysics3d;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
PhysicsEngine::PhysicsEngine(PhysicsWorld& world, const Time& timeStep)
|
||||||
|
: world(world), timer(Time(0.0), timeStep) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
PhysicsEngine::~PhysicsEngine() {
|
||||||
|
|
||||||
|
}
|
|
@ -42,8 +42,8 @@ class PhysicsEngine {
|
||||||
Timer timer; // Timer of the physics engine
|
Timer timer; // Timer of the physics engine
|
||||||
|
|
||||||
public :
|
public :
|
||||||
PhysicsEngine(); // Constructor
|
PhysicsEngine(PhysicsWorld& world, const Time& timeStep); // Constructor
|
||||||
virtual ~PhysicsEngine(); // Destructor
|
virtual ~PhysicsEngine(); // Destructor
|
||||||
|
|
||||||
virtual void update()=0; // Update the physics simulation
|
virtual void update()=0; // Update the physics simulation
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "World.h"
|
#include "PhysicsWorld.h"
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
// We want to use the ReactPhysics3D namespace
|
||||||
using namespace reactphysics3d;
|
using namespace reactphysics3d;
|
||||||
|
@ -28,6 +28,12 @@ PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy-constructor
|
||||||
|
PhysicsWorld::PhysicsWorld(const PhysicsWorld& world) {
|
||||||
|
bodyList = world.bodyList;
|
||||||
|
gravity = world.gravity;
|
||||||
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
PhysicsWorld::~PhysicsWorld() {
|
PhysicsWorld::~PhysicsWorld() {
|
||||||
|
|
||||||
|
|
|
@ -37,15 +37,13 @@ namespace reactphysics3d {
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
class PhysicsWorld {
|
class PhysicsWorld {
|
||||||
private :
|
|
||||||
PhysicsWorld(const PhysicsWorld&); // Copy-constructor is private because we don't want it to be used
|
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
std::vector<Body*> bodyList; // list that contains all bodies of the physics world
|
std::vector<Body*> bodyList; // list that contains all bodies of the physics world
|
||||||
Vector3D gravity; // Gravity vector of the world
|
Vector3D gravity; // Gravity vector of the world
|
||||||
|
|
||||||
public :
|
public :
|
||||||
PhysicsWorld(const Vector3D& gravity); // Constructor
|
PhysicsWorld(const Vector3D& gravity); // Constructor
|
||||||
|
PhysicsWorld(const PhysicsWorld&); // Copy-constructor
|
||||||
virtual ~PhysicsWorld(); // Destructor
|
virtual ~PhysicsWorld(); // Destructor
|
||||||
|
|
||||||
void addBody(Body* body) throw(std::invalid_argument); // Add a body to the physics world
|
void addBody(Body* body) throw(std::invalid_argument); // Add a body to the physics world
|
||||||
|
|
Loading…
Reference in New Issue
Block a user