git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@274 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
1fb0912ed2
commit
c1f25eed31
|
@ -29,7 +29,7 @@ using namespace reactphysics3d;
|
||||||
// Constructor of the class Context
|
// Constructor of the class Context
|
||||||
Context::Context() {
|
Context::Context() {
|
||||||
|
|
||||||
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* cube1 = new Cube(Vector3D(11.0,14.0, 4.0), Quaternion(1.0, 1.0, 0.0, 0.0), 4.0, Kilogram(3.0));
|
||||||
cube1->getRigidBody()->setLinearVelocity(Vector3D(0.0, -5.0, 0.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* cube2 = new Cube(Vector3D(0.0, 17, 8.0), Quaternion(0.0, 1.0, 0.0, 0.0), 3.0, Kilogram(2.0));
|
||||||
|
|
|
@ -20,9 +20,14 @@
|
||||||
// Librairies
|
// Librairies
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
|
||||||
// Constructor of the class Scene
|
// Constructor of the class Scene
|
||||||
Scene::Scene() {
|
Scene::Scene(rp3d::PhysicsWorld* world) {
|
||||||
|
|
||||||
|
this->world = world;
|
||||||
|
|
||||||
// Initialise the material specular color
|
// Initialise the material specular color
|
||||||
mat_specular[0] = 1.0;
|
mat_specular[0] = 1.0;
|
||||||
mat_specular[1] = 1.0;
|
mat_specular[1] = 1.0;
|
||||||
|
@ -109,6 +114,25 @@ void Scene::display(const Context& context) const {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw all the contact points
|
||||||
|
for (std::vector<Constraint*>::const_iterator it = world->getConstraintListStartIterator(); it != world->getConstraintListEndIterator(); ++it) {
|
||||||
|
RigidBody* rigidBody1 = dynamic_cast<RigidBody*>((*it)->getBody1());
|
||||||
|
RigidBody* rigidBody2 = dynamic_cast<RigidBody*>((*it)->getBody2());
|
||||||
|
rigidBody1->setIsMotionEnabled(false);
|
||||||
|
rigidBody2->setIsMotionEnabled(false);
|
||||||
|
|
||||||
|
Contact* contact = dynamic_cast<Contact*>((*it));
|
||||||
|
assert(contact != 0);
|
||||||
|
|
||||||
|
// Draw the contact points
|
||||||
|
for (unsigned int i=0; i<contact->getPoints().size(); ++i) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(contact->getPoints()[i].getX(), contact->getPoints()[i].getY(), contact->getPoints()[i].getZ());
|
||||||
|
contact->draw();
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Change the buffers
|
// Change the buffers
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,10 @@ class Scene {
|
||||||
GLfloat ambient_color[4]; // Ambient color of the light
|
GLfloat ambient_color[4]; // Ambient color of the light
|
||||||
GLfloat white_light[4]; // White light color
|
GLfloat white_light[4]; // White light color
|
||||||
OutSideCamera outsideCamera; // OutSide camera (Camera that can move around the scene)
|
OutSideCamera outsideCamera; // OutSide camera (Camera that can move around the scene)
|
||||||
|
rp3d::PhysicsWorld* world; //"Pointer to the physics world
|
||||||
|
|
||||||
public :
|
public :
|
||||||
Scene(); // constructor of the class
|
Scene(rp3d::PhysicsWorld* world); // constructor of the class
|
||||||
~Scene(); // Destructor of the class
|
~Scene(); // Destructor of the class
|
||||||
void init(); // Initialize the values of OpenGL
|
void init(); // Initialize the values of OpenGL
|
||||||
void display(const Context& context) const; // display the scene
|
void display(const Context& context) const; // display the scene
|
||||||
|
|
|
@ -27,7 +27,7 @@ using namespace reactphysics3d;
|
||||||
|
|
||||||
// Constructor of the class Simulation
|
// Constructor of the class Simulation
|
||||||
Simulation::Simulation()
|
Simulation::Simulation()
|
||||||
:world(new DynamicWorld(Vector3D(0.0, -0.6, 0.0))), engine(world, Time(0.01)) {
|
:world(new PhysicsWorld(Vector3D(0.0, -0.6, 0.0))), engine(world, Time(0.01)), scene(this->world) {
|
||||||
simRunning = false;
|
simRunning = false;
|
||||||
mouseButtonPressed = false;
|
mouseButtonPressed = false;
|
||||||
nbFrame = 0;
|
nbFrame = 0;
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
// Class Simulation
|
// Class Simulation
|
||||||
class Simulation {
|
class Simulation {
|
||||||
private :
|
private :
|
||||||
|
rp3d::PhysicsWorld* world; // Pointer to the collision world that contains bodies of the simulation
|
||||||
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::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
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
int initSDL();
|
int initSDL();
|
||||||
|
|
||||||
|
@ -56,8 +55,6 @@ int main(int argc, char** argv) {
|
||||||
(argv);
|
(argv);
|
||||||
|
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methode to initialise the SDL and the windows
|
// Methode to initialise the SDL and the windows
|
||||||
|
|
Loading…
Reference in New Issue
Block a user