Modifications in testbed application

This commit is contained in:
Daniel Chappuis 2021-11-30 22:19:54 +01:00
parent 2b0b4ea5fd
commit 80c49d3a85
8 changed files with 123795 additions and 25849 deletions

View File

@ -59,3 +59,5 @@ If you find any issue with the library, you can report it on the issue tracker [
Thanks a lot to Erin Catto, Dirk Gregorius, Erwin Coumans, Pierre Terdiman and Christer Ericson for their amazing GDC presentations, Thanks a lot to Erin Catto, Dirk Gregorius, Erwin Coumans, Pierre Terdiman and Christer Ericson for their amazing GDC presentations,
their physics engines, their books or articles and their contributions on many physics engine forums. their physics engines, their books or articles and their contributions on many physics engine forums.
- [Artbake Graphics](https://sketchfab.com/ismir) for the static castle 3D model used in testbed application ([CC license](https://creativecommons.org/licenses/by/4.0))

123770
testbed/meshes/castle.obj Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -119,7 +119,7 @@ void BridgeScene::createPhysicsWorld() {
mBoxes[boxIndex] = new Box(true, BOX_SIZE, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath); mBoxes[boxIndex] = new Box(true, BOX_SIZE, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath);
// Set the box color // Set the box color
mBoxes[boxIndex]->setColor(mObjectColorDemo); mBoxes[boxIndex]->setColor(mFloorColorDemo);
mBoxes[boxIndex]->setSleepingColor(mSleepingColorDemo); mBoxes[boxIndex]->setSleepingColor(mSleepingColorDemo);
// Change the material properties of the rigid body // Change the material properties of the rigid body

View File

@ -37,7 +37,7 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& sett
std::string meshFolderPath("meshes/"); std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene // Compute the radius and the center of the scene
openglframework::Vector3 center(0, 20, 0); openglframework::Vector3 center(0, 15, 0);
// Set the center of the scene // Set the center of the scene
setScenePosition(center, SCENE_RADIUS); setScenePosition(center, SCENE_RADIUS);
@ -167,7 +167,7 @@ void ConcaveMeshScene::createPhysicsWorld() {
// ---------- Create the triangular mesh ---------- // // ---------- Create the triangular mesh ---------- //
// Create a convex mesh and a corresponding rigid in the physics world // Create a convex mesh and a corresponding rigid in the physics world
mConcaveMesh = new ConcaveMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "city.obj"); mConcaveMesh = new ConcaveMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "castle.obj", rp3d::Vector3(0.5, 0.5, 0.5));
// Set the mesh as beeing static // Set the mesh as beeing static
mConcaveMesh->getRigidBody()->setType(rp3d::BodyType::STATIC); mConcaveMesh->getRigidBody()->setType(rp3d::BodyType::STATIC);

View File

@ -42,20 +42,16 @@ namespace trianglemeshscene {
// Constants // Constants
const float SCENE_RADIUS = 70.0f; // Radius of the scene in meters const float SCENE_RADIUS = 70.0f; // Radius of the scene in meters
static const int NB_BOXES = 50; static const int NB_BOXES = 20;
static const int NB_SPHERES = 40; static const int NB_SPHERES = 20;
static const int NB_CAPSULES = 20; static const int NB_CAPSULES = 10;
static const int NB_MESHES = 15; static const int NB_MESHES = 5;
static const int NB_COMPOUND_SHAPES = 3; static const int NB_COMPOUND_SHAPES = 3;
const openglframework::Vector3 BOX_SIZE(2, 2, 2); const openglframework::Vector3 BOX_SIZE(2, 2, 2);
const float SPHERE_RADIUS = 1.5f; const float SPHERE_RADIUS = 0.5f;
const float CONE_RADIUS = 2.0f; const float CAPSULE_RADIUS = 0.5f;
const float CONE_HEIGHT = 3.0f; const float CAPSULE_HEIGHT = 0.5f;
const float CYLINDER_RADIUS = 1.0f; const float DUMBBELL_HEIGHT = 0.5f;
const float CYLINDER_HEIGHT = 5.0f;
const float CAPSULE_RADIUS = 1.0f;
const float CAPSULE_HEIGHT = 1.0f;
const float DUMBBELL_HEIGHT = 1.0f;
// Class TriangleMeshScene // Class TriangleMeshScene
class ConcaveMeshScene : public SceneDemo { class ConcaveMeshScene : public SceneDemo {

View File

@ -34,14 +34,14 @@ using namespace openglframework;
int SceneDemo::shadowMapTextureLevel = 0; int SceneDemo::shadowMapTextureLevel = 0;
//openglframework::Color SceneDemo::mObjectColorDemo = Color(0.76f, 0.67f, 0.47f, 1.0f); //openglframework::Color SceneDemo::mObjectColorDemo = Color(0.76f, 0.67f, 0.47f, 1.0f);
openglframework::Color SceneDemo::mObjectColorDemo = Color(0.21f, 0.65f, 1.0f, 1.0f); openglframework::Color SceneDemo::mObjectColorDemo = Color(0.0f, 0.68f, 0.99f, 1.0f);
openglframework::Color SceneDemo::mFloorColorDemo = Color(0.47f, 0.48f, 0.49f, 1.0f); openglframework::Color SceneDemo::mFloorColorDemo = Color(0.7f, 0.7f, 0.7f, 1.0f);
openglframework::Color SceneDemo::mSleepingColorDemo = Color(1.0f, 0.25f, 0.25f, 1.0f); openglframework::Color SceneDemo::mSleepingColorDemo = Color(1.0f, 0.0f, 0.0f, 1.0f);
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.88f, 0.09f, 1.0f); openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.88f, 0.09f, 1.0f);
// Constructor // Constructor
SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon, bool isPhysicsWorldSimulated, bool isShadowMappingEnabled) SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon, bool isPhysicsWorldSimulated, bool isShadowMappingEnabled)
: Scene(name, settings, isShadowMappingEnabled), mBackgroundColor(0.15, 0.15, 0.15, 1), : Scene(name, settings, isShadowMappingEnabled), mBackgroundColor(0.75, 0.75, 0.75, 1),
mIsShadowMappingInitialized(false), mIsShadowMappingInitialized(false),
mDepthShader("shaders/depth.vert", "shaders/depth.frag"), mDepthShader("shaders/depth.vert", "shaders/depth.frag"),
mPhongShader("shaders/phong.vert", "shaders/phong.frag"), mPhongShader("shaders/phong.vert", "shaders/phong.frag"),
@ -54,18 +54,19 @@ SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, reactphy
shadowMapTextureLevel++; shadowMapTextureLevel++;
// Move the lights // Move the lights
float lightsRadius = 40.0f; float lightsRadius = 80.0f;
float lightsHeight = 50.0f; float lightsHeight = 50.0f;
mLight0.translateWorld(Vector3(0.4f * lightsRadius, 0.6 * lightsHeight, 0.4f * lightsRadius)); mLight0.translateWorld(Vector3(0.4f * lightsRadius, 0.6 * lightsHeight, 0.4f * lightsRadius));
mLight1.translateWorld(Vector3(-0.4 * lightsRadius, 0.6 * lightsHeight, 0.4 * lightsRadius)); mLight1.translateWorld(Vector3(-0.4 * lightsRadius, 0.6 * lightsHeight, 0.4 * lightsRadius));
mLight2.translateWorld(Vector3(-0.40f * lightsRadius, -lightsHeight, -0.4f * lightsRadius)); mLight2.translateWorld(Vector3(0.40f * lightsRadius, -5, -0.4f * lightsRadius));
// Set the lights colors // Set the lights colors
float lightIntensity = 0.6f; float lightIntensity = 0.5;
Color lightColor(lightIntensity * 1.0, lightIntensity * 1.0f, lightIntensity * 1.0f, 1.0f); Color lightColor(lightIntensity * 1.0, lightIntensity * 1.0f, lightIntensity * 1.0f, 1.0f);
Color noLightColor(0, 0, 0, 1);
mLight0.setDiffuseColor(lightColor); mLight0.setDiffuseColor(lightColor);
mLight1.setDiffuseColor(lightColor); mLight1.setDiffuseColor(lightColor);
mLight2.setDiffuseColor(lightColor); mLight2.setDiffuseColor(noLightColor);
mShadowMapLightCameras[0].translateWorld(mLight0.getOrigin()); mShadowMapLightCameras[0].translateWorld(mLight0.getOrigin());
mShadowMapLightCameras[0].rotateLocal(Vector3(1, 0, 0), -PI / 4.0f); mShadowMapLightCameras[0].rotateLocal(Vector3(1, 0, 0), -PI / 4.0f);
@ -151,7 +152,7 @@ void SceneDemo::update() {
void SceneDemo::rotateCameraAnimation() { void SceneDemo::rotateCameraAnimation() {
const float angle = 0.1f * (PI / 180.0); const float angle = 0.12f * (PI / 180.0);
mCamera.rotateAroundWorldPoint(Vector3(0, 1, 0), angle, mCenterScene); mCamera.rotateAroundWorldPoint(Vector3(0, 1, 0), angle, mCenterScene);
} }
@ -258,7 +259,7 @@ void SceneDemo::render() {
mPhongShader.setVector3Uniform("light0PosCameraSpace", worldToCameraMatrix * mLight0.getOrigin()); mPhongShader.setVector3Uniform("light0PosCameraSpace", worldToCameraMatrix * mLight0.getOrigin());
mPhongShader.setVector3Uniform("light1PosCameraSpace", worldToCameraMatrix * mLight1.getOrigin()); mPhongShader.setVector3Uniform("light1PosCameraSpace", worldToCameraMatrix * mLight1.getOrigin());
mPhongShader.setVector3Uniform("light2PosCameraSpace", worldToCameraMatrix * mLight2.getOrigin()); mPhongShader.setVector3Uniform("light2PosCameraSpace", worldToCameraMatrix * mLight2.getOrigin());
mPhongShader.setVector3Uniform("lightAmbientColor", Vector3(0.2f, 0.2f, 0.2f)); mPhongShader.setVector3Uniform("lightAmbientColor", Vector3(0.1f, 0.1f, 0.1f));
mPhongShader.setVector3Uniform("light0DiffuseColor", Vector3(mLight0.getDiffuseColor().r, mLight0.getDiffuseColor().g, mLight0.getDiffuseColor().b)); mPhongShader.setVector3Uniform("light0DiffuseColor", Vector3(mLight0.getDiffuseColor().r, mLight0.getDiffuseColor().g, mLight0.getDiffuseColor().b));
mPhongShader.setVector3Uniform("light1DiffuseColor", Vector3(mLight1.getDiffuseColor().r, mLight1.getDiffuseColor().g, mLight1.getDiffuseColor().b)); mPhongShader.setVector3Uniform("light1DiffuseColor", Vector3(mLight1.getDiffuseColor().r, mLight1.getDiffuseColor().g, mLight1.getDiffuseColor().b));
mPhongShader.setVector3Uniform("light2DiffuseColor", Vector3(mLight2.getDiffuseColor().r, mLight2.getDiffuseColor().g, mLight2.getDiffuseColor().b)); mPhongShader.setVector3Uniform("light2DiffuseColor", Vector3(mLight2.getDiffuseColor().r, mLight2.getDiffuseColor().g, mLight2.getDiffuseColor().b));

View File

@ -36,7 +36,7 @@
// Constants // Constants
const int SHADOWMAP_WIDTH = 2048; const int SHADOWMAP_WIDTH = 2048;
const int SHADOWMAP_HEIGHT = 2048; const int SHADOWMAP_HEIGHT = 2048;
const float MOUSE_MOVE_BODY_FORCE = 100000.0f; const float MOUSE_MOVE_BODY_FORCE = 200000.0f;
// Class SceneDemo // Class SceneDemo
// Abstract class that represents a 3D scene for the ReactPhysics3D examples. // Abstract class that represents a 3D scene for the ReactPhysics3D examples.