Create a custom logger for the testbed application and edit demo scenes for this
This commit is contained in:
parent
975eb1c11f
commit
30ca167bf9
|
@ -91,6 +91,8 @@ set(TESTBED_SOURCES
|
||||||
src/SceneDemo.h
|
src/SceneDemo.h
|
||||||
src/SceneDemo.cpp
|
src/SceneDemo.cpp
|
||||||
src/Timer.h
|
src/Timer.h
|
||||||
|
src/TestbedLogger.h
|
||||||
|
src/TestbedLogger.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Common source files
|
# Common source files
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace ballandsocketjointscene;
|
using namespace ballandsocketjointscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BallAndSocketJointScene::BallAndSocketJointScene(const std::string& name, EngineSettings& settings)
|
BallAndSocketJointScene::BallAndSocketJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -42,13 +42,6 @@ BallAndSocketJointScene::BallAndSocketJointScene(const std::string& name, Engine
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BallAndSocketJointScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BallAndSocketJointScene(const std::string& name, EngineSettings& settings);
|
BallAndSocketJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BallAndSocketJointScene() override ;
|
virtual ~BallAndSocketJointScene() override ;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace ballandsocketjointschainscene;
|
using namespace ballandsocketjointschainscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BallAndSocketJointsChainScene::BallAndSocketJointsChainScene(const std::string& name, EngineSettings& settings)
|
BallAndSocketJointsChainScene::BallAndSocketJointsChainScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -44,13 +44,6 @@ BallAndSocketJointsChainScene::BallAndSocketJointsChainScene(const std::string&
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -65,7 +65,7 @@ class BallAndSocketJointsChainScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BallAndSocketJointsChainScene(const std::string& name, EngineSettings& settings);
|
BallAndSocketJointsChainScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BallAndSocketJointsChainScene() override ;
|
virtual ~BallAndSocketJointsChainScene() override ;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace ballandsocketjointsnetscene;
|
using namespace ballandsocketjointsnetscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BallAndSocketJointsNetScene::BallAndSocketJointsNetScene(const std::string& name, EngineSettings& settings)
|
BallAndSocketJointsNetScene::BallAndSocketJointsNetScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -49,13 +49,6 @@ BallAndSocketJointsNetScene::BallAndSocketJointsNetScene(const std::string& name
|
||||||
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
||||||
worldSettings.worldName = name;
|
worldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
|
|
||||||
// Create the physics world for the physics simulation
|
// Create the physics world for the physics simulation
|
||||||
rp3d::PhysicsWorld* physicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
rp3d::PhysicsWorld* physicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
||||||
physicsWorld->setEventListener(this);
|
physicsWorld->setEventListener(this);
|
||||||
|
|
|
@ -65,7 +65,7 @@ class BallAndSocketJointsNetScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BallAndSocketJointsNetScene(const std::string& name, EngineSettings& settings);
|
BallAndSocketJointsNetScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BallAndSocketJointsNetScene() override ;
|
virtual ~BallAndSocketJointsNetScene() override ;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace boxtowerscene;
|
using namespace boxtowerscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BoxTowerScene::BoxTowerScene(const std::string& name, EngineSettings& settings)
|
BoxTowerScene::BoxTowerScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -46,13 +46,6 @@ BoxTowerScene::BoxTowerScene(const std::string& name, EngineSettings& settings)
|
||||||
rp3d::Vector3 gravity(0, -9.81f, 0);
|
rp3d::Vector3 gravity(0, -9.81f, 0);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -77,7 +77,7 @@ class BoxTowerScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BoxTowerScene(const std::string& name, EngineSettings& settings);
|
BoxTowerScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon &physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BoxTowerScene() override;
|
virtual ~BoxTowerScene() override;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace bridgescene;
|
using namespace bridgescene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BridgeScene::BridgeScene(const std::string& name, EngineSettings& settings)
|
BridgeScene::BridgeScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -44,13 +44,6 @@ BridgeScene::BridgeScene(const std::string& name, EngineSettings& settings)
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -72,7 +72,7 @@ class BridgeScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
BridgeScene(const std::string& name, EngineSettings& settings);
|
BridgeScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~BridgeScene() override ;
|
virtual ~BridgeScene() override ;
|
||||||
|
|
|
@ -33,8 +33,8 @@ using namespace openglframework;
|
||||||
using namespace collisiondetectionscene;
|
using namespace collisiondetectionscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CollisionDetectionScene::CollisionDetectionScene(const std::string& name, EngineSettings& settings)
|
CollisionDetectionScene::CollisionDetectionScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
|
: SceneDemo(name, settings, physicsCommon, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
|
||||||
mContactManager(mPhongShader, mMeshFolderPath, mSnapshotsContactPoints),
|
mContactManager(mPhongShader, mMeshFolderPath, mSnapshotsContactPoints),
|
||||||
mAreNormalsDisplayed(false) {
|
mAreNormalsDisplayed(false) {
|
||||||
|
|
||||||
|
@ -52,13 +52,6 @@ CollisionDetectionScene::CollisionDetectionScene(const std::string& name, Engine
|
||||||
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
||||||
worldSettings.worldName = name;
|
worldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
|
|
||||||
// Create the physics world for the physics simulation
|
// Create the physics world for the physics simulation
|
||||||
mPhysicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
mPhysicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class CollisionDetectionScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CollisionDetectionScene(const std::string& name, EngineSettings& settings);
|
CollisionDetectionScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CollisionDetectionScene() override;
|
virtual ~CollisionDetectionScene() override;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace collisionshapesscene;
|
using namespace collisionshapesscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettings& settings)
|
CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name, EngineSettin
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -89,7 +89,7 @@ class CollisionShapesScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CollisionShapesScene(const std::string& name, EngineSettings& settings);
|
CollisionShapesScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CollisionShapesScene() override;
|
virtual ~CollisionShapesScene() override;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace trianglemeshscene;
|
using namespace trianglemeshscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& settings)
|
ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ ConcaveMeshScene::ConcaveMeshScene(const std::string& name, EngineSettings& sett
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -87,7 +87,7 @@ class ConcaveMeshScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ConcaveMeshScene(const std::string& name, EngineSettings& settings);
|
ConcaveMeshScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~ConcaveMeshScene() override;
|
virtual ~ConcaveMeshScene() override;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace cubesscene;
|
using namespace cubesscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CubesScene::CubesScene(const std::string& name, EngineSettings& settings)
|
CubesScene::CubesScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
iter = 0;
|
iter = 0;
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ CubesScene::CubesScene(const std::string& name, EngineSettings& settings)
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CubesScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CubesScene(const std::string& name, EngineSettings& settings);
|
CubesScene(const std::string& name, EngineSettings& settings, rp3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CubesScene() override;
|
virtual ~CubesScene() override;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace cubestackscene;
|
using namespace cubestackscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings)
|
CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -41,13 +41,6 @@ CubeStackScene::CubeStackScene(const std::string& name, EngineSettings& settings
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the physics world
|
// Create the physics world
|
||||||
|
|
|
@ -61,7 +61,7 @@ class CubeStackScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CubeStackScene(const std::string& name, EngineSettings& settings);
|
CubeStackScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~CubeStackScene() override;
|
virtual ~CubeStackScene() override;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace fixedjointscene;
|
using namespace fixedjointscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FixedJointScene::FixedJointScene(const std::string& name, EngineSettings& settings)
|
FixedJointScene::FixedJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -42,13 +42,6 @@ FixedJointScene::FixedJointScene(const std::string& name, EngineSettings& settin
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -70,7 +70,7 @@ class FixedJointScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
FixedJointScene(const std::string& name, EngineSettings& settings);
|
FixedJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FixedJointScene() override ;
|
virtual ~FixedJointScene() override ;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace heightfieldscene;
|
using namespace heightfieldscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& settings)
|
HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
mWorldSettings.gravity = rp3d::Vector3(settings.gravity.x, settings.gravity.y, settings.gravity.z);
|
mWorldSettings.gravity = rp3d::Vector3(settings.gravity.x, settings.gravity.y, settings.gravity.z);
|
||||||
|
|
||||||
|
@ -45,13 +45,6 @@ HeightFieldScene::HeightFieldScene(const std::string& name, EngineSettings& sett
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -88,7 +88,7 @@ class HeightFieldScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
HeightFieldScene(const std::string& name, EngineSettings& settings);
|
HeightFieldScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~HeightFieldScene() override;
|
virtual ~HeightFieldScene() override;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace hingejointscene;
|
using namespace hingejointscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HingeJointScene::HingeJointScene(const std::string& name, EngineSettings& settings)
|
HingeJointScene::HingeJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -42,13 +42,6 @@ HingeJointScene::HingeJointScene(const std::string& name, EngineSettings& settin
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -70,7 +70,7 @@ class HingeJointScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
HingeJointScene(const std::string& name, EngineSettings& settings);
|
HingeJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~HingeJointScene() override ;
|
virtual ~HingeJointScene() override ;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace hingejointschainscene;
|
using namespace hingejointschainscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HingeJointsChainScene::HingeJointsChainScene(const std::string& name, EngineSettings& settings)
|
HingeJointsChainScene::HingeJointsChainScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -47,13 +47,6 @@ HingeJointsChainScene::HingeJointsChainScene(const std::string& name, EngineSett
|
||||||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -65,7 +65,7 @@ class HingeJointsChainScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
HingeJointsChainScene(const std::string& name, EngineSettings& settings);
|
HingeJointsChainScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~HingeJointsChainScene() override ;
|
virtual ~HingeJointsChainScene() override ;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace jointsscene;
|
using namespace jointsscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
JointsScene::JointsScene(const std::string& name, EngineSettings& settings)
|
JointsScene::JointsScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -45,13 +45,6 @@ JointsScene::JointsScene(const std::string& name, EngineSettings& settings)
|
||||||
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
rp3d::Vector3 gravity(0, rp3d::decimal(-9.81), 0);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -115,7 +115,7 @@ class JointsScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
JointsScene(const std::string& name, EngineSettings& settings);
|
JointsScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~JointsScene() override ;
|
virtual ~JointsScene() override ;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace pilescene;
|
using namespace pilescene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
PileScene::PileScene(const std::string& name, EngineSettings& settings)
|
PileScene::PileScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ PileScene::PileScene(const std::string& name, EngineSettings& settings)
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -89,7 +89,7 @@ class PileScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
PileScene(const std::string& name, EngineSettings& settings);
|
PileScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~PileScene() override;
|
virtual ~PileScene() override;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace ragdollscene;
|
using namespace ragdollscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
RagdollScene::RagdollScene(const std::string& name, EngineSettings& settings)
|
RagdollScene::RagdollScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -42,13 +42,6 @@ RagdollScene::RagdollScene(const std::string& name, EngineSettings& settings)
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -145,7 +145,7 @@ class RagdollScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
RagdollScene(const std::string& name, EngineSettings& settings);
|
RagdollScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~RagdollScene() override ;
|
virtual ~RagdollScene() override ;
|
||||||
|
|
|
@ -31,8 +31,8 @@ using namespace openglframework;
|
||||||
using namespace raycastscene;
|
using namespace raycastscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings)
|
RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
|
: SceneDemo(name, settings, physicsCommon, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
|
||||||
mRaycastManager(mMeshFolderPath, mSnapshotsContactPoints), mCurrentBodyIndex(-1),
|
mRaycastManager(mMeshFolderPath, mSnapshotsContactPoints), mCurrentBodyIndex(-1),
|
||||||
mAreNormalsDisplayed(false), mVBOVertices(GL_ARRAY_BUFFER) {
|
mAreNormalsDisplayed(false), mVBOVertices(GL_ARRAY_BUFFER) {
|
||||||
|
|
||||||
|
@ -45,13 +45,6 @@ RaycastScene::RaycastScene(const std::string& name, EngineSettings& settings)
|
||||||
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
rp3d::PhysicsWorld::WorldSettings worldSettings;
|
||||||
worldSettings.worldName = name;
|
worldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
|
|
||||||
// Create the physics world for the physics simulation
|
// Create the physics world for the physics simulation
|
||||||
mPhysicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
mPhysicsWorld = mPhysicsCommon.createPhysicsWorld(worldSettings);
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ class RaycastScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
RaycastScene(const std::string& name, EngineSettings& settings);
|
RaycastScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~RaycastScene() override;
|
virtual ~RaycastScene() override;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace ropescene;
|
using namespace ropescene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
RopeScene::RopeScene(const std::string& name, EngineSettings& settings)
|
RopeScene::RopeScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS), nbIterations(0), nbTorqueIterations(200) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS), nbIterations(0), nbTorqueIterations(200) {
|
||||||
|
|
||||||
std::string meshFolderPath("meshes/");
|
std::string meshFolderPath("meshes/");
|
||||||
|
|
||||||
|
@ -46,13 +46,6 @@ RopeScene::RopeScene(const std::string& name, EngineSettings& settings)
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -81,7 +81,7 @@ class RopeScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
RopeScene(const std::string& name, EngineSettings& settings);
|
RopeScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~RopeScene() override ;
|
virtual ~RopeScene() override ;
|
||||||
|
|
|
@ -32,8 +32,8 @@ using namespace openglframework;
|
||||||
using namespace sliderjointscene;
|
using namespace sliderjointscene;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SliderJointScene::SliderJointScene(const std::string& name, EngineSettings& settings)
|
SliderJointScene::SliderJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon)
|
||||||
: SceneDemo(name, settings, true, SCENE_RADIUS) {
|
: SceneDemo(name, settings, physicsCommon, true, SCENE_RADIUS) {
|
||||||
|
|
||||||
// Compute the radius and the center of the scene
|
// Compute the radius and the center of the scene
|
||||||
openglframework::Vector3 center(0, 5, 0);
|
openglframework::Vector3 center(0, 5, 0);
|
||||||
|
@ -42,13 +42,6 @@ SliderJointScene::SliderJointScene(const std::string& name, EngineSettings& sett
|
||||||
setScenePosition(center, SCENE_RADIUS);
|
setScenePosition(center, SCENE_RADIUS);
|
||||||
|
|
||||||
mWorldSettings.worldName = name;
|
mWorldSettings.worldName = name;
|
||||||
|
|
||||||
// Logger
|
|
||||||
rp3d::DefaultLogger* defaultLogger = mPhysicsCommon.createDefaultLogger();
|
|
||||||
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information) | static_cast<uint>(rp3d::Logger::Level::Warning) |
|
|
||||||
static_cast<uint>(rp3d::Logger::Level::Error);
|
|
||||||
defaultLogger->addFileDestination("rp3d_log_" + name + ".html", logLevel, rp3d::DefaultLogger::Format::HTML);
|
|
||||||
mPhysicsCommon.setLogger(defaultLogger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -67,7 +67,7 @@ class SliderJointScene : public SceneDemo {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
SliderJointScene(const std::string& name, EngineSettings& settings);
|
SliderJointScene(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~SliderJointScene() override ;
|
virtual ~SliderJointScene() override ;
|
||||||
|
|
|
@ -40,14 +40,14 @@ openglframework::Color SceneDemo::mSleepingColorDemo = Color(1.0f, 0.25f, 0.25f,
|
||||||
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.59f, 0.88f, 1.0f);
|
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.59f, 0.88f, 1.0f);
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, bool isPhysicsWorldSimulated, float sceneRadius, bool isShadowMappingEnabled)
|
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), 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"),
|
||||||
mColorShader("shaders/color.vert", "shaders/color.frag"),
|
mColorShader("shaders/color.vert", "shaders/color.frag"),
|
||||||
mQuadShader("shaders/quad.vert", "shaders/quad.frag"),
|
mQuadShader("shaders/quad.vert", "shaders/quad.frag"),
|
||||||
mVBOQuad(GL_ARRAY_BUFFER), mDebugVBOLinesVertices(GL_ARRAY_BUFFER), mDebugVBOTrianglesVertices(GL_ARRAY_BUFFER),
|
mVBOQuad(GL_ARRAY_BUFFER), mDebugVBOLinesVertices(GL_ARRAY_BUFFER), mDebugVBOTrianglesVertices(GL_ARRAY_BUFFER),
|
||||||
mMeshFolderPath("meshes/"), mPhysicsWorld(nullptr), mIsPhysicsWorldSimulated(isPhysicsWorldSimulated),
|
mMeshFolderPath("meshes/"), mPhysicsCommon(physicsCommon), mPhysicsWorld(nullptr), mIsPhysicsWorldSimulated(isPhysicsWorldSimulated),
|
||||||
mIsMovingBody(false), mMovingBody(nullptr) {
|
mIsMovingBody(false), mMovingBody(nullptr) {
|
||||||
|
|
||||||
shadowMapTextureLevel++;
|
shadowMapTextureLevel++;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "VisualContactPoint.h"
|
#include "VisualContactPoint.h"
|
||||||
#include <reactphysics3d/reactphysics3d.h>
|
#include <reactphysics3d/reactphysics3d.h>
|
||||||
#include "PhysicsObject.h"
|
#include "PhysicsObject.h"
|
||||||
|
#include "TestbedLogger.h"
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const int SHADOWMAP_WIDTH = 2048;
|
const int SHADOWMAP_WIDTH = 2048;
|
||||||
|
@ -113,7 +114,7 @@ class SceneDemo : public Scene, rp3d::RaycastCallback {
|
||||||
|
|
||||||
std::string mMeshFolderPath;
|
std::string mMeshFolderPath;
|
||||||
|
|
||||||
rp3d::PhysicsCommon mPhysicsCommon;
|
rp3d::PhysicsCommon& mPhysicsCommon;
|
||||||
|
|
||||||
std::vector<PhysicsObject*> mPhysicsObjects;
|
std::vector<PhysicsObject*> mPhysicsObjects;
|
||||||
|
|
||||||
|
@ -168,7 +169,7 @@ class SceneDemo : public Scene, rp3d::RaycastCallback {
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
SceneDemo(const std::string& name, EngineSettings& settings, bool isPhysicsWorldSimulated, float sceneRadius, bool isShadowMappingEnabled = true);
|
SceneDemo(const std::string& name, EngineSettings& settings, rp3d::PhysicsCommon& physicsCommon, bool isPhysicsWorldSimulated, bool isShadowMappingEnabled = true);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~SceneDemo() override;
|
virtual ~SceneDemo() override;
|
||||||
|
|
|
@ -105,6 +105,9 @@ TestbedApplication::~TestbedApplication() {
|
||||||
// Initialize the viewer
|
// Initialize the viewer
|
||||||
void TestbedApplication::init() {
|
void TestbedApplication::init() {
|
||||||
|
|
||||||
|
// Logger
|
||||||
|
rp3d::PhysicsCommon::setLogger(&mLogger);
|
||||||
|
|
||||||
// Create all the scenes
|
// Create all the scenes
|
||||||
createScenes();
|
createScenes();
|
||||||
|
|
||||||
|
@ -137,85 +140,128 @@ void TestbedApplication::init() {
|
||||||
// Create all the scenes
|
// Create all the scenes
|
||||||
void TestbedApplication::createScenes() {
|
void TestbedApplication::createScenes() {
|
||||||
|
|
||||||
|
uint logLevel = static_cast<uint>(rp3d::Logger::Level::Information);
|
||||||
|
|
||||||
// Cubes scene
|
// Cubes scene
|
||||||
CubesScene* cubeScene = new CubesScene("Cubes", mDefaultEngineSettings);
|
std::string sceneName = "Cubes";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
CubesScene* cubeScene = new CubesScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(cubeScene);
|
mScenes.push_back(cubeScene);
|
||||||
|
|
||||||
// Cube Stack scene
|
// Cube Stack scene
|
||||||
CubeStackScene* cubeStackScene = new CubeStackScene("Cube Stack", mDefaultEngineSettings);
|
sceneName = "Cube Stack";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
CubeStackScene* cubeStackScene = new CubeStackScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(cubeStackScene);
|
mScenes.push_back(cubeStackScene);
|
||||||
|
|
||||||
// Joints scene
|
// Joints scene
|
||||||
JointsScene* jointsScene = new JointsScene("Joints", mDefaultEngineSettings);
|
sceneName = "Joints";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
JointsScene* jointsScene = new JointsScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(jointsScene);
|
mScenes.push_back(jointsScene);
|
||||||
|
|
||||||
// Collision shapes scene
|
// Collision shapes scene
|
||||||
CollisionShapesScene* collisionShapesScene = new CollisionShapesScene("Collision Shapes", mDefaultEngineSettings);
|
sceneName = "Collision Shapes";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
CollisionShapesScene* collisionShapesScene = new CollisionShapesScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(collisionShapesScene);
|
mScenes.push_back(collisionShapesScene);
|
||||||
|
|
||||||
// Heightfield shape scene
|
// Heightfield shape scene
|
||||||
HeightFieldScene* heightFieldScene = new HeightFieldScene("Heightfield", mDefaultEngineSettings);
|
sceneName = "Heightfield";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
HeightFieldScene* heightFieldScene = new HeightFieldScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(heightFieldScene);
|
mScenes.push_back(heightFieldScene);
|
||||||
|
|
||||||
// Raycast scene
|
// Raycast scene
|
||||||
RaycastScene* raycastScene = new RaycastScene("Raycast", mDefaultEngineSettings);
|
sceneName = "Raycast";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
RaycastScene* raycastScene = new RaycastScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(raycastScene);
|
mScenes.push_back(raycastScene);
|
||||||
|
|
||||||
// Collision Detection scene
|
// Collision Detection scene
|
||||||
CollisionDetectionScene* collisionDetectionScene = new CollisionDetectionScene("Collision Detection", mDefaultEngineSettings);
|
sceneName = "Collision Detection";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
CollisionDetectionScene* collisionDetectionScene = new CollisionDetectionScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(collisionDetectionScene);
|
mScenes.push_back(collisionDetectionScene);
|
||||||
|
|
||||||
// Concave Mesh scene
|
// Concave Mesh scene
|
||||||
ConcaveMeshScene* concaveMeshScene = new ConcaveMeshScene("Concave Mesh", mDefaultEngineSettings);
|
sceneName = "Concave Mesh";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
ConcaveMeshScene* concaveMeshScene = new ConcaveMeshScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(concaveMeshScene);
|
mScenes.push_back(concaveMeshScene);
|
||||||
|
|
||||||
// Pile scene
|
// Pile scene
|
||||||
PileScene* pileScene = new PileScene("Pile", mDefaultEngineSettings);
|
sceneName = "Pile";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
PileScene* pileScene = new PileScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(pileScene);
|
mScenes.push_back(pileScene);
|
||||||
|
|
||||||
// Ball and Socket joint scene
|
// Ball and Socket joint scene
|
||||||
BallAndSocketJointScene* ballAndSocketJointScene = new BallAndSocketJointScene("Ball and Socket joint", mDefaultEngineSettings);
|
sceneName = "Ball and Socket joint";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
BallAndSocketJointScene* ballAndSocketJointScene = new BallAndSocketJointScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(ballAndSocketJointScene);
|
mScenes.push_back(ballAndSocketJointScene);
|
||||||
|
|
||||||
// Box Tower scene
|
// Box Tower scene
|
||||||
BoxTowerScene* boxTowerScene = new BoxTowerScene("Box Tower", mDefaultEngineSettings);
|
sceneName = "Box Tower";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
BoxTowerScene* boxTowerScene = new BoxTowerScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(boxTowerScene);
|
mScenes.push_back(boxTowerScene);
|
||||||
|
|
||||||
// Ball and Socket joints Net scene
|
// Ball and Socket joints Net scene
|
||||||
BallAndSocketJointsNetScene* ballAndSocketJointsNetScene = new BallAndSocketJointsNetScene("BallAndSocket Joints Net", mDefaultEngineSettings);
|
sceneName = "BallAndSocket Joints Net";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
BallAndSocketJointsNetScene* ballAndSocketJointsNetScene = new BallAndSocketJointsNetScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(ballAndSocketJointsNetScene);
|
mScenes.push_back(ballAndSocketJointsNetScene);
|
||||||
|
|
||||||
// Ball and Socket joints chain scene
|
// Ball and Socket joints chain scene
|
||||||
BallAndSocketJointsChainScene* ballAndSocketJointsChainScene = new BallAndSocketJointsChainScene("BallAndSocket Joints Chain", mDefaultEngineSettings);
|
sceneName = "BallAndSoket Joints Chain";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
BallAndSocketJointsChainScene* ballAndSocketJointsChainScene = new BallAndSocketJointsChainScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(ballAndSocketJointsChainScene);
|
mScenes.push_back(ballAndSocketJointsChainScene);
|
||||||
|
|
||||||
// Hinge joints chain scene
|
// Hinge joints chain scene
|
||||||
HingeJointsChainScene* hingeJointsChainScene = new HingeJointsChainScene("Hinge Joints Chain", mDefaultEngineSettings);
|
sceneName = "Hinge Joints Chain";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
HingeJointsChainScene* hingeJointsChainScene = new HingeJointsChainScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(hingeJointsChainScene);
|
mScenes.push_back(hingeJointsChainScene);
|
||||||
|
|
||||||
// Bridge scene
|
// Bridge scene
|
||||||
BridgeScene* bridgeScene = new BridgeScene("Bridge", mDefaultEngineSettings);
|
sceneName = "Bridge";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
BridgeScene* bridgeScene = new BridgeScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(bridgeScene);
|
mScenes.push_back(bridgeScene);
|
||||||
|
|
||||||
// Fixed joint scene
|
// Fixed joint scene
|
||||||
FixedJointScene* fixedJointScene = new FixedJointScene("Fixed joint", mDefaultEngineSettings);
|
sceneName = "Fixed joint";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
FixedJointScene* fixedJointScene = new FixedJointScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(fixedJointScene);
|
mScenes.push_back(fixedJointScene);
|
||||||
|
|
||||||
// Hinge joint scene
|
// Hinge joint scene
|
||||||
HingeJointScene* hingeJointScene = new HingeJointScene("Hinge joint", mDefaultEngineSettings);
|
sceneName = "Hinge joint";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
HingeJointScene* hingeJointScene = new HingeJointScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(hingeJointScene);
|
mScenes.push_back(hingeJointScene);
|
||||||
|
|
||||||
// Slider joint scene
|
// Slider joint scene
|
||||||
SliderJointScene* sliderJointScene = new SliderJointScene("Slider joint", mDefaultEngineSettings);
|
sceneName = "Slider joint";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
SliderJointScene* sliderJointScene = new SliderJointScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(sliderJointScene);
|
mScenes.push_back(sliderJointScene);
|
||||||
|
|
||||||
// Ragdoll scene
|
// Ragdoll scene
|
||||||
RagdollScene* ragdollScene = new RagdollScene("Ragdoll", mDefaultEngineSettings);
|
sceneName = "Ragdoll";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
RagdollScene* ragdollScene = new RagdollScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(ragdollScene);
|
mScenes.push_back(ragdollScene);
|
||||||
|
|
||||||
// Rope scene
|
// Rope scene
|
||||||
RopeScene* ropeScene = new RopeScene("Rope", mDefaultEngineSettings);
|
sceneName = "Rope";
|
||||||
|
mLogger.addFileDestination(sceneName, logLevel, rp3d::DefaultLogger::Format::HTML);
|
||||||
|
RopeScene* ropeScene = new RopeScene(sceneName, mDefaultEngineSettings, mPhysicsCommon);
|
||||||
mScenes.push_back(ropeScene);
|
mScenes.push_back(ropeScene);
|
||||||
|
|
||||||
assert(mScenes.size() > 0);
|
assert(mScenes.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include "TestbedLogger.h"
|
||||||
|
|
||||||
using namespace nanogui;
|
using namespace nanogui;
|
||||||
|
|
||||||
|
@ -56,6 +57,9 @@ class TestbedApplication : public Screen {
|
||||||
/// Timer
|
/// Timer
|
||||||
Timer mTimer;
|
Timer mTimer;
|
||||||
|
|
||||||
|
/// Physics common object
|
||||||
|
rp3d::PhysicsCommon mPhysicsCommon;
|
||||||
|
|
||||||
/// List of 3D scenes
|
/// List of 3D scenes
|
||||||
std::vector<Scene*> mScenes;
|
std::vector<Scene*> mScenes;
|
||||||
|
|
||||||
|
@ -127,6 +131,9 @@ class TestbedApplication : public Screen {
|
||||||
/// True if the debug renderer is enabled
|
/// True if the debug renderer is enabled
|
||||||
bool mIsDebugRendererEnabled;
|
bool mIsDebugRendererEnabled;
|
||||||
|
|
||||||
|
/// Logger
|
||||||
|
TestbedLogger mLogger;
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
/// Private copy-constructor (for the singleton class)
|
/// Private copy-constructor (for the singleton class)
|
||||||
|
|
98
testbed/src/TestbedLogger.cpp
Normal file
98
testbed/src/TestbedLogger.cpp
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
|
||||||
|
* Copyright (c) 2010-2021 Daniel Chappuis *
|
||||||
|
*********************************************************************************
|
||||||
|
* *
|
||||||
|
* This software is provided 'as-is', without any express or implied warranty. *
|
||||||
|
* In no event will the authors be held liable for any damages arising from the *
|
||||||
|
* use of this software. *
|
||||||
|
* *
|
||||||
|
* Permission is granted to anyone to use this software for any purpose, *
|
||||||
|
* including commercial applications, and to alter it and redistribute it *
|
||||||
|
* freely, subject to the following restrictions: *
|
||||||
|
* *
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not claim *
|
||||||
|
* that you wrote the original software. If you use this software in a *
|
||||||
|
* product, an acknowledgment in the product documentation would be *
|
||||||
|
* appreciated but is not required. *
|
||||||
|
* *
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be *
|
||||||
|
* misrepresented as being the original software. *
|
||||||
|
* *
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include "TestbedLogger.h"
|
||||||
|
|
||||||
|
using namespace reactphysics3d;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
TestbedLogger::TestbedLogger() {
|
||||||
|
|
||||||
|
// Create the log formatters
|
||||||
|
mFormatters.insert({reactphysics3d::DefaultLogger::Format::Text, new reactphysics3d::DefaultLogger::TextFormatter()});
|
||||||
|
mFormatters.insert({reactphysics3d::DefaultLogger::Format::HTML, new reactphysics3d::DefaultLogger::HtmlFormatter()});
|
||||||
|
|
||||||
|
// Add destination to send warning and errors to standard output
|
||||||
|
uint warningsErrors = static_cast<uint>(reactphysics3d::Logger::Level::Warning);
|
||||||
|
addStreamDestination(std::cout, warningsErrors, reactphysics3d::DefaultLogger::Format::Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
TestbedLogger::~TestbedLogger() {
|
||||||
|
|
||||||
|
// Delete all the destinations
|
||||||
|
for (auto& item: mMapWorldToDestinations) {
|
||||||
|
delete item.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete mStandardOutputDestination;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log something
|
||||||
|
void TestbedLogger::log(Level level, const std::string& physicsWorldName, Category category, const std::string& message, const char* filename, int lineNumber) {
|
||||||
|
|
||||||
|
// Get current time
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
auto time = std::chrono::system_clock::to_time_t(now);
|
||||||
|
|
||||||
|
// Get the destination file for this world
|
||||||
|
DefaultLogger::Destination* destination = mMapWorldToDestinations[physicsWorldName];
|
||||||
|
|
||||||
|
mMutex.lock();
|
||||||
|
|
||||||
|
// Write the log file into the file of the corresponding scene
|
||||||
|
destination->write(time, physicsWorldName, message, level, category, filename, lineNumber);
|
||||||
|
|
||||||
|
// Write the log into the standard output
|
||||||
|
mStandardOutputDestination->write(time, physicsWorldName, message, level, category, filename, lineNumber);
|
||||||
|
|
||||||
|
mMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the corresponding format
|
||||||
|
DefaultLogger::Formatter* TestbedLogger::getFormatter(DefaultLogger::Format format) const {
|
||||||
|
|
||||||
|
auto it = mFormatters.find(format);
|
||||||
|
if (it != mFormatters.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a log file destination to the logger
|
||||||
|
void TestbedLogger::addFileDestination(const std::string& worldName, 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));
|
||||||
|
mMapWorldToDestinations.insert({worldName, destination});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a stream destination to the logger
|
||||||
|
void TestbedLogger::addStreamDestination(std::ostream& outputStream, uint logLevelFlag, reactphysics3d::DefaultLogger::Format format) {
|
||||||
|
|
||||||
|
mStandardOutputDestination = new reactphysics3d::DefaultLogger::StreamDestination(outputStream, logLevelFlag, getFormatter(format));
|
||||||
|
}
|
74
testbed/src/TestbedLogger.h
Normal file
74
testbed/src/TestbedLogger.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
|
||||||
|
* Copyright (c) 2010-2016 Daniel Chappuis *
|
||||||
|
*********************************************************************************
|
||||||
|
* *
|
||||||
|
* This software is provided 'as-is', without any express or implied warranty. *
|
||||||
|
* In no event will the authors be held liable for any damages arising from the *
|
||||||
|
* use of this software. *
|
||||||
|
* *
|
||||||
|
* Permission is granted to anyone to use this software for any purpose, *
|
||||||
|
* including commercial applications, and to alter it and redistribute it *
|
||||||
|
* freely, subject to the following restrictions: *
|
||||||
|
* *
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not claim *
|
||||||
|
* that you wrote the original software. If you use this software in a *
|
||||||
|
* product, an acknowledgment in the product documentation would be *
|
||||||
|
* appreciated but is not required. *
|
||||||
|
* *
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be *
|
||||||
|
* misrepresented as being the original software. *
|
||||||
|
* *
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TESTBED_LOGGER_H
|
||||||
|
#define TESTBED_LOGGER_H
|
||||||
|
|
||||||
|
// Libraries
|
||||||
|
#include <reactphysics3d/utils/DefaultLogger.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/// Class TestbedApplication
|
||||||
|
class TestbedLogger : public reactphysics3d::Logger {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/// Map a log format to the given formatter object
|
||||||
|
std::unordered_map<reactphysics3d::DefaultLogger::Format, reactphysics3d::DefaultLogger::Formatter*> mFormatters;
|
||||||
|
|
||||||
|
/// Map the name of a world with the corresponding log destination
|
||||||
|
std::unordered_map<std::string, reactphysics3d::DefaultLogger::Destination*> mMapWorldToDestinations;
|
||||||
|
|
||||||
|
reactphysics3d::DefaultLogger::StreamDestination* mStandardOutputDestination;
|
||||||
|
|
||||||
|
/// Mutex
|
||||||
|
std::mutex mMutex;
|
||||||
|
|
||||||
|
// -------------------- Methods -------------------- //
|
||||||
|
|
||||||
|
/// Return the corresponding formatter
|
||||||
|
reactphysics3d::DefaultLogger::Formatter* getFormatter(reactphysics3d::DefaultLogger::Format format) const;
|
||||||
|
|
||||||
|
/// Add a stream destination to the logger
|
||||||
|
void addStreamDestination(std::ostream& outputStream, uint logLevelFlag, reactphysics3d::DefaultLogger::Format format);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
TestbedLogger();
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~TestbedLogger();
|
||||||
|
|
||||||
|
/// Add a log file destination to the logger
|
||||||
|
void addFileDestination(const std::string& worldName, uint logLevelFlag, reactphysics3d::DefaultLogger::Format format);
|
||||||
|
|
||||||
|
|
||||||
|
/// Log something
|
||||||
|
virtual void log(Level level, const std::string& physicsWorldName, Category category, const std::string& message, const char* filename, int lineNumber) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user