Improvements of the tesbted application

This commit is contained in:
Daniel Chappuis 2021-11-18 07:12:22 +01:00
parent 2545e5f702
commit 08da70bfcd
42 changed files with 218 additions and 242 deletions

View File

@ -27,13 +27,17 @@
#include "ConcaveMesh.h"
// Constructor
ConcaveMesh::ConcaveMesh(bool createRigidBody, reactphysics3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld, const std::string& meshPath)
ConcaveMesh::ConcaveMesh(bool createRigidBody, reactphysics3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld,
const std::string& meshPath, const rp3d::Vector3& scaling)
: PhysicsObject(physicsCommon, meshPath), mPhysicsWorld(physicsWorld), mVBOVertices(GL_ARRAY_BUFFER),
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
// Compute the scaling matrix
mScalingMatrix = openglframework::Matrix4::identity();
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,
0, scaling.y, 0, 0,
0, 0, scaling.z, 0,
0, 0, 0, 1);
mPhysicsTriangleMesh = mPhysicsCommon.createTriangleMesh();
@ -53,7 +57,7 @@ ConcaveMesh::ConcaveMesh(bool createRigidBody, reactphysics3d::PhysicsCommon& ph
// Create the collision shape for the rigid body (convex mesh shape) and
// do not forget to delete it at the end
mConcaveShape = mPhysicsCommon.createConcaveMeshShape(mPhysicsTriangleMesh);
mConcaveShape = mPhysicsCommon.createConcaveMeshShape(mPhysicsTriangleMesh, scaling);
mPreviousTransform = rp3d::Transform::identity();

View File

@ -75,7 +75,8 @@ class ConcaveMesh : public PhysicsObject {
// -------------------- Methods -------------------- //
/// Constructor
ConcaveMesh(bool createRigidBody, reactphysics3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld, const std::string& meshPath);
ConcaveMesh(bool createRigidBody, reactphysics3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld,
const std::string& meshPath, const reactphysics3d::Vector3& scaling = rp3d::Vector3(1, 1, 1));
/// Destructor
virtual ~ConcaveMesh() override;

View File

@ -28,13 +28,17 @@
#include <unordered_set>
// Constructor
ConvexMesh::ConvexMesh(bool createRigidBody, rp3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld, const std::string& meshPath)
ConvexMesh::ConvexMesh(bool createRigidBody, rp3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld,
const std::string& meshPath, const rp3d::Vector3& scaling)
: PhysicsObject(physicsCommon, meshPath), mPhysicsWorld(physicsWorld), mVBOVertices(GL_ARRAY_BUFFER),
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
// Compute the scaling matrix
mScalingMatrix = openglframework::Matrix4::identity();
mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0,
0, scaling.y, 0, 0,
0, 0, scaling.z, 0,
0, 0, 0, 1);
// Polygon faces descriptions for the polyhedron
mPolygonFaces = new rp3d::PolygonVertexArray::PolygonFace[getNbFaces(0)];
@ -71,7 +75,7 @@ ConvexMesh::ConvexMesh(bool createRigidBody, rp3d::PhysicsCommon& physicsCommon,
// Create the collision shape for the rigid body (convex mesh shape) and do
// not forget to delete it at the end
mConvexShape = mPhysicsCommon.createConvexMeshShape(mPolyhedronMesh);
mConvexShape = mPhysicsCommon.createConvexMeshShape(mPolyhedronMesh, scaling);
mPreviousTransform = rp3d::Transform::identity();

View File

@ -88,7 +88,8 @@ class ConvexMesh : public PhysicsObject {
// -------------------- Methods -------------------- //
/// Constructor
ConvexMesh(bool createRigidBody, rp3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld, const std::string& meshPath);
ConvexMesh(bool createRigidBody, rp3d::PhysicsCommon& physicsCommon, rp3d::PhysicsWorld* physicsWorld,
const std::string& meshPath, const reactphysics3d::Vector3& scaling = rp3d::Vector3(1, 1, 1));
/// Destructor
virtual ~ConvexMesh() override;

View File

@ -35,7 +35,7 @@ HeightField::HeightField(bool createRigidBody, reactphysics3d::PhysicsCommon& ph
// Compute the scaling matrix
//mScalingMatrix = openglframework::Matrix4::identity();
mScalingMatrix = openglframework::Matrix4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1);
mScalingMatrix = openglframework::Matrix4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1);
// Generate the height field
generateHeightField();
@ -47,7 +47,7 @@ HeightField::HeightField(bool createRigidBody, reactphysics3d::PhysicsCommon& ph
// do not forget to delete it at the end
mHeightFieldShape = mPhysicsCommon.createHeightFieldShape(NB_POINTS_WIDTH, NB_POINTS_LENGTH, mMinHeight, mMaxHeight,
mHeightData, rp3d::HeightFieldShape::HeightDataType::HEIGHT_FLOAT_TYPE);
mHeightFieldShape->setScale(rp3d::Vector3(2, 2, 2));
mHeightFieldShape->setScale(rp3d::Vector3(0.5, 0.5, 0.5));
mPreviousTransform = rp3d::Transform::identity();

36
testbed/meshes/pile.obj Normal file
View File

@ -0,0 +1,36 @@
# Blender v2.82 (sub 7) OBJ File: 'Pile.blend'
# www.blender.org
o Cube
v 22.184696 4.733990 -22.184696
v 22.184696 -5.811781 -22.184696
v 22.184696 4.733990 22.184696
v 22.184696 -5.811781 22.184696
v -22.184696 4.733990 -22.184696
v -22.184696 -5.811781 -22.184696
v -22.184696 4.733990 22.184696
v -22.184696 -5.811781 22.184696
v 11.135588 -4.521785 11.135588
v -11.135588 -4.521785 11.135588
v 11.135588 -4.521785 -11.135588
v -11.135588 -4.521785 -11.135588
vn 0.0000 0.7666 -0.6422
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 1.0000 0.0000
vn 0.6422 0.7666 0.0000
vn -0.6422 0.7666 0.0000
vn 0.0000 0.7666 0.6422
s off
f 7//1 3//1 9//1 10//1
f 4//2 3//2 7//2 8//2
f 8//3 7//3 5//3 6//3
f 6//4 2//4 4//4 8//4
f 2//5 1//5 3//5 4//5
f 6//6 5//6 1//6 2//6
f 11//7 12//7 10//7 9//7
f 5//8 7//8 10//8 12//8
f 3//9 1//9 11//9 9//9
f 1//10 5//10 12//10 11//10

View File

@ -1,116 +0,0 @@
# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
v -31.880749 -0.589469 22.622011
v -25.786182 -0.589469 22.622011
v -19.691614 -0.589469 22.622011
v -13.597046 -0.589469 22.622011
v -7.502479 -0.589469 22.622011
v -1.407912 -0.589469 22.622011
v 4.686658 -0.589469 22.622011
v 10.781222 -0.589469 22.622011
v -31.880749 -0.589469 16.527445
v -25.786182 -0.589469 16.527445
v -19.691614 -0.589469 16.527445
v -13.597046 -0.589469 16.527445
v -7.502479 -0.589469 16.527445
v -1.407912 -0.589469 16.527445
v 4.686658 -0.589469 16.527445
v 10.781222 -0.589469 16.527445
v -31.880749 -0.589469 10.432877
v -25.786182 -0.589469 10.432877
v -19.691614 -13.260081 10.432877
v -13.597046 -13.260081 10.432877
v -7.502479 -13.260081 10.432877
v -1.407912 -13.260081 10.432877
v 4.686658 -13.260081 10.432877
v 10.781222 -0.589469 10.432877
v -31.880749 -0.589469 4.338308
v -25.786182 -0.589469 4.338308
v -19.691614 -13.260081 4.338308
v -13.597046 -13.260081 4.338308
v -7.502479 -13.260081 4.338308
v -1.407912 -13.260081 4.338308
v 4.686658 -13.260081 4.338308
v 10.781222 -0.589469 4.338308
v -31.880749 -0.589469 -1.756259
v -25.786182 -0.589469 -1.756259
v -19.691614 -13.260081 -1.756259
v -13.597046 -13.260081 -1.756259
v -7.502479 -13.260081 -1.756259
v -1.407912 -13.260081 -1.756259
v 4.686658 -13.260081 -1.756259
v 10.781222 -0.589469 -1.756259
v -31.880749 -0.589469 -7.850826
v -25.786182 -0.589469 -7.850826
v -19.691614 -13.260081 -7.850826
v -13.597046 -13.260081 -7.850826
v -7.502479 -13.260081 -7.850826
v -1.407912 -13.260081 -7.850826
v 4.686658 -13.260081 -7.850826
v 10.781222 -0.589469 -7.850826
v -31.880749 -0.589469 -13.945395
v -25.786182 -0.589469 -13.945395
v -19.691614 -0.589469 -13.945395
v -13.597046 -0.589469 -13.945395
v -7.502479 -0.589469 -13.945395
v -1.407912 -0.589469 -13.945395
v 4.686658 -0.589469 -13.945395
v 10.781222 -0.589469 -13.945395
v -31.880749 -0.589469 -20.039961
v -25.786182 -0.589469 -20.039961
v -19.691614 -0.589469 -20.039961
v -13.597046 -0.589469 -20.039961
v -7.502479 -0.589469 -20.039961
v -1.407912 -0.589469 -20.039961
v 4.686658 -0.589469 -20.039961
v 10.781222 -0.589469 -20.039961
s off
f 1 2 10 9
f 2 3 11 10
f 3 4 12 11
f 4 5 13 12
f 5 6 14 13
f 6 7 15 14
f 7 8 16 15
f 9 10 18 17
f 10 11 19 18
f 11 12 20 19
f 12 13 21 20
f 13 14 22 21
f 14 15 23 22
f 15 16 24 23
f 17 18 26 25
f 18 19 27 26
f 19 20 28 27
f 20 21 29 28
f 21 22 30 29
f 22 23 31 30
f 23 24 32 31
f 25 26 34 33
f 26 27 35 34
f 27 28 36 35
f 28 29 37 36
f 29 30 38 37
f 30 31 39 38
f 31 32 40 39
f 33 34 42 41
f 34 35 43 42
f 35 36 44 43
f 36 37 45 44
f 37 38 46 45
f 38 39 47 46
f 39 40 48 47
f 41 42 50 49
f 42 43 51 50
f 43 44 52 51
f 44 45 53 52
f 45 46 54 53
f 46 47 55 54
f 47 48 56 55
f 49 50 58 57
f 50 51 59 58
f 51 52 60 59
f 52 53 61 60
f 53 54 62 61
f 54 55 63 62
f 55 56 64 63

View File

@ -40,6 +40,8 @@ BallAndSocketJointScene::BallAndSocketJointScene(const std::string& name, Engine
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -42,6 +42,8 @@ BallAndSocketJointsChainScene::BallAndSocketJointsChainScene(const std::string&
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.3);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -42,6 +42,8 @@ BallAndSocketJointsNetScene::BallAndSocketJointsNetScene(const std::string& name
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.3);
resetCameraToViewAll();
// Gravity vector in the physics world
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);

View File

@ -39,10 +39,12 @@ BoxTowerScene::BoxTowerScene(const std::string& name, EngineSettings& settings,
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 10, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.5);
resetCameraToViewAll();
// Gravity vector in the physics world
rp3d::Vector3 gravity(0, -9.81f, 0);

View File

@ -44,7 +44,7 @@ namespace boxtowerscene {
const float SCENE_RADIUS = 30.0f;
const int NB_BOXES = 16;
const openglframework::Vector3 BOX_SIZE(2, 2, 16);
const openglframework::Vector3 FLOOR_SIZE(50, 0.5f, 50); // Floor dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(30, 0.5f, 30); // Floor dimensions in meters
// Class BoxTowerScene
class BoxTowerScene : public SceneDemo {

View File

@ -38,10 +38,12 @@ BridgeScene::BridgeScene(const std::string& name, EngineSettings& settings, reac
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 0, 0);
openglframework::Vector3 center(0, 5, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -48,6 +48,8 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name, Engine
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.9);
resetCameraToViewAll();
rp3d::PhysicsWorld::WorldSettings worldSettings;
worldSettings.worldName = name;

View File

@ -37,10 +37,12 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettin
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 10, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.5);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -56,7 +56,7 @@ const float CYLINDER_HEIGHT = 5.0f;
const float CAPSULE_RADIUS = 1.0f;
const float CAPSULE_HEIGHT = 1.0f;
const float DUMBBELL_HEIGHT = 1.0f;
const openglframework::Vector3 FLOOR_SIZE(50, 0.5f, 50); // Floor dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(30, 0.5f, 30); // Floor dimensions in meters
// Class CollisionShapesScene
class CollisionShapesScene : public SceneDemo {

View File

@ -37,10 +37,12 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& sett
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 20, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.5);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}
@ -248,7 +250,8 @@ void ConcaveMeshScene::initBodiesPositions() {
// ---------- Create the triangular mesh ---------- //
mConcaveMesh->setTransform(rp3d::Transform::identity());
mConcaveMesh->setTransform(rp3d::Transform(rp3d::Vector3(15, 0, -5), rp3d::Quaternion::identity()));
}
// Destroy the physics world

View File

@ -34,13 +34,13 @@ using namespace cubesscene;
CubesScene::CubesScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
iter = 0;
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 10, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.5);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}
@ -95,7 +95,7 @@ void CubesScene::createPhysicsWorld() {
// Initialize the bodies positions
void CubesScene::initBodiesPositions() {
float radius = 2.0f;
const float radius = 2.0f;
// Create all the cubes of the scene
std::vector<Box*>::iterator it;

View File

@ -38,7 +38,7 @@ namespace cubesscene {
const float SCENE_RADIUS = 30.0f; // Radius of the scene in meters
const int NB_CUBES = 30; // Number of boxes in the scene
const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(50, 1, 50); // Floor dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(30, 1, 30); // Floor dimensions in meters
// Class CubesScene
class CubesScene : public SceneDemo {
@ -53,8 +53,6 @@ class CubesScene : public SceneDemo {
/// Box for the floor
Box* mFloor;
unsigned int iter;
/// World settings
rp3d::PhysicsWorld::WorldSettings mWorldSettings;

View File

@ -35,10 +35,12 @@ CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 16, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.9);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -38,7 +38,7 @@ namespace cubestackscene {
const float SCENE_RADIUS = 30.0f; // Radius of the scene in meters
const int NB_FLOORS = 15; // Number of boxes in the scene
const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(50, 1, 50); // Floor dimensions in meters
const openglframework::Vector3 FLOOR_SIZE(50, 1, 20); // Floor dimensions in meters
// Class CubeStackScene
class CubeStackScene : public SceneDemo {

View File

@ -40,6 +40,8 @@ FixedJointScene::FixedJointScene(const std::string& name, EngineSettings& settin
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -39,10 +39,12 @@ HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& sett
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 17, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.5);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -40,6 +40,8 @@ HingeJointScene::HingeJointScene(const std::string& name, EngineSettings& settin
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -42,6 +42,8 @@ HingeJointsChainScene::HingeJointsChainScene(const std::string& name, EngineSett
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.3);
resetCameraToViewAll();
// Gravity vector in the physics world
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);

View File

@ -36,10 +36,12 @@ JointsScene::JointsScene(const std::string& name, EngineSettings& settings, reac
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 8, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1);
resetCameraToViewAll();
// Gravity vector in the physics world
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);

View File

@ -37,7 +37,7 @@ namespace jointsscene {
// Constants
const float SCENE_RADIUS = 30.0f;
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 openglframework::Vector3 FLOOR_SIZE(15, 0.5f, 15); // Floor dimensions in meters
const int NB_BALLSOCKETJOINT_BOXES = 7; // Number of Ball-And-Socket chain boxes
const int NB_HINGE_BOXES = 7; // Number of Hinge chain boxes

View File

@ -37,7 +37,7 @@ PileScene::PileScene(const std::string& name, EngineSettings& settings, reactphy
std::string meshFolderPath("meshes/");
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 15, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
@ -146,7 +146,7 @@ void PileScene::createPhysicsWorld() {
for (int i=0; i<NB_MESHES; i++) {
// Create a convex mesh and a corresponding rigid in the physics world
ConvexMesh* mesh = new ConvexMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "convexmesh.obj");
ConvexMesh* mesh = new ConvexMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "convexmesh.obj", rp3d::Vector3(2, 2, 2));
// Set the box color
mesh->setColor(mObjectColorDemo);
@ -164,7 +164,7 @@ void PileScene::createPhysicsWorld() {
// ---------- Create the triangular mesh ---------- //
// Create a convex mesh and a corresponding rigid in the physics world
mSandbox = new ConcaveMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "sandbox.obj");
mSandbox = new ConcaveMesh(true, mPhysicsCommon, mPhysicsWorld, mMeshFolderPath + "pile.obj");
// Set the mesh as beeing static
mSandbox->getRigidBody()->setType(rp3d::BodyType::STATIC);
@ -191,7 +191,7 @@ void PileScene::initBodiesPositions() {
// Position
float angle = i * 30.0f;
rp3d::Vector3 position(radius * std::cos(angle),
125 + i * (DUMBBELL_HEIGHT + 0.3f),
90 + i * (DUMBBELL_HEIGHT + 0.3f),
radius * std::sin(angle));
mDumbbells[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
@ -203,7 +203,7 @@ void PileScene::initBodiesPositions() {
// Position
float angle = i * 30.0f;
rp3d::Vector3 position(radius * std::cos(angle),
85 + i * (BOX_SIZE.y + 0.8f),
70 + i * (BOX_SIZE.y + 0.8f),
radius * std::sin(angle));
mBoxes[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
@ -215,7 +215,7 @@ void PileScene::initBodiesPositions() {
// Position
float angle = i * 35.0f;
rp3d::Vector3 position(radius * std::cos(angle),
75 + i * (SPHERE_RADIUS + 0.8f),
50 + i * (SPHERE_RADIUS + 0.8f),
radius * std::sin(angle));
mSpheres[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
@ -227,7 +227,7 @@ void PileScene::initBodiesPositions() {
// Position
float angle = i * 45.0f;
rp3d::Vector3 position(radius * std::cos(angle),
40 + i * (CAPSULE_HEIGHT + 0.3f),
30 + i * (CAPSULE_HEIGHT + 0.3f),
radius * std::sin(angle));
mCapsules[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
@ -239,7 +239,7 @@ void PileScene::initBodiesPositions() {
// Position
float angle = i * 30.0f;
rp3d::Vector3 position(radius * std::cos(angle),
30 + i * (CAPSULE_HEIGHT + 0.3f),
10 + i * (CAPSULE_HEIGHT + 0.3f),
radius * std::sin(angle));
mConvexMeshes[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));

View File

@ -42,19 +42,15 @@ namespace pilescene {
// Constants
const float SCENE_RADIUS = 30.0f;
const int NB_BOXES = 150;
const int NB_SPHERES = 80;
const int NB_CAPSULES = 5;
const int NB_MESHES = 0;
const int NB_BOXES = 100;
const int NB_SPHERES = 40;
const int NB_CAPSULES = 30;
const int NB_MESHES = 30;
const int NB_COMPOUND_SHAPES = 0;
const openglframework::Vector3 BOX_SIZE(2, 2, 2);
const float SPHERE_RADIUS = 1.5f;
const float CONE_RADIUS = 2.0f;
const float CONE_HEIGHT = 3.0f;
const float CYLINDER_RADIUS = 1.0f;
const float CYLINDER_HEIGHT = 5.0f;
const float CAPSULE_RADIUS = 1.0f;
const float CAPSULE_HEIGHT = 1.0f;
const openglframework::Vector3 BOX_SIZE(3, 3, 3);
const float SPHERE_RADIUS = 2.5f;
const float CAPSULE_RADIUS = 1.5f;
const float CAPSULE_HEIGHT = 3.0f;
const float DUMBBELL_HEIGHT = 1.0f;
const openglframework::Vector3 FLOOR_SIZE(50, 0.5f, 50); // Floor dimensions in meters

View File

@ -36,10 +36,12 @@ RagdollScene::RagdollScene(const std::string& name, EngineSettings& settings, re
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
// Compute the radius and the center of the scene
openglframework::Vector3 center(0, 5, 0);
openglframework::Vector3 center(0, 10, 0);
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(2.1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -41,6 +41,8 @@ RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings, re
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(2);
resetCameraToViewAll();
rp3d::PhysicsWorld::WorldSettings worldSettings;
worldSettings.worldName = name;

View File

@ -44,6 +44,8 @@ RopeScene::RopeScene(const std::string& name, EngineSettings& settings, reactphy
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}
@ -192,8 +194,6 @@ void RopeScene::createPhysicsWorld() {
material1.setMassDensity(rp3d::decimal(0.02));
mBox1->getRigidBody()->updateMassPropertiesFromColliders();
std::cout << "Mass: " << mBox1->getRigidBody()->getMass() << std::endl;
mPhysicsObjects.push_back(mBox1);
// ---------- Create the second box --------- //
@ -220,9 +220,7 @@ void RopeScene::createPhysicsWorld() {
// Create a box and a corresponding rigid in the physics world
mPlank = new Box(true, Vector3(10, 2, 15), mPhysicsCommon, mPhysicsWorld, mMeshFolderPath);
mPlank->getRigidBody()->setType(rp3d::BodyType::STATIC);
// Set the box color
mPlank->setColor(mObjectColorDemo);
mPlank->setColor(mFloorColorDemo);
mPlank->setSleepingColor(mSleepingColorDemo);
// Change the material properties of the rigid body

View File

@ -40,6 +40,8 @@ SliderJointScene::SliderJointScene(const std::string& name, EngineSettings& sett
// Set the center of the scene
setScenePosition(center, SCENE_RADIUS);
setInitZoom(1.1);
resetCameraToViewAll();
mWorldSettings.worldName = name;
}

View File

@ -36,7 +36,6 @@ uniform vec3 light2DiffuseColor; // Light 2 diffuse color
uniform sampler2D textureSampler; // Texture
uniform sampler2D shadowMapSampler0; // Shadow map texture sampler
uniform sampler2D shadowMapSampler1; // Shadow map texture sampler
uniform sampler2D shadowMapSampler2; // Shadow map texture sampler
uniform bool isTexture; // True if we need to use the texture
uniform vec4 globalVertexColor; // Vertex color
uniform bool isShadowEnabled; // True if shadow mapping is enabled
@ -46,7 +45,7 @@ uniform vec2 shadowMapDimension; // Shadow map dimension
in vec3 vertexPosCameraSpace; // Camera-space position of the vertex
in vec3 vertexNormalCameraSpace; // Vertex normal in camera-space
in vec2 texCoords; // Texture coordinates
in vec4 shadowMapCoords[3]; // Shadow map texture coords
in vec4 shadowMapCoords[2]; // Shadow map texture coords
// Out variable
out vec4 color; // Output color
@ -72,18 +71,22 @@ void main() {
color = vec4(ambient, 1);
vec3 lightPosCameraSpace[3];
vec3 lightPosCameraSpace[3];
lightPosCameraSpace[0] = light0PosCameraSpace;
lightPosCameraSpace[1] = light1PosCameraSpace;
lightPosCameraSpace[2] = light2PosCameraSpace;
vec3 lightDiffuseColor[3];
vec3 lightDiffuseColor[3];
lightDiffuseColor[0] = light0DiffuseColor;
lightDiffuseColor[1] = light1DiffuseColor;
lightDiffuseColor[2] = light2DiffuseColor;
bool isShadowEnabledForLight[3];
isShadowEnabledForLight[0] = true;
isShadowEnabledForLight[1] = true;
isShadowEnabledForLight[2] = false;
// For each light source
for (int l=0; l < 3; l++) {
for (int l=0; l < 3; l++) {
// Compute the diffuse term of light 0
vec3 L0 = normalize(lightPosCameraSpace[l] - vertexPosCameraSpace);
@ -92,7 +95,8 @@ void main() {
// Compute shadow factor
float shadow = 1.0;
if (isShadowEnabled) {
if (isShadowEnabled && isShadowEnabledForLight[l]) {
shadow = 0.0;
float bias = 0.0003;
float shadowBias = -0.000;
@ -102,15 +106,14 @@ void main() {
// PCF Shadow Mapping
for (float i=-1; i<=1; i++) {
for (float j=-1; j<=1; j++) {
float distInShadowMap0 = textureLookupPCF(shadowMapSampler0, shadowMapCoordsOverW.xy, vec2(i, j)) + bias;
float distInShadowMap1 = textureLookupPCF(shadowMapSampler1, shadowMapCoordsOverW.xy, vec2(i, j)) + bias;
float distInShadowMap2 = textureLookupPCF(shadowMapSampler2, shadowMapCoordsOverW.xy, vec2(i, j)) + bias;
float distInShadowMap = l == 0 ? distInShadowMap0 : (l == 1 ? distInShadowMap1 : distInShadowMap2);
if (shadowMapCoords[l].w > 0) {
shadow += distInShadowMap < shadowMapCoordsOverW.z ? 0.5 : 1.0;
}
}
for (float j=-1; j<=1; j++) {
float distInShadowMap0 = textureLookupPCF(shadowMapSampler0, shadowMapCoordsOverW.xy, vec2(i, j)) + bias;
float distInShadowMap1 = textureLookupPCF(shadowMapSampler1, shadowMapCoordsOverW.xy, vec2(i, j)) + bias;
float distInShadowMap = l == 0 ? distInShadowMap0 : distInShadowMap1;
if (shadowMapCoords[l].w > 0) {
shadow += distInShadowMap < shadowMapCoordsOverW.z ? 0.5 : 1.0;
}
}
}
shadow /= 9.0;
}

View File

@ -30,12 +30,10 @@ uniform mat4 localToWorldMatrix; // Local-space to world-space matrix
uniform mat4 worldToCameraMatrix; // World-space to camera-space matrix
uniform mat4 worldToLight0CameraMatrix; // World-space to light0 camera-space matrix (for shadow mapping)
uniform mat4 worldToLight1CameraMatrix; // World-space to light1 camera-space matrix (for shadow mapping)
uniform mat4 worldToLight2CameraMatrix; // World-space to light2 camera-space matrix (for shadow mapping)
uniform mat4 projectionMatrix; // Projection matrix
uniform mat3 normalMatrix; // Normal matrix
uniform mat4 shadowMapLight0ProjectionMatrix; // Shadow map projection matrix for light 0
uniform mat4 shadowMapLight1ProjectionMatrix; // Shadow map projection matrix for light 1
uniform mat4 shadowMapLight2ProjectionMatrix; // Shadow map projection matrix for light 2
// In variables
in vec4 vertexPosition;
@ -46,7 +44,7 @@ in vec2 textureCoords;
out vec3 vertexPosCameraSpace; // Camera-space position of the vertex
out vec3 vertexNormalCameraSpace; // Vertex normal in camera-space
out vec2 texCoords; // Texture coordinates
out vec4 shadowMapCoords[3]; // Shadow map texture coords
out vec4 shadowMapCoords[2]; // Shadow map texture coords
void main() {
@ -61,17 +59,15 @@ void main() {
texCoords = textureCoords;
// Compute the texture coords of the vertex in the shadow map
mat4 worldToLightCameraMatrix[3];
worldToLightCameraMatrix[0] = worldToLight0CameraMatrix;
worldToLightCameraMatrix[1] = worldToLight1CameraMatrix;
worldToLightCameraMatrix[2] = worldToLight2CameraMatrix;
mat4 shadowMapProjectionMatrix[3];
shadowMapProjectionMatrix[0] = shadowMapLight0ProjectionMatrix;
shadowMapProjectionMatrix[1] = shadowMapLight1ProjectionMatrix;
shadowMapProjectionMatrix[2] = shadowMapLight2ProjectionMatrix;
for (int l=0; l < 3; l++) {
shadowMapCoords[l] = shadowMapProjectionMatrix[l] * worldToLightCameraMatrix[l] * localToWorldMatrix * vertexPosition;
}
mat4 worldToLightCameraMatrix[2];
worldToLightCameraMatrix[0] = worldToLight0CameraMatrix;
worldToLightCameraMatrix[1] = worldToLight1CameraMatrix;
mat4 shadowMapProjectionMatrix[2];
shadowMapProjectionMatrix[0] = shadowMapLight0ProjectionMatrix;
shadowMapProjectionMatrix[1] = shadowMapLight1ProjectionMatrix;
for (int l=0; l < 2; l++) {
shadowMapCoords[l] = shadowMapProjectionMatrix[l] * worldToLightCameraMatrix[l] * localToWorldMatrix * vertexPosition;
}
// Compute the clip-space vertex coordinates
gl_Position = projectionMatrix * positionCameraSpace;

View File

@ -533,7 +533,7 @@ void Gui::createSettingsPanel() {
void Gui::createProfilingPanel() {
Widget* profilingPanel = new Window(mScreen, "Profiling");
profilingPanel->set_position(Vector2i(15, 525));
profilingPanel->set_position(Vector2i(15, 505));
profilingPanel->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 5));
//profilingPanel->setId("SettingsPanel");
profilingPanel->set_fixed_width(220);
@ -568,7 +568,7 @@ bool Gui::onScrollEvent(double x, double y) {
// If the mouse cursor is over the scenes choice scrolling menu
const float pixelRatio = mScreen->pixel_ratio();
if (mComboBoxScenes->visible() && mComboBoxScenes->popup()->contains(Vector2i(xMouse, yMouse) / pixelRatio)) {
if (mComboBoxScenes->popup()->visible() && mComboBoxScenes->popup()->contains(Vector2i(xMouse, yMouse) / pixelRatio)) {
mScreen->scroll_callback_event(x, y);
return true;
}

View File

@ -37,7 +37,8 @@ Scene::Scene(const std::string& name, EngineSettings& engineSettings, bool isSha
mCurrentCameraVerticalAngle(0.0), mViewportX(0), mViewportY(0),
mViewportWidth(0), mViewportHeight(0), mIsShadowMappingEnabled(isShadowMappingEnabled),
mAreContactPointsDisplayed(true), mAreContactNormalsDisplayed(false), mAreBroadPhaseAABBsDisplayed(false),
mAreCollidersAABBsDisplayed(false), mAreCollisionShapesDisplayed(false), mIsWireframeEnabled(false) {
mAreCollidersAABBsDisplayed(false), mAreCollisionShapesDisplayed(false), mIsWireframeEnabled(false),
mInitZoom(2.0f) {
}
@ -63,12 +64,12 @@ void Scene::resetCameraToViewAll() {
// Move the camera to the origin of the scene
mCamera.translateWorld(-mCamera.getOrigin());
// Move the camera to the center of the scene
// Move the camera
mCamera.translateWorld(mCenterScene);
// Set the zoom of the camera so that the scene center is
// in negative view direction of the camera
mCamera.setZoom(1.0);
mCamera.setZoom(mInitZoom);
}
// Map the mouse x,y coordinates to a point on a sphere
@ -182,6 +183,4 @@ void Scene::rotate(int xMouse, int yMouse) {
mCamera.rotateAroundLocalPoint(localVertAxis, deltaHorizRotationAngle, mCenterScene);
mCurrentCameraVerticalAngle += deltaVertRotationAngle;
std::cout << "Delta angle: " << deltaVertRotationAngle << std::endl;
std::cout << "Horizon angle: " << mCurrentCameraVerticalAngle << std::endl;
}

View File

@ -155,6 +155,9 @@ class Scene : public rp3d::EventListener {
/// Snapshots Contact points (computed with PhysicsWorld::testCollision() or PhysicsWorld::raycast() methods)
std::vector<SceneContactPoint> mSnapshotsContactPoints;
/// Initial zoom factor
float mInitZoom;
// -------------------- Methods -------------------- //
/// Set the scene position (where the camera needs to look at)
@ -221,6 +224,12 @@ class Scene : public rp3d::EventListener {
/// Set the viewport to render the scene
void setViewport(int x, int y, int width, int height);
/// Return the initial zoom factor
float getInitZoom() const;
/// Set the initial zoom factor
void setInitZoom(float zoom);
/// Return a reference to the camera
const openglframework::Camera& getCamera() const;
@ -302,6 +311,16 @@ inline void Scene::setViewport(int x, int y, int width, int height) {
mViewportHeight = height;
}
// Return the initial zoom factor
inline float Scene::getInitZoom() const {
return mInitZoom;
}
// Set the initial zoom factor
inline void Scene::setInitZoom(float zoom) {
mInitZoom = zoom;
}
// Set the interpolation factor
inline void Scene::setInterpolationFactor(float interpolationFactor) {
mInterpolationFactor = interpolationFactor;

View File

@ -34,51 +34,51 @@ using namespace openglframework;
int SceneDemo::shadowMapTextureLevel = 0;
//openglframework::Color SceneDemo::mObjectColorDemo = Color(0.76f, 0.67f, 0.47f, 1.0f);
openglframework::Color SceneDemo::mObjectColorDemo = Color(0.35f, 0.65f, 0.78f, 1.0f);
openglframework::Color SceneDemo::mObjectColorDemo = Color(0.21f, 0.65f, 1.0f, 1.0f);
openglframework::Color SceneDemo::mFloorColorDemo = Color(0.47f, 0.48f, 0.49f, 1.0f);
openglframework::Color SceneDemo::mSleepingColorDemo = Color(1.0f, 0.25f, 0.25f, 1.0f);
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.59f, 0.88f, 1.0f);
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.88f, 0.09f, 1.0f);
// Constructor
SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon, bool isPhysicsWorldSimulated, bool isShadowMappingEnabled)
: Scene(name, settings, isShadowMappingEnabled), mIsShadowMappingInitialized(false),
: Scene(name, settings, isShadowMappingEnabled), mBackgroundColor(0.15, 0.15, 0.15, 1),
mIsShadowMappingInitialized(false),
mDepthShader("shaders/depth.vert", "shaders/depth.frag"),
mPhongShader("shaders/phong.vert", "shaders/phong.frag"),
mColorShader("shaders/color.vert", "shaders/color.frag"),
mQuadShader("shaders/quad.vert", "shaders/quad.frag"),
mVBOQuad(GL_ARRAY_BUFFER), mDebugVBOLinesVertices(GL_ARRAY_BUFFER), mDebugVBOTrianglesVertices(GL_ARRAY_BUFFER),
mMeshFolderPath("meshes/"), mPhysicsCommon(physicsCommon), mPhysicsWorld(nullptr), mIsPhysicsWorldSimulated(isPhysicsWorldSimulated),
mIsMovingBody(false), mMovingBody(nullptr) {
mIsMovingBody(false), mMovingBody(nullptr) {
shadowMapTextureLevel++;
// Move the lights
float lightsRadius = 30.0f;
float lightsHeight = 20.0f;
mLight0.translateWorld(Vector3(0 * lightsRadius, lightsHeight, 1 * lightsRadius));
mLight1.translateWorld(Vector3(0.95f * lightsRadius, lightsHeight, -0.3f * lightsRadius));
mLight2.translateWorld(Vector3(-0.58f * lightsRadius, lightsHeight, -0.81f * lightsRadius));
float lightsRadius = 40.0f;
float lightsHeight = 50.0f;
mLight0.translateWorld(Vector3(0.4f * lightsRadius, 0.6 * lightsHeight, 0.4f * lightsRadius));
mLight1.translateWorld(Vector3(-0.4 * lightsRadius, 0.6 * lightsHeight, 0.4 * lightsRadius));
mLight2.translateWorld(Vector3(-0.40f * lightsRadius, -lightsHeight, -0.4f * lightsRadius));
// Set the lights colors
mLight0.setDiffuseColor(Color(0.6f, 0.6f, 0.6f, 1.0f));
mLight1.setDiffuseColor(Color(0.6f, 0.6f, 0.6f, 1.0f));
mLight2.setDiffuseColor(Color(0.6f, 0.6f, 0.6f, 1.0f));
float lightIntensity = 0.6f;
Color lightColor(lightIntensity * 1.0, lightIntensity * 1.0f, lightIntensity * 1.0f, 1.0f);
mLight0.setDiffuseColor(lightColor);
mLight1.setDiffuseColor(lightColor);
mLight2.setDiffuseColor(lightColor);
mShadowMapLightCameras[0].translateWorld(mLight0.getOrigin());
mShadowMapLightCameras[0].rotateLocal(Vector3(1, 0, 0), -PI / 4.0f);
mShadowMapLightCameras[0].translateWorld(mLight0.getOrigin());
mShadowMapLightCameras[0].rotateLocal(Vector3(1, 0, 0), -PI / 4.0f);
mShadowMapLightCameras[0].rotateLocal(Vector3(0, 1, 0), PI / 4.0f);
mShadowMapLightCameras[1].translateWorld(mLight1.getOrigin());
mShadowMapLightCameras[1].rotateLocal(Vector3(0, 1, 0), -5.0f * PI/3.7f);
mShadowMapLightCameras[1].rotateLocal(Vector3(1, 0, 0), -PI/4.0f);
mShadowMapLightCameras[2].translateWorld(mLight2.getOrigin());
mShadowMapLightCameras[2].rotateLocal(Vector3(0, 1, 0), 5 * PI/4.0f);
mShadowMapLightCameras[2].rotateLocal(Vector3(1, 0 , 0), -PI/4.0f);
mShadowMapLightCameras[1].rotateLocal(Vector3(0, 1, 0), -PI / 4.0f);
for (int i = 0; i < NB_SHADOW_MAPS; i++) {
mShadowMapLightCameras[i].setDimensions(SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT);
mShadowMapLightCameras[i].setFieldOfView(100.0f);
mShadowMapLightCameras[i].setSceneRadius(100);
mShadowMapLightCameras[i].setSceneRadius(100);
}
mShadowMapBiasMatrix.setAllValues(0.5, 0.0, 0.0, 0.5,
@ -168,6 +168,8 @@ void SceneDemo::render() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glClearColor(mBackgroundColor.r, mBackgroundColor.g, mBackgroundColor.b, mBackgroundColor.a);
Matrix4 shadowMapProjMatrix[NB_SHADOW_MAPS];
openglframework::Matrix4 worldToLightCameraMatrix[NB_SHADOW_MAPS];
for (int i = 0; i < NB_SHADOW_MAPS; i++) {
@ -241,20 +243,17 @@ void SceneDemo::render() {
mPhongShader.setMatrix4x4Uniform("projectionMatrix", mCamera.getProjectionMatrix());
mPhongShader.setMatrix4x4Uniform("shadowMapLight0ProjectionMatrix", mShadowMapBiasMatrix * shadowMapProjMatrix[0]);
mPhongShader.setMatrix4x4Uniform("shadowMapLight1ProjectionMatrix", mShadowMapBiasMatrix * shadowMapProjMatrix[1]);
mPhongShader.setMatrix4x4Uniform("shadowMapLight2ProjectionMatrix", mShadowMapBiasMatrix * shadowMapProjMatrix[2]);
mPhongShader.setMatrix4x4Uniform("worldToLight0CameraMatrix", worldToLightCameraMatrix[0]);
mPhongShader.setMatrix4x4Uniform("worldToLight1CameraMatrix", worldToLightCameraMatrix[1]);
mPhongShader.setMatrix4x4Uniform("worldToLight2CameraMatrix", worldToLightCameraMatrix[2]);
mPhongShader.setVector3Uniform("light0PosCameraSpace", worldToCameraMatrix * mLight0.getOrigin());
mPhongShader.setVector3Uniform("light1PosCameraSpace", worldToCameraMatrix * mLight1.getOrigin());
mPhongShader.setVector3Uniform("light2PosCameraSpace", worldToCameraMatrix * mLight2.getOrigin());
mPhongShader.setVector3Uniform("lightAmbientColor", Vector3(0.3f, 0.3f, 0.3f));
mPhongShader.setVector3Uniform("lightAmbientColor", Vector3(0.2f, 0.2f, 0.2f));
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("light2DiffuseColor", Vector3(mLight2.getDiffuseColor().r, mLight2.getDiffuseColor().g, mLight2.getDiffuseColor().b));
mPhongShader.setIntUniform("shadowMapSampler0", textureUnits[0]);
mPhongShader.setIntUniform("shadowMapSampler1", textureUnits[1]);
mPhongShader.setIntUniform("shadowMapSampler2", textureUnits[2]);
mPhongShader.setIntUniform("isShadowEnabled", mIsShadowMappingEnabled);
mPhongShader.setVector2Uniform("shadowMapDimension", Vector2(SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT));
mPhongShader.unbind();

View File

@ -47,10 +47,13 @@ class SceneDemo : public Scene, rp3d::RaycastCallback {
// -------------------- Constants -------------------- //
static constexpr int NB_SHADOW_MAPS = 3;
static constexpr int NB_SHADOW_MAPS = 2;
// -------------------- Attributes -------------------- //
/// Background color
openglframework::Color mBackgroundColor;
/// Light 0
openglframework::Light mLight0;

View File

@ -300,12 +300,6 @@ void TestbedApplication::createScenes() {
RaycastScene* raycastScene = new RaycastScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(raycastScene);
// Collision Detection scene
sceneName = "Collision Detection";
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
CollisionDetectionScene* collisionDetectionScene = new CollisionDetectionScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(collisionDetectionScene);
// Concave Mesh scene
sceneName = "Concave Mesh";
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
@ -331,13 +325,13 @@ void TestbedApplication::createScenes() {
mScenes.push_back(boxTowerScene);
// Ball and Socket joints Net scene
sceneName = "BallAndSocket Joints Net";
sceneName = "BallSocket Joints Net";
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
BallAndSocketJointsNetScene* ballAndSocketJointsNetScene = new BallAndSocketJointsNetScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(ballAndSocketJointsNetScene);
// Ball and Socket joints chain scene
sceneName = "BallAndSoket Joints Chain";
sceneName = "BallSocket Joints Chain";
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
BallAndSocketJointsChainScene* ballAndSocketJointsChainScene = new BallAndSocketJointsChainScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(ballAndSocketJointsChainScene);
@ -384,6 +378,12 @@ void TestbedApplication::createScenes() {
RopeScene* ropeScene = new RopeScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(ropeScene);
// Collision Detection scene
sceneName = "Collision Detection";
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
CollisionDetectionScene* collisionDetectionScene = new CollisionDetectionScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
mScenes.push_back(collisionDetectionScene);
assert(mScenes.size() > 0);
}

View File

@ -84,7 +84,7 @@ DefaultLogger::Formatter* TestbedLogger::getFormatter(DefaultLogger::Format form
}
// Add a log file destination to the logger
void TestbedLogger::addFileDestination(const std::string& worldName, uint logLevelFlag, reactphysics3d::DefaultLogger::Format format) {
void TestbedLogger::addFileDestination(const std::string& worldName, reactphysics3d::uint logLevelFlag, reactphysics3d::DefaultLogger::Format format) {
std::string filePath = "rp3d_log_" + worldName + ".html";
reactphysics3d::DefaultLogger::FileDestination* destination = new reactphysics3d::DefaultLogger::FileDestination(filePath, logLevelFlag, getFormatter(format));
@ -92,7 +92,7 @@ void TestbedLogger::addFileDestination(const std::string& worldName, uint logLev
}
// Add a stream destination to the logger
void TestbedLogger::addStreamDestination(std::ostream& outputStream, uint logLevelFlag, reactphysics3d::DefaultLogger::Format format) {
void TestbedLogger::addStreamDestination(std::ostream& outputStream, reactphysics3d::uint logLevelFlag, reactphysics3d::DefaultLogger::Format format) {
mStandardOutputDestination = new reactphysics3d::DefaultLogger::StreamDestination(outputStream, logLevelFlag, getFormatter(format));
}