Fix sleeping colors in testbed application

This commit is contained in:
Daniel Chappuis 2016-03-21 23:02:05 +01:00
parent e530a1a7cc
commit 4d982ebd31
10 changed files with 22 additions and 17 deletions

View File

@ -182,7 +182,8 @@ void ConcaveMesh::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -166,7 +166,8 @@ void Cone::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -163,7 +163,8 @@ void ConvexMesh::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -167,7 +167,8 @@ void Cylinder::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -208,7 +208,8 @@ void Dumbbell::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -148,7 +148,8 @@ void HeightField::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -168,7 +168,8 @@ void Sphere::render(openglframework::Shader& shader,
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false);
// Set the vertex color // Set the vertex color
openglframework::Vector4 color(mColor.r, mColor.g, mColor.b, mColor.a); openglframework::Color currentColor = mBody->isSleeping() ? mSleepingColor : mColor;
openglframework::Vector4 color(currentColor.r, currentColor.g, currentColor.b, currentColor.a);
shader.setVector4Uniform("vertexColor", color, false); shader.setVector4Uniform("vertexColor", color, false);
// Bind the VAO // Bind the VAO

View File

@ -237,7 +237,6 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
// ---------- Create the floor --------- // ---------- Create the floor ---------
openglframework::Vector3 floorPosition(0, 0, 0); openglframework::Vector3 floorPosition(0, 0, 0);
mFloor = new Box(FLOOR_SIZE, floorPosition, FLOOR_MASS, mDynamicsWorld); mFloor = new Box(FLOOR_SIZE, floorPosition, FLOOR_MASS, mDynamicsWorld);
@ -252,7 +251,6 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
rp3d::Material& material = mFloor->getRigidBody()->getMaterial(); rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2)); material.setBounciness(rp3d::decimal(0.2));
// ---------- Create the triangular mesh ---------- // // ---------- Create the triangular mesh ---------- //
/* /*

View File

@ -62,7 +62,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name)
mBox = new Box(Vector3(3, 3, 3), spherePos, 80.1, mDynamicsWorld); mBox = new Box(Vector3(3, 3, 3), spherePos, 80.1, mDynamicsWorld);
// Set the sphere color // Set the sphere color
mBox->setColor(mDemoColors[1]); mBox->setColor(mDemoColors[0]);
mBox->setSleepingColor(mRedColorDemo); mBox->setSleepingColor(mRedColorDemo);
// Change the material properties of the rigid body // Change the material properties of the rigid body
@ -82,8 +82,8 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name)
mConcaveMesh->getRigidBody()->setType(rp3d::STATIC); mConcaveMesh->getRigidBody()->setType(rp3d::STATIC);
// Set the box color // Set the box color
mConcaveMesh->setColor(mDemoColors[0]); mConcaveMesh->setColor(mGreyColorDemo);
mConcaveMesh->setSleepingColor(mRedColorDemo); mConcaveMesh->setSleepingColor(mGreyColorDemo);
// Change the material properties of the rigid body // Change the material properties of the rigid body
rp3d::Material& material = mConcaveMesh->getRigidBody()->getMaterial(); rp3d::Material& material = mConcaveMesh->getRigidBody()->getMaterial();

View File

@ -55,13 +55,13 @@ HeightFieldScene::HeightFieldScene(const std::string& name) : SceneDemo(name, SC
for (int i=0; i<NB_BOXES; i++) { for (int i=0; i<NB_BOXES; i++) {
// Position // Position
openglframework::Vector3 spherePos(15, 10, 0); openglframework::Vector3 position(15, 10 + 6 * i, 0);
// Create a sphere and a corresponding rigid in the dynamics world // Create a sphere and a corresponding rigid in the dynamics world
mBoxes[i] = new Box(Vector3(3, 3, 3), spherePos, 80.1, mDynamicsWorld); mBoxes[i] = new Box(Vector3(3, 3, 3), position, 80.1, mDynamicsWorld);
// Set the sphere color // Set the sphere color
mBoxes[i]->setColor(mDemoColors[1]); mBoxes[i]->setColor(mDemoColors[2]);
mBoxes[i]->setSleepingColor(mRedColorDemo); mBoxes[i]->setSleepingColor(mRedColorDemo);
// Change the material properties of the rigid body // Change the material properties of the rigid body
@ -82,8 +82,8 @@ HeightFieldScene::HeightFieldScene(const std::string& name) : SceneDemo(name, SC
mHeightField->getRigidBody()->setType(rp3d::STATIC); mHeightField->getRigidBody()->setType(rp3d::STATIC);
// Set the color // Set the color
mHeightField->setColor(mDemoColors[0]); mHeightField->setColor(mGreyColorDemo);
mHeightField->setSleepingColor(mRedColorDemo); mHeightField->setSleepingColor(mGreyColorDemo);
// Change the material properties of the rigid body // Change the material properties of the rigid body
rp3d::Material& material = mHeightField->getRigidBody()->getMaterial(); rp3d::Material& material = mHeightField->getRigidBody()->getMaterial();