Add rolling resistance to shapes in collision shapes scene in testbed application

This commit is contained in:
Daniel Chappuis 2016-03-21 21:55:02 +01:00
parent 67334b1bd3
commit e530a1a7cc
2 changed files with 14 additions and 3 deletions

View File

@ -101,7 +101,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
}
// Create all the spheres of the scene
for (int i=0; i<NB_CUBES; i++) {
for (int i=0; i<NB_SPHERES; i++) {
// Position
float angle = i * 35.0f;
@ -113,6 +113,9 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
Sphere* sphere = new Sphere(SPHERE_RADIUS, position , BOX_MASS, mDynamicsWorld,
meshFolderPath);
// Add some rolling resistance
sphere->getRigidBody()->getMaterial().setRollingResistance(0.08);
// Set the box color
sphere->setColor(mDemoColors[i % mNbDemoColors]);
sphere->setSleepingColor(mRedColorDemo);
@ -138,6 +141,9 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
Cone* cone = new Cone(CONE_RADIUS, CONE_HEIGHT, position, CONE_MASS, mDynamicsWorld,
meshFolderPath);
// Add some rolling resistance
cone->getRigidBody()->getMaterial().setRollingResistance(0.08);
// Set the box color
cone->setColor(mDemoColors[i % mNbDemoColors]);
cone->setSleepingColor(mRedColorDemo);
@ -163,6 +169,9 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
Cylinder* cylinder = new Cylinder(CYLINDER_RADIUS, CYLINDER_HEIGHT, position ,
CYLINDER_MASS, mDynamicsWorld, meshFolderPath);
// Add some rolling resistance
cylinder->getRigidBody()->getMaterial().setRollingResistance(0.08);
// Set the box color
cylinder->setColor(mDemoColors[i % mNbDemoColors]);
cylinder->setSleepingColor(mRedColorDemo);
@ -188,6 +197,8 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
Capsule* capsule = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position ,
CAPSULE_MASS, mDynamicsWorld, meshFolderPath);
capsule->getRigidBody()->getMaterial().setRollingResistance(0.08);
// Set the box color
capsule->setColor(mDemoColors[i % mNbDemoColors]);
capsule->setSleepingColor(mRedColorDemo);
@ -540,7 +551,7 @@ void CollisionShapesScene::reset() {
}
// Create all the spheres of the scene
for (int i=0; i<NB_CUBES; i++) {
for (int i=0; i<NB_SPHERES; i++) {
// Position
float angle = i * 35.0f;

View File

@ -45,7 +45,7 @@ namespace collisionshapesscene {
// Constants
const float SCENE_RADIUS = 30.0f;
const int NB_BOXES = 5;
const int NB_CUBES = 5;
const int NB_SPHERES = 5;
const int NB_CONES = 5;
const int NB_CYLINDERS = 5;
const int NB_CAPSULES = 5;