diff --git a/examples/collisionshapes/Scene.cpp b/examples/collisionshapes/Scene.cpp index 440ec5a6..c6fc330e 100644 --- a/examples/collisionshapes/Scene.cpp +++ b/examples/collisionshapes/Scene.cpp @@ -46,7 +46,7 @@ Scene::Scene(Viewer* viewer, const std::string& shaderFolderPath, const std::str mViewer->setScenePosition(center, radiusScene); // Gravity vector in the dynamics world - rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); + rp3d::Vector3 gravity(0, -9.81, 0); // Time step for the physics simulation rp3d::decimal timeStep = 1.0f / 60.0f; @@ -67,7 +67,7 @@ Scene::Scene(Viewer* viewer, const std::string& shaderFolderPath, const std::str // Position float angle = i * 30.0f; openglframework::Vector3 position(radius * cos(angle), - 80 + i * (DUMBBELL_HEIGHT + 0.3f), + 100 + i * (DUMBBELL_HEIGHT + 0.3f), radius * sin(angle)); // Create a convex mesh and a corresponding rigid in the dynamics world diff --git a/examples/collisionshapes/Scene.h b/examples/collisionshapes/Scene.h index afc0537c..0fe055bf 100644 --- a/examples/collisionshapes/Scene.h +++ b/examples/collisionshapes/Scene.h @@ -41,12 +41,12 @@ // Constants const int NB_BOXES = 2; -const int NB_SPHERES = 3; -const int NB_CONES = 1; +const int NB_SPHERES = 1; +const int NB_CONES = 3; const int NB_CYLINDERS = 2; const int NB_CAPSULES = 1; -const int NB_MESHES = 3; -const int NB_COMPOUND_SHAPES = 1; +const int NB_MESHES = 2; +const int NB_COMPOUND_SHAPES = 2; const openglframework::Vector3 BOX_SIZE(2, 2, 2); const float SPHERE_RADIUS = 1.5f; const float CONE_RADIUS = 2.0f; diff --git a/examples/common/Dumbbell.cpp b/examples/common/Dumbbell.cpp index d6810d06..595a3915 100644 --- a/examples/common/Dumbbell.cpp +++ b/examples/common/Dumbbell.cpp @@ -61,7 +61,7 @@ Dumbbell::Dumbbell(const openglframework::Vector3 &position, // Initial position and orientation of the rigid body rp3d::Vector3 initPosition(position.x, position.y, position.z); - rp3d::decimal angleAroundX = rp3d::PI / 4; + rp3d::decimal angleAroundX = 0;//rp3d::PI / 2; rp3d::Quaternion initOrientation(angleAroundX, 0, 0); rp3d::Transform transformBody(initPosition, initOrientation); @@ -78,8 +78,8 @@ Dumbbell::Dumbbell(const openglframework::Vector3 &position, mRigidBody = dynamicsWorld->createRigidBody(transformBody); // Add the three collision shapes to the body and specify the mass and transform of the shapes - mRigidBody->addCollisionShape(sphereCollisionShape, 1, transformSphereShape1); - mRigidBody->addCollisionShape(sphereCollisionShape, 4, transformSphereShape2); + mRigidBody->addCollisionShape(sphereCollisionShape, massSphere, transformSphereShape1); + mRigidBody->addCollisionShape(sphereCollisionShape, massSphere, transformSphereShape2); mRigidBody->addCollisionShape(cylinderCollisionShape, massCylinder, transformCylinderShape); } diff --git a/examples/cubes/Scene.cpp b/examples/cubes/Scene.cpp index 838f4a0b..240dd757 100644 --- a/examples/cubes/Scene.cpp +++ b/examples/cubes/Scene.cpp @@ -46,7 +46,7 @@ Scene::Scene(Viewer* viewer, const std::string& shaderFolderPath) mViewer->setScenePosition(center, radiusScene); // Gravity vector in the dynamics world - rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0); + rp3d::Vector3 gravity(0, rp3d::decimal(-5.81), 0); // Time step for the physics simulation rp3d::decimal timeStep = 1.0f / 60.0f; @@ -92,6 +92,8 @@ Scene::Scene(Viewer* viewer, const std::string& shaderFolderPath) // Start the simulation startSimulation(); + + counter=0; } // Destructor @@ -129,6 +131,9 @@ void Scene::simulate() { // If the physics simulation is running if (mIsRunning) { + counter++; + if (counter == 800) mIsRunning = false; + // Take a simulation step mDynamicsWorld->update(); diff --git a/examples/cubes/Scene.h b/examples/cubes/Scene.h index f8f0dde0..dc60a127 100644 --- a/examples/cubes/Scene.h +++ b/examples/cubes/Scene.h @@ -33,7 +33,7 @@ #include "Viewer.h" // Constants -const int NB_SPHERES = 20; // Number of boxes in the scene +const int NB_SPHERES = 200; // Number of boxes in the scene const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters const openglframework::Vector3 FLOOR_SIZE(50, 0.5f, 50); // Floor dimensions in meters const float BOX_MASS = 1.0f; // Box mass in kilograms @@ -46,6 +46,8 @@ class Scene { // -------------------- Attributes -------------------- // + int counter; + /// Pointer to the viewer Viewer* mViewer;