From 4d982ebd31f41636a462765804f94be62acd9293 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 21 Mar 2016 23:02:05 +0100 Subject: [PATCH] Fix sleeping colors in testbed application --- testbed/common/ConcaveMesh.cpp | 3 ++- testbed/common/Cone.cpp | 3 ++- testbed/common/ConvexMesh.cpp | 3 ++- testbed/common/Cylinder.cpp | 3 ++- testbed/common/Dumbbell.cpp | 3 ++- testbed/common/HeightField.cpp | 3 ++- testbed/common/Sphere.cpp | 3 ++- .../scenes/collisionshapes/CollisionShapesScene.cpp | 2 -- testbed/scenes/concavemesh/ConcaveMeshScene.cpp | 6 +++--- testbed/scenes/heightfield/HeightFieldScene.cpp | 10 +++++----- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/testbed/common/ConcaveMesh.cpp b/testbed/common/ConcaveMesh.cpp index 3601e34a..4338a70d 100644 --- a/testbed/common/ConcaveMesh.cpp +++ b/testbed/common/ConcaveMesh.cpp @@ -182,7 +182,8 @@ void ConcaveMesh::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/Cone.cpp b/testbed/common/Cone.cpp index cbe25563..bc24c26e 100644 --- a/testbed/common/Cone.cpp +++ b/testbed/common/Cone.cpp @@ -166,7 +166,8 @@ void Cone::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/ConvexMesh.cpp b/testbed/common/ConvexMesh.cpp index 6c272d36..365713a4 100644 --- a/testbed/common/ConvexMesh.cpp +++ b/testbed/common/ConvexMesh.cpp @@ -163,7 +163,8 @@ void ConvexMesh::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/Cylinder.cpp b/testbed/common/Cylinder.cpp index 1342eeb5..b96ee839 100644 --- a/testbed/common/Cylinder.cpp +++ b/testbed/common/Cylinder.cpp @@ -167,7 +167,8 @@ void Cylinder::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/Dumbbell.cpp b/testbed/common/Dumbbell.cpp index d7a232aa..7909d281 100644 --- a/testbed/common/Dumbbell.cpp +++ b/testbed/common/Dumbbell.cpp @@ -208,7 +208,8 @@ void Dumbbell::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/HeightField.cpp b/testbed/common/HeightField.cpp index 58dc6af4..5240c05f 100644 --- a/testbed/common/HeightField.cpp +++ b/testbed/common/HeightField.cpp @@ -148,7 +148,8 @@ void HeightField::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/common/Sphere.cpp b/testbed/common/Sphere.cpp index a7a0c880..05072749 100644 --- a/testbed/common/Sphere.cpp +++ b/testbed/common/Sphere.cpp @@ -168,7 +168,8 @@ void Sphere::render(openglframework::Shader& shader, shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); // 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); // Bind the VAO diff --git a/testbed/scenes/collisionshapes/CollisionShapesScene.cpp b/testbed/scenes/collisionshapes/CollisionShapesScene.cpp index f6fda6f2..d5aca068 100644 --- a/testbed/scenes/collisionshapes/CollisionShapesScene.cpp +++ b/testbed/scenes/collisionshapes/CollisionShapesScene.cpp @@ -237,7 +237,6 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name) // ---------- Create the floor --------- - openglframework::Vector3 floorPosition(0, 0, 0); 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(); material.setBounciness(rp3d::decimal(0.2)); - // ---------- Create the triangular mesh ---------- // /* diff --git a/testbed/scenes/concavemesh/ConcaveMeshScene.cpp b/testbed/scenes/concavemesh/ConcaveMeshScene.cpp index fdff04ce..fcbd095d 100644 --- a/testbed/scenes/concavemesh/ConcaveMeshScene.cpp +++ b/testbed/scenes/concavemesh/ConcaveMeshScene.cpp @@ -62,7 +62,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name) mBox = new Box(Vector3(3, 3, 3), spherePos, 80.1, mDynamicsWorld); // Set the sphere color - mBox->setColor(mDemoColors[1]); + mBox->setColor(mDemoColors[0]); mBox->setSleepingColor(mRedColorDemo); // Change the material properties of the rigid body @@ -82,8 +82,8 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name) mConcaveMesh->getRigidBody()->setType(rp3d::STATIC); // Set the box color - mConcaveMesh->setColor(mDemoColors[0]); - mConcaveMesh->setSleepingColor(mRedColorDemo); + mConcaveMesh->setColor(mGreyColorDemo); + mConcaveMesh->setSleepingColor(mGreyColorDemo); // Change the material properties of the rigid body rp3d::Material& material = mConcaveMesh->getRigidBody()->getMaterial(); diff --git a/testbed/scenes/heightfield/HeightFieldScene.cpp b/testbed/scenes/heightfield/HeightFieldScene.cpp index a3796337..28246af9 100644 --- a/testbed/scenes/heightfield/HeightFieldScene.cpp +++ b/testbed/scenes/heightfield/HeightFieldScene.cpp @@ -55,13 +55,13 @@ HeightFieldScene::HeightFieldScene(const std::string& name) : SceneDemo(name, SC for (int i=0; isetColor(mDemoColors[1]); + mBoxes[i]->setColor(mDemoColors[2]); mBoxes[i]->setSleepingColor(mRedColorDemo); // 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); // Set the color - mHeightField->setColor(mDemoColors[0]); - mHeightField->setSleepingColor(mRedColorDemo); + mHeightField->setColor(mGreyColorDemo); + mHeightField->setSleepingColor(mGreyColorDemo); // Change the material properties of the rigid body rp3d::Material& material = mHeightField->getRigidBody()->getMaterial();