Modification of the examples

This commit is contained in:
Daniel Chappuis 2013-09-10 21:53:34 +02:00
parent 4bd228e8c0
commit f575a46fdd
25 changed files with 116 additions and 88 deletions

View File

@ -2,6 +2,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
add_subdirectory(common/)
add_subdirectory(fallingcubes/)
add_subdirectory(cubes/)
add_subdirectory(joints/)
add_subdirectory(convexmesh/)
add_subdirectory(collisionshapes/)

View File

@ -34,14 +34,14 @@ openglframework::VertexBufferObject Box::mVBOVertices(GL_ARRAY_BUFFER);
openglframework::VertexBufferObject Box::mVBOIndices(GL_ELEMENT_ARRAY_BUFFER);
bool Box::areVBOsCreated = false;
VertexData Box::mCubeVertices[8] = {
{openglframework::Vector3(1,1,1),openglframework::Vector3(1,1,1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(-1,1,1),openglframework::Vector3(-1,1,1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(-1,-1,1),openglframework::Vector3(-1,-1,1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(1,-1,1),openglframework::Vector3(1,-1,1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(1,-1,-1),openglframework::Vector3(1,-1,-1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(-1,-1,-1),openglframework::Vector3(-1,-1,-1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(-1,1,-1),openglframework::Vector3(-1,1,-1),openglframework::Color(0,0,1,1)},
{openglframework::Vector3(1,1,-1),openglframework::Vector3(1,1,-1),openglframework::Color(0,0,1,1)}
{openglframework::Vector3(1,1,1),openglframework::Vector3(1,1,1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(-1,1,1),openglframework::Vector3(-1,1,1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(-1,-1,1),openglframework::Vector3(-1,-1,1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(1,-1,1),openglframework::Vector3(1,-1,1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(1,-1,-1),openglframework::Vector3(1,-1,-1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(-1,-1,-1),openglframework::Vector3(-1,-1,-1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(-1,1,-1),openglframework::Vector3(-1,1,-1),openglframework::Color(1,0,0,1)},
{openglframework::Vector3(1,1,-1),openglframework::Vector3(1,1,-1),openglframework::Color(1,0,0,1)}
};
GLuint Box::mCubeIndices[36] = { 0, 1, 2,
2, 3, 0,
@ -59,7 +59,7 @@ GLuint Box::mCubeIndices[36] = { 0, 1, 2,
// Constructor
Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &position,
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld)
: openglframework::Object3D() {
: openglframework::Object3D(), mColor(0.5f, 0.5f, 0.5f, 1.0f) {
// Initialize the size of the box
mSize[0] = size.x * 0.5f;
@ -77,7 +77,7 @@ Box::Box(const openglframework::Vector3& size, const openglframework::Vector3 &p
// Create the collision shape for the rigid body (box shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroy right after calling Dynamics::createRigidBody()
// it is OK if this object is destroyed right after calling Dynamics::createRigidBody()
const rp3d::BoxShape collisionShape(rp3d::Vector3(mSize[0], mSize[1], mSize[2]));
// Compute the inertia tensor of the body using its collision shape
@ -121,6 +121,10 @@ void Box::render(openglframework::Shader& shader,
localToCameraMatrix.getUpperLeft3x3Matrix().getInverse().getTranspose();
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix);
// TODO : REMOVE THIS
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a);
shader.setVector4Uniform("vertexColor", color);
// Bind the vertices VBO
mVBOVertices.bind();
@ -153,6 +157,11 @@ void Box::render(openglframework::Shader& shader,
shader.unbind();
}
// Set the color of the box
void Box::setColor(openglframework::Color& color) {
mColor = color;
}
// Update the transform matrix of the box
void Box::updateTransform() {

View File

@ -74,6 +74,9 @@ class Box : public openglframework::Object3D {
/// True if the VBOs have already been created
static bool areVBOsCreated;
// TODO : REMOVE THIS
openglframework::Color mColor;
// -------------------- Methods -------------------- //
/// Create a Vertex Buffer Object to render to box with OpenGL
@ -98,6 +101,9 @@ class Box : public openglframework::Object3D {
/// Render the cube at the correct position and with the correct orientation
void render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix);
/// Set the color of the box
void setColor(openglframework::Color& color);
};
// Return a pointer to the rigid body of the box

View File

@ -40,16 +40,16 @@ Capsule::Capsule(float radius, float height, const openglframework::Vector3 &pos
// Compute the scaling matrix
mScalingMatrix = openglframework::Matrix4(mRadius, 0, 0, 0,
0, (mHeight + 2.0 * mRadius) / 3.0, 0,0,
0, (mHeight + 2.0f * mRadius) / 3.0f, 0,0,
0, 0, mRadius, 0,
0, 0, 0, 1);
0, 0, 0, 1.0f);
// Initialize the position where the sphere will be rendered
translateWorld(position);
// Create the collision shape for the rigid body (sphere shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroy right after calling Dynamics::createRigidBody()
// it is OK if this object is destroyed right after calling Dynamics::createRigidBody()
const rp3d::CapsuleShape collisionShape(mRadius, mHeight);
// Compute the inertia tensor of the body using its collision shape

View File

@ -49,7 +49,7 @@ Cone::Cone(float radius, float height, const openglframework::Vector3 &position,
// Create the collision shape for the rigid body (cone shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroy right after calling Dynamics::createRigidBody()
// it is OK if this object is destroyed right after calling Dynamics::createRigidBody()
const rp3d::ConeShape collisionShape(mRadius, mHeight);
// Compute the inertia tensor of the body using its collision shape

View File

@ -49,7 +49,7 @@ Cylinder::Cylinder(float radius, float height, const openglframework::Vector3 &p
// Create the collision shape for the rigid body (cylinder shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroy right after calling Dynamics::createRigidBody()
// it is OK if this object is destroyed right after calling Dynamics::createRigidBody()
const rp3d::CylinderShape collisionShape(mRadius, mHeight);
// Compute the inertia tensor of the body using its collision shape

View File

@ -49,7 +49,7 @@ Sphere::Sphere(float radius, const openglframework::Vector3 &position,
// Create the collision shape for the rigid body (sphere shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroy right after calling Dynamics::createRigidBody()
// it is OK if this object is destroyed right after calling Dynamics::createRigidBody()
const rp3d::SphereShape collisionShape(mRadius);
// Compute the inertia tensor of the body using its collision shape

View File

@ -48,7 +48,7 @@ void Viewer::computeFPS() {
if(timeInterval > 1000){
// calculate the number of frames per second
fps = nbFrames / (timeInterval / 1000.0f);
fps = static_cast<int>(nbFrames / (timeInterval / 1000.0f));
// Set time
previousTime = currentTime;

View File

@ -4,6 +4,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Project configuration
PROJECT(OPENGLFRAMEWORK)
# Options
OPTION(USE_JPEG_TEXTURES "Select this if you want to use jpeg textures (libjpeg required)" OFF)
# Where to find the module to find special packages/libraries
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
@ -23,12 +26,16 @@ else()
MESSAGE("GLEW not found")
endif()
# Find the LIBJPEG library
FIND_PACKAGE(JPEG REQUIRED)
if(JPEG_FOUND)
MESSAGE("LIBJPEG found")
else()
MESSAGE("LIBJPEG not found")
# If the user wants to use JPEG textures
if(USE_JPEG_TEXTURES)
# Find the LIBJPEG library
FIND_PACKAGE(JPEG REQUIRED)
if(JPEG_FOUND)
MESSAGE("LIBJPEG found")
else()
MESSAGE("LIBJPEG not found")
endif()
endif()
# Freeglut
@ -37,6 +44,10 @@ add_subdirectory(freeglut)
# Headers
INCLUDE_DIRECTORIES(src freeglut ${JPEG_INCLUDE_DIR})
if(USE_JPEG_TEXTURES)
add_definitions(-DUSE_JPEG_TEXTURE)
endif()
# Library configuration
file (
GLOB_RECURSE
@ -44,7 +55,6 @@ file (
src/*
)
# Require the opengl-framework code to be compiled in a static library
ADD_LIBRARY (
openglframework

View File

@ -84,7 +84,6 @@ void Mesh::calculateNormals() {
// Normalize the normal at each vertex
for (uint i=0; i<getNbVertices(); i++) {
std::cout << "vertex n : " << i << std::endl;
mNormals[i] = mNormals[i].normalize();
}
}

View File

@ -44,7 +44,7 @@ namespace openglframework {
// object that can be loaded from an OBJ file for instance.
class Mesh : public Object3D {
private:
protected:
// -------------------- Attributes -------------------- //

View File

@ -41,9 +41,7 @@ MeshReaderWriter::MeshReaderWriter() {
}
// Load a mesh from a file and returns true if the mesh has been sucessfully loaded
void MeshReaderWriter::loadMeshFromFile(const std::string& filename,
Mesh& meshToCreate)
throw(std::invalid_argument, std::runtime_error) {
void MeshReaderWriter::loadMeshFromFile(const std::string& filename, Mesh& meshToCreate) {
// Get the extension of the file
uint startPosExtension = filename.find_last_of(".");
@ -64,9 +62,7 @@ void MeshReaderWriter::loadMeshFromFile(const std::string& filename,
}
// Write a mesh to a file
void MeshReaderWriter::writeMeshToFile(const std::string& filename,
const Mesh& meshToWrite)
throw(std::invalid_argument, std::runtime_error) {
void MeshReaderWriter::writeMeshToFile(const std::string& filename, const Mesh& meshToWrite) {
// Get the extension of the file
uint startPosExtension = filename.find_last_of(".");

View File

@ -57,14 +57,10 @@ class MeshReaderWriter {
// -------------------- Methods -------------------- //
// Read a mesh from a file
static void loadMeshFromFile(const std::string& filename,
Mesh& meshToCreate)
throw(std::invalid_argument, std::runtime_error);
static void loadMeshFromFile(const std::string& filename, Mesh& meshToCreate);
// Write a mesh to a file
static void writeMeshToFile(const std::string& filename,
const Mesh& meshToWrite)
throw(std::invalid_argument, std::runtime_error);
static void writeMeshToFile(const std::string& filename, const Mesh& meshToWrite);
};
// Class VertexMergingData

View File

@ -52,7 +52,7 @@ Texture2D::~Texture2D() {
// Create the texture
void Texture2D::create(uint width, uint height, uint internalFormat, uint format, uint type,
void* data) throw(std::invalid_argument) {
void* data) {
// Destroy the current texture
destroy();

View File

@ -69,7 +69,7 @@ class Texture2D {
// Create the texture
void create(uint width, uint height, uint internalFormat, uint format, uint type,
void* data = NULL) throw(std::invalid_argument);
void* data = NULL);
// Destroy the texture
void destroy();

View File

@ -26,8 +26,10 @@
// Librairies
#include "TextureReaderWriter.h"
#include <string>
#include <jpeglib.h>
#include <jerror.h>
#ifdef USE_JPEG_TEXTURE
#include <jpeglib.h>
#include <jerror.h>
#endif
using namespace openglframework;
using namespace std;
@ -59,8 +61,7 @@ typedef struct {
// Load a texture from a file
void TextureReaderWriter::loadTextureFromFile(const std::string& filename,
Texture2D& textureToCreate)
throw(runtime_error, invalid_argument){
Texture2D& textureToCreate) {
// Get the extension of the file
uint startPosExtension = filename.find_last_of(".");
@ -70,9 +71,11 @@ void TextureReaderWriter::loadTextureFromFile(const std::string& filename,
if (extension == "tga") {
readTGAPicture(filename, textureToCreate);
}
#ifdef USE_JPEG_TEXTURE
else if (extension == "jpg" || extension == "jpeg"){
readJPEGPicture(filename, textureToCreate);
}
#endif
else {
// Display an error message and throw an exception
@ -84,9 +87,7 @@ void TextureReaderWriter::loadTextureFromFile(const std::string& filename,
}
// Write a texture to a file
void TextureReaderWriter::writeTextureToFile(const std::string& filename,
const Texture2D& texture)
throw(runtime_error, invalid_argument){
void TextureReaderWriter::writeTextureToFile(const std::string& filename,const Texture2D& texture) {
// Get the extension of the file
uint startPosExtension = filename.find_last_of(".");
@ -96,9 +97,11 @@ void TextureReaderWriter::writeTextureToFile(const std::string& filename,
if (extension == "tga") {
writeTGAPicture(filename, texture);
}
#ifdef USE_JPEG_TEXTURE
else if (extension == "jpg" || extension == "jpeg"){
writeJPEGPicture(filename, texture);
}
#endif
else {
// Display an error message and throw an exception
@ -110,8 +113,7 @@ void TextureReaderWriter::writeTextureToFile(const std::string& filename,
}
// Load a TGA picture
void TextureReaderWriter::readTGAPicture(const std::string &filename,
Texture2D& textureToCreate) throw(runtime_error) {
void TextureReaderWriter::readTGAPicture(const std::string &filename, Texture2D& textureToCreate) {
// Open the file
std::ifstream stream(filename.c_str(), std::ios::binary);
@ -156,8 +158,7 @@ void TextureReaderWriter::readTGAPicture(const std::string &filename,
// Write a TGA picture
void TextureReaderWriter::writeTGAPicture(const std::string& filename,
const Texture2D& texture) throw(runtime_error) {
void TextureReaderWriter::writeTGAPicture(const std::string& filename, const Texture2D& texture) {
assert(texture.getID() != 0);
// Bind the corresponding texture
@ -219,9 +220,10 @@ void TextureReaderWriter::writeTGAPicture(const std::string& filename,
glBindTexture(GL_TEXTURE_2D, 0);
}
#ifdef USE_JPEG_TEXTURE
// Read a JPEG picture
void TextureReaderWriter::readJPEGPicture(const std::string& filename,
Texture2D& textureToCreate) throw(std::runtime_error) {
void TextureReaderWriter::readJPEGPicture(const std::string& filename, Texture2D& textureToCreate) {
struct jpeg_decompress_struct info;
struct jpeg_error_mgr error;
@ -276,8 +278,7 @@ void TextureReaderWriter::readJPEGPicture(const std::string& filename,
}
// Write a JPEG picture
void TextureReaderWriter::writeJPEGPicture(const std::string& filename,
const Texture2D& texture) throw(std::runtime_error) {
void TextureReaderWriter::writeJPEGPicture(const std::string& filename, const Texture2D& texture) {
struct jpeg_compress_struct info;
struct jpeg_error_mgr error;
@ -327,3 +328,5 @@ void TextureReaderWriter::writeJPEGPicture(const std::string& filename,
// Free allocated memory
delete[] data;
}
#endif

View File

@ -52,34 +52,26 @@ class TextureReaderWriter {
TextureReaderWriter();
// Read a TGA picture
static void readTGAPicture(const std::string& filename,
Texture2D& textureToCreate) throw(std::runtime_error);
static void readTGAPicture(const std::string& filename, Texture2D& textureToCreate);
// Write a TGA picture
static void writeTGAPicture(const std::string& filename,
const Texture2D& texture) throw(std::runtime_error);
static void writeTGAPicture(const std::string& filename, const Texture2D& texture);
// Read a JPEG picture
static void readJPEGPicture(const std::string& filename,
Texture2D& textureToCreate) throw(std::runtime_error);
static void readJPEGPicture(const std::string& filename, Texture2D& textureToCreate);
// Write a JPEG picture
static void writeJPEGPicture(const std::string& filename,
const Texture2D& texture) throw(std::runtime_error);
static void writeJPEGPicture(const std::string& filename, const Texture2D& texture);
public :
// -------------------- Methods -------------------- //
// Load a texture from a file
static void loadTextureFromFile(const std::string& filename,
Texture2D& textureToCreate)
throw(std::runtime_error, std::invalid_argument);
static void loadTextureFromFile(const std::string& filename, Texture2D& textureToCreate);
// Write a texture to a file
static void writeTextureToFile(const std::string& filename,
const Texture2D& texture)
throw(std::runtime_error, std::invalid_argument);
static void writeTextureToFile(const std::string& filename, const Texture2D& texture);
};
}

View File

@ -47,7 +47,7 @@ struct Color {
// Constructor
Color(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {}
// Constructor
// Copy-constructor
Color(const Color& color) : r(color.r), g(color.g), b(color.b), a(color.a) {}
// Destructor

View File

@ -31,6 +31,7 @@ uniform vec3 light0SpecularColor; // Light 0 specular color
uniform float shininess; // Shininess
uniform sampler2D texture; // Texture
uniform bool isTexture; // True if we need to use the texture
uniform vec4 vertexColor; // Vertex color
// Varying variables
varying vec3 vertexPosCameraSpace; // Camera-space position of the vertex
@ -40,10 +41,11 @@ varying vec2 texCoords; // Texture coordinates
void main() {
// Compute the ambient term
vec3 ambient = lightAmbientColor;
//vec3 ambient = lightAmbientColor;
vec3 ambient = vertexColor.rgb + 0.0 * lightAmbientColor;
// Get the texture color
vec3 textureColor = vec3(1);
vec3 textureColor = vertexColor.rgb;
if (isTexture) textureColor = texture2D(texture, texCoords).rgb;
// Compute the surface normal vector

View File

@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(FallingCubes)
PROJECT(Cubes)
# Copy the shaders used for the demo into the build directory
FILE(COPY "../common/opengl-framework/src/shaders/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
@ -12,6 +12,6 @@ INCLUDE_DIRECTORIES("../common/opengl-framework/src/" "../common/")
# Create the example executable using the
# compiled reactphysics3d static library
ADD_EXECUTABLE(fallingcubes FallingCubes.cpp Scene.cpp Scene.h "../common/Box.cpp" "../common/Box.h" "../common/Viewer.cpp" "../common/Viewer.h")
ADD_EXECUTABLE(cubes Cubes.cpp Scene.cpp Scene.h "../common/Box.cpp" "../common/Box.h" "../common/Viewer.cpp" "../common/Viewer.h")
TARGET_LINK_LIBRARIES(fallingcubes reactphysics3d openglframework)
TARGET_LINK_LIBRARIES(cubes reactphysics3d openglframework)

View File

@ -51,7 +51,7 @@ int main(int argc, char** argv) {
viewer = new Viewer();
Vector2 windowsSize = Vector2(800, 600);
Vector2 windowsPosition = Vector2(100, 100);
bool initOK = viewer->init(argc, argv, "ReactPhysics3D Examples - Falling Cubes", windowsSize, windowsPosition);
bool initOK = viewer->init(argc, argv, "ReactPhysics3D Examples - Cubes", windowsSize, windowsPosition);
if (!initOK) return 1;
// Create the scene

View File

@ -65,12 +65,13 @@ Scene::Scene(GlutViewer* viewer) : mViewer(viewer), mLight0(0),
float angle = i * 30.0f;
openglframework::Vector3 position(radius * cos(angle),
1 + i * (BOX_SIZE.y + 0.3f),
radius * sin(angle));
0);
// Create a cube and a corresponding rigid in the dynamics world
Box* cube = new Box(BOX_SIZE, position , CUBE_MASS, mDynamicsWorld);
Box* cube = new Box(BOX_SIZE, position , BOX_MASS, mDynamicsWorld);
cube->getRigidBody()->setIsMotionEnabled(true);
mMapBodyToBox.insert(std::make_pair<rp3d::RigidBody*, Box*>(cube->getRigidBody(), cube));
// Change the material properties of the rigid body
rp3d::Material& material = cube->getRigidBody()->getMaterial();
@ -87,6 +88,8 @@ Scene::Scene(GlutViewer* viewer) : mViewer(viewer), mLight0(0),
// The floor must be a non-moving rigid body
mFloor->getRigidBody()->setIsMotionEnabled(false);
mMapBodyToBox.insert(std::make_pair<rp3d::RigidBody*, Box*>(mFloor->getRigidBody(), mFloor));
// Change the material properties of the floor rigid body
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.3));
@ -142,6 +145,15 @@ void Scene::simulate() {
mFloor->updateTransform();
// Set the color of the awake/sleeping bodies
for (uint i=0; i<mBoxes.size(); i++) {
if (mBoxes[i]->getRigidBody()->isSleeping()) {
mBoxes[i]->setColor(Color(1, 0, 0, 1));
}
else {
mBoxes[i]->setColor(Color(0, 1, 0, 1));
}
}
}
}

View File

@ -34,8 +34,8 @@
// Constants
const int NB_SPHERES = 20; // Number of boxes in the scene
const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(20, 0.5f, 20); // Floor dimensions in meters
const float CUBE_MASS = 1.0f; // Box mass in kilograms
const openglframework::Vector3 FLOOR_SIZE(50, 0.5f, 50); // Floor dimensions in meters
const float BOX_MASS = 1.0f; // Box mass in kilograms
const float FLOOR_MASS = 100.0f; // Floor mass in kilograms
// Class Scene
@ -66,6 +66,9 @@ class Scene {
/// True if the physics simulation is running
bool mIsRunning;
// TODO : REMOVE THIS
std::map<rp3d::RigidBody*, Box*> mMapBodyToBox;
public:
// -------------------- Methods -------------------- //

View File

@ -246,7 +246,7 @@ void Scene::createSliderJoint() {
// Create a box and a corresponding rigid in the dynamics world
openglframework::Vector3 box1Dimension(2, 4, 2);
mSliderJointBottomBox = new Box(box1Dimension, positionBox1 , CUBE_MASS, mDynamicsWorld);
mSliderJointBottomBox = new Box(box1Dimension, positionBox1 , BOX_MASS, mDynamicsWorld);
// The fist box cannot move
mSliderJointBottomBox->getRigidBody()->setIsMotionEnabled(false);
@ -262,7 +262,7 @@ void Scene::createSliderJoint() {
// Create a box and a corresponding rigid in the dynamics world
openglframework::Vector3 box2Dimension(1.5f, 4, 1.5f);
mSliderJointTopBox = new Box(box2Dimension, positionBox2 , CUBE_MASS, mDynamicsWorld);
mSliderJointTopBox = new Box(box2Dimension, positionBox2 , BOX_MASS, mDynamicsWorld);
// The second box is allowed to move
mSliderJointTopBox->getRigidBody()->setIsMotionEnabled(true);
@ -301,7 +301,7 @@ void Scene::createPropellerHingeJoint() {
// Create a box and a corresponding rigid in the dynamics world
openglframework::Vector3 boxDimension(10, 1, 1);
mPropellerBox = new Box(boxDimension, positionBox1 , CUBE_MASS, mDynamicsWorld);
mPropellerBox = new Box(boxDimension, positionBox1 , BOX_MASS, mDynamicsWorld);
// The fist box cannot move
mPropellerBox->getRigidBody()->setIsMotionEnabled(true);
@ -339,7 +339,7 @@ void Scene::createFixedJoints() {
// Create a box and a corresponding rigid in the dynamics world
openglframework::Vector3 boxDimension(1.5, 1.5, 1.5);
mFixedJointBox1 = new Box(boxDimension, positionBox1 , CUBE_MASS, mDynamicsWorld);
mFixedJointBox1 = new Box(boxDimension, positionBox1 , BOX_MASS, mDynamicsWorld);
// The fist box cannot move
mFixedJointBox1->getRigidBody()->setIsMotionEnabled(true);
@ -354,7 +354,7 @@ void Scene::createFixedJoints() {
openglframework::Vector3 positionBox2(-5, 7, 0);
// Create a box and a corresponding rigid in the dynamics world
mFixedJointBox2 = new Box(boxDimension, positionBox2 , CUBE_MASS, mDynamicsWorld);
mFixedJointBox2 = new Box(boxDimension, positionBox2 , BOX_MASS, mDynamicsWorld);
// The second box is allowed to move
mFixedJointBox2->getRigidBody()->setIsMotionEnabled(true);

View File

@ -34,7 +34,7 @@
// Constants
const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(20, 0.5f, 20); // Floor dimensions in meters
const float CUBE_MASS = 1.0f; // Box mass in kilograms
const float BOX_MASS = 1.0f; // Box mass in kilograms
const float FLOOR_MASS = 100.0f; // Floor mass in kilograms
const int NB_BALLSOCKETJOINT_BOXES = 7; // Number of Ball-And-Socket chain boxes
const int NB_HINGE_BOXES = 7; // Number of Hinge chain boxes