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,12 +29,12 @@ using namespace reactphysics3d;
|
|||
// Constructor of the class 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));
|
||||
|
||||
//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));
|
||||
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);
|
||||
|
|
|
@ -19,10 +19,15 @@
|
|||
|
||||
// Librairies
|
||||
#include "Scene.h"
|
||||
#include "Objects.h"
|
||||
#include "Objects.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
// Constructor of the class Scene
|
||||
Scene::Scene() {
|
||||
Scene::Scene(rp3d::PhysicsWorld* world) {
|
||||
|
||||
this->world = world;
|
||||
|
||||
// Initialise the material specular color
|
||||
mat_specular[0] = 1.0;
|
||||
mat_specular[1] = 1.0;
|
||||
|
@ -107,6 +112,25 @@ void Scene::display(const Context& context) const {
|
|||
|
||||
// Remove the matrix on the top of the matrix stack
|
||||
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
|
||||
|
|
|
@ -37,10 +37,11 @@ class Scene {
|
|||
GLfloat light_position[4]; // Position of the light source
|
||||
GLfloat ambient_color[4]; // Ambient color of the light
|
||||
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 :
|
||||
Scene(); // constructor of the class
|
||||
Scene(rp3d::PhysicsWorld* world); // constructor of the class
|
||||
~Scene(); // Destructor of the class
|
||||
void init(); // Initialize the values of OpenGL
|
||||
void display(const Context& context) const; // display the scene
|
||||
|
|
|
@ -27,7 +27,7 @@ using namespace reactphysics3d;
|
|||
|
||||
// Constructor of the class 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;
|
||||
mouseButtonPressed = false;
|
||||
nbFrame = 0;
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
// 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
|
||||
Context context; // Context 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
|
||||
rp3d::CollisionEngine 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
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <iostream>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
|
||||
// Prototypes
|
||||
int initSDL();
|
||||
|
||||
|
@ -33,7 +32,7 @@ int initSDL();
|
|||
SDL_Surface * pScreen; // Pointer to the SDL windows
|
||||
|
||||
// Main function
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
if(initSDL() > 0) {
|
||||
// If initSDL return an error then we exit the program
|
||||
|
@ -56,8 +55,6 @@ int main(int argc, char** argv) {
|
|||
(argv);
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Methode to initialise the SDL and the windows
|
||||
|
|
Loading…
Reference in New Issue
Block a user