diff --git a/ParticleGenerator/src/Interface/GlobalInterface.cpp b/ParticleGenerator/old/Global.cpp.old similarity index 77% rename from ParticleGenerator/src/Interface/GlobalInterface.cpp rename to ParticleGenerator/old/Global.cpp.old index cdc0bec48c5c9f14619c5b445741efd40ca45d9a..c18e4c4f63ff10cb97793d2db13e1796d43af13c 100644 --- a/ParticleGenerator/src/Interface/GlobalInterface.cpp +++ b/ParticleGenerator/old/Global.cpp.old @@ -1,4 +1,4 @@ -#include "GlobalInterface.hpp" +#include "Global.hpp" #include <imgui.h> #include <imgui_impl_glfw.h> @@ -6,22 +6,21 @@ #include "../Scene/Manager.hpp" -namespace pg { - GlobalInterface::GlobalInterface(Window & window, Manager & manager, const std::string & title) +namespace pg::interface { + Global::Global(Window & window, Manager & manager, const std::string & title) : _title(title), _manager(manager), _historical() { if(this->_title.empty()) { this->_title = window.title(); } ImGui::CreateContext(); - ImGui::GetStyle().WindowMenuButtonPosition = ImGuiDir_None; ImGui::GetIO().IniFilename = "config/imgui.ini"; ImGui_ImplGlfw_InitForOpenGL(window.address(), true); ImGui_ImplOpenGL3_Init("#version 330 core"); } - GlobalInterface::~GlobalInterface() { + Global::~Global() { ImGui::GetIO().IniFilename = ""; ImGui_ImplOpenGL3_Shutdown(); @@ -29,7 +28,7 @@ namespace pg { ImGui::DestroyContext(); } - void GlobalInterface::render(double current_time) { + void Global::render(double current_time) { ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); @@ -39,7 +38,7 @@ namespace pg { if(ImGui::Begin(this->_title.c_str())) { if(ImGui::BeginTabBar("")) { if(ImGui::BeginTabItem("Scene")) { - this->_manager.interface().render(current_time); + //this->_manager.interface().render(current_time); ImGui::EndTabItem(); } diff --git a/ParticleGenerator/src/Interface/GlobalInterface.hpp b/ParticleGenerator/old/Global.hpp.old similarity index 71% rename from ParticleGenerator/src/Interface/GlobalInterface.hpp rename to ParticleGenerator/old/Global.hpp.old index 9697237a84712df202a706a3a68690e885c8918a..3460f4216f387a690251ec885da3954b1e4a0554 100644 --- a/ParticleGenerator/src/Interface/GlobalInterface.hpp +++ b/ParticleGenerator/old/Global.hpp.old @@ -6,8 +6,8 @@ #include "../System/Window.hpp" #include "../System/FrameHistorical.hpp" -namespace pg { - class GlobalInterface : public Interface { +namespace pg::interface { + class Global : public Interface { private: std::string _title; @@ -15,8 +15,8 @@ namespace pg { FrameHistorical _historical; public: - GlobalInterface(Window &, Manager &, const std::string & = ""); - ~GlobalInterface(); + Global(Window &, Manager &, const std::string & = ""); + ~Global(); virtual void render(double); inline std::string title() const {return "Global Interface";} diff --git a/ParticleGenerator/src/Interface/SceneManagerInterface.cpp b/ParticleGenerator/old/SceneManager.cpp.old similarity index 69% rename from ParticleGenerator/src/Interface/SceneManagerInterface.cpp rename to ParticleGenerator/old/SceneManager.cpp.old index 5e8418fcf13881fdf3aa562f57e690a652be8ef3..b458f0fa0c7eaffa33c411ec3bd1a4862416a169 100644 --- a/ParticleGenerator/src/Interface/SceneManagerInterface.cpp +++ b/ParticleGenerator/old/SceneManager.cpp.old @@ -1,23 +1,21 @@ -#include "SceneManagerInterface.hpp" +#include "SceneManager.hpp" #include <imgui.h> #include "../Scene/Manager.hpp" -namespace pg { - SceneManagerInterface::SceneManagerInterface(Manager * manager) - : _manager(manager) { - - } +namespace pg::interface { + SceneManager::SceneManager(Manager * manager) + : _manager(manager) {} - void SceneManagerInterface::render(double current_time) { + void SceneManager::render(double current_time) { if(!this->_manager->scenes().empty()) { std::string name = this->_manager->current() == nullptr ? this->_manager->scenes().front()->name() : this->_manager->current()->name(); if(ImGui::BeginCombo("Current Scene", name.c_str())) { for(auto & scene : this->_manager->_scenes) { bool is_selected = (scene == this->_manager->current()); if(ImGui::Selectable(scene->name().c_str(), is_selected)) { - this->_manager->setScene(scene); + this->_manager->changeScene(*scene); } } ImGui::EndCombo(); @@ -25,7 +23,7 @@ namespace pg { ImGui::Separator(); } - Scene * current = this->_manager->current(); + scene::Scene * current = this->_manager->current(); if(current != nullptr && current->interface() != nullptr) { current->interface()->render(current_time); } diff --git a/ParticleGenerator/src/Interface/SceneManagerInterface.hpp b/ParticleGenerator/old/SceneManager.hpp.old similarity index 71% rename from ParticleGenerator/src/Interface/SceneManagerInterface.hpp rename to ParticleGenerator/old/SceneManager.hpp.old index 09728ae5c1e1e45b6830413cac57cb088ac0f88c..74afd686a1dbf488977438befd4958c4c13db107 100644 --- a/ParticleGenerator/src/Interface/SceneManagerInterface.hpp +++ b/ParticleGenerator/old/SceneManager.hpp.old @@ -4,12 +4,15 @@ namespace pg { class Manager; - class SceneManagerInterface : public Interface { +} + +namespace pg::interface { + class SceneManager : public Interface { private: Manager * _manager; public: - SceneManagerInterface(Manager *); + SceneManager(Manager *); virtual void render(double = 0.0); inline std::string title() const {return "Scene Manager Interface";} diff --git a/ParticleGenerator/res/config/imgui.ini b/ParticleGenerator/res/config/imgui.ini index 76a4970f61a8ee84a544ac265e6464b976230717..d59a5fdfcef08d8835f66e92dac664ae8fff0534 100644 --- a/ParticleGenerator/res/config/imgui.ini +++ b/ParticleGenerator/res/config/imgui.ini @@ -1,32 +1,8 @@ [Window][Debug##Default] -Pos=306,287 +Pos=60,60 Size=400,400 -[Window][Particle Debug Menu] +[Window][Particle Generator] Pos=60,60 -Size=128,100 - -[Window][Main window] -Pos=0,0 -Size=491,602 - -[Window][Settings] -Pos=20,23 -Size=431,416 - -[Window][Particles Configuration] -Pos=23,44 -Size=729,421 - -[Window][Particles Settings] -Pos=10,4 -Size=674,754 - -[Window][Particle Generator Settings] -Pos=20,44 -Size=523,732 - -[Window][Dear ImGui Demo] -Pos=650,20 -Size=550,680 +Size=504,424 diff --git a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp similarity index 94% rename from ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp rename to ParticleGenerator/src/Interface/Generator/PathGenerator.cpp index aa38e0ae1c1077d9873dc20acae74e0d43af6245..f8f5d81ddfaad5301095dc8ed078373b9c7fb9a4 100644 --- a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp +++ b/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp @@ -1,16 +1,16 @@ #pragma once -#include "PathGeneratorInterface.hpp" +#include "PathGenerator.hpp" #include <imgui.h> #include "../../Particle/generator/PathParticleGenerator.hpp" -namespace pg { - PathGeneratorInterface::PathGeneratorInterface(PathParticleGenerator * generator, Trajectory * trajectory) +namespace pg::interface { + PathGenerator::PathGenerator(PathParticleGenerator * generator, Trajectory * trajectory) : _generator(generator), _trajectory(trajectory), _next(0.f, 0.f, 0.f), _index(0) {} - void PathGeneratorInterface::render(double) { + void PathGenerator::render(double) { if(ImGui::CollapsingHeader("Generator Information")) { ImGui::Text("Physic generator at %f / %f / %f (x, y, z) - variation : %f.", this->_generator->m_position.x, this->_generator->m_position.y, this->_generator->m_position.z, this->_generator->m_positionVariation); ImGui::Separator(); diff --git a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.hpp b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp similarity index 78% rename from ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.hpp rename to ParticleGenerator/src/Interface/Generator/PathGenerator.hpp index 1ef335e3b43bb8dfe933db2bea95313deb72ffb9..e54ae83d70fe129ca68af1d1248f1d1b293d1b06 100644 --- a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.hpp +++ b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp @@ -7,7 +7,10 @@ namespace pg { class PathParticleGenerator; - class PathGeneratorInterface : public Interface { +} + +namespace pg::interface { + class PathGenerator : public Interface { private: PathParticleGenerator * _generator; Trajectory * _trajectory; @@ -15,7 +18,7 @@ namespace pg { int _index; public: - PathGeneratorInterface(PathParticleGenerator *, Trajectory * = nullptr); + PathGenerator(PathParticleGenerator *, Trajectory * = nullptr); inline PathParticleGenerator * getGenerator() const {return this->_generator;} diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp similarity index 95% rename from ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp rename to ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp index a5aade5044868a12a6436e80c714009acde288da..b1e18a8c38eff54d0632c4f5fc061bd1a5eaf0db 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp @@ -1,16 +1,16 @@ #pragma once -#include "PhysicGeneratorInterface.hpp" +#include "PhysicGenerator.hpp" #include <imgui.h> #include "../../Particle/generator/PhysicsParticleGenerator.hpp" -namespace pg { - PhysicGeneratorInterface::PhysicGeneratorInterface(PhysicsParticleGenerator * generator) +namespace pg::interface { + PhysicGenerator::PhysicGenerator(PhysicsParticleGenerator * generator) : _generator(generator) {} - void PhysicGeneratorInterface::render(double) { + void PhysicGenerator::render(double) { if(this->_generator == nullptr) { return; } diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp similarity index 79% rename from ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp rename to ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp index fc8f2ffea69456b27efc768094ae041d3fb04ec1..ff3c5c5b8ae6cedd098798d46c7130a4b4687689 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp @@ -4,12 +4,15 @@ namespace pg { class PhysicsParticleGenerator; - class PhysicGeneratorInterface : public Interface { +} + +namespace pg::interface { + class PhysicGenerator : public Interface { private: PhysicsParticleGenerator * _generator; public: - PhysicGeneratorInterface(PhysicsParticleGenerator *); + PhysicGenerator(PhysicsParticleGenerator *); inline PhysicsParticleGenerator * getGenerator() const {return this->_generator;} inline void setGenerator(PhysicsParticleGenerator * generator) {this->_generator = generator;} diff --git a/ParticleGenerator/src/Interface/Interface.hpp b/ParticleGenerator/src/Interface/Interface.hpp index 27645f4ad32e97678e38d79204ccf8a9f404007f..b5a11b2d6254ce0bb1882a2d6695ac2f4465e222 100644 --- a/ParticleGenerator/src/Interface/Interface.hpp +++ b/ParticleGenerator/src/Interface/Interface.hpp @@ -2,7 +2,7 @@ #include <string> -namespace pg { +namespace pg::interface { class Interface { public: virtual void render(double = 0.0) = 0; diff --git a/ParticleGenerator/src/Interface/Manager.cpp b/ParticleGenerator/src/Interface/Manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..57b2e8d809db74849d6b323ceb6a154f92d5b278 --- /dev/null +++ b/ParticleGenerator/src/Interface/Manager.cpp @@ -0,0 +1,57 @@ +#include "Manager.hpp" + +#include "../Scene/Manager.hpp" + +#include <imgui.h> +#include <imgui_impl_glfw.h> +#include <imgui_impl_opengl3.h> + +namespace pg::interface { + Manager::Manager(const Window & window, pg::Manager & manager) + : _window(window), _manager(manager), _title(window.title()) { + ImGui::CreateContext(); + ImGui::GetIO().IniFilename = "config/imgui.ini"; + + ImGui_ImplGlfw_InitForOpenGL(window.address(), true); + ImGui_ImplOpenGL3_Init("#version 330 core"); + } + + Manager::~Manager() { + ImGui::GetIO().IniFilename = "res/config/imgui.ini"; + + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); + } + + void Manager::render(double current_time) { + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + this->_historical.count(current_time); + + if(ImGui::Begin(this->_title.c_str())) { + if(ImGui::BeginTabBar("")) { + if(ImGui::BeginTabItem("Scene")) { + auto current = this->_manager.current(); + if(current.has_value()) { + (*(*current)->interface())->render(current_time); + } + + ImGui::EndTabItem(); + } + + if(ImGui::BeginTabItem("Performance")) { + this->_historical.render(current_time); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + } + ImGui::End(); + + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + } +} \ No newline at end of file diff --git a/ParticleGenerator/src/Interface/Manager.hpp b/ParticleGenerator/src/Interface/Manager.hpp new file mode 100644 index 0000000000000000000000000000000000000000..239ea7f8946cb57d5678e720b6200c7b503b479d --- /dev/null +++ b/ParticleGenerator/src/Interface/Manager.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "Interface.hpp" + +#include "../System/FrameHistorical.hpp" +#include "../Scene/Manager.hpp" +#include "../System/Window.hpp" + +namespace pg::interface { + class Manager { + private: + const Window & _window; + pg::Manager & _manager; + FrameHistorical _historical; + std::string _title; + + public: + Manager(const Window &, pg::Manager &); + ~Manager(); + + void render(double); + }; +} \ No newline at end of file diff --git a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Scene/MeshGenerator.cpp.old similarity index 92% rename from ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp rename to ParticleGenerator/src/Interface/Scene/MeshGenerator.cpp.old index 128109217f5455ea6548f8618756e525f485ca24..3c13649751f8c803847481f5abea8cf8ad036c8e 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp +++ b/ParticleGenerator/src/Interface/Scene/MeshGenerator.cpp.old @@ -1,11 +1,11 @@ -#include "MeshGeneratorInterface.hpp" +#include "MeshGenerator.hpp" #include <imgui.h> #include "../../Scene/Scenes/MeshGenerator.hpp" #include "../../tfd/tinyfiledialogs.h" -namespace pg { - MeshGeneratorInterface::MeshGeneratorInterface(scene::MeshGenerator * scene, size_t max) +namespace pg::interface { + MeshGenerator::MeshGenerator(scene::MeshGenerator * scene, size_t max) : _scene(scene), _interface(nullptr), _max(max), @@ -17,7 +17,7 @@ namespace pg { } - void MeshGeneratorInterface::render(double current_time) { + void MeshGenerator::render(double current_time) { ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max); ImGui::SameLine(); if(ImGui::Button("Spawn")) { diff --git a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp b/ParticleGenerator/src/Interface/Scene/MeshGenerator.hpp.old similarity index 72% rename from ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp rename to ParticleGenerator/src/Interface/Scene/MeshGenerator.hpp.old index 0808a65ff4917a707df4f0aa81856069d4e7a872..e0ddd63914ba136a90d8ec7a47326ddcce2e0de7 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp +++ b/ParticleGenerator/src/Interface/Scene/MeshGenerator.hpp.old @@ -1,17 +1,17 @@ #pragma once #include "../Interface.hpp" -#include "../Generator/PhysicGeneratorInterface.hpp" +#include "../Generator/PhysicGenerator.hpp" -namespace pg { - namespace scene { - class MeshGenerator; - } +namespace pg::scene { + class MeshGenerator; +} - class MeshGeneratorInterface : public Interface { +namespace pg::interface { + class MeshGenerator : public Interface { private: scene::MeshGenerator * _scene; - PhysicGeneratorInterface _interface; + PhysicGenerator _interface; size_t _max; int _spawnFrequence; @@ -22,7 +22,7 @@ namespace pg { bool _enableSpawn; public: - MeshGeneratorInterface(scene::MeshGenerator *, size_t max = 1024); + MeshGenerator(scene::MeshGenerator *, size_t max = 1024); inline size_t getMaxParticle() const {return this->_max;} diff --git a/ParticleGenerator/src/Interface/Scene/MeshSceneInterface.cpp b/ParticleGenerator/src/Interface/Scene/MeshScene.cpp.old similarity index 93% rename from ParticleGenerator/src/Interface/Scene/MeshSceneInterface.cpp rename to ParticleGenerator/src/Interface/Scene/MeshScene.cpp.old index 150ee302d6525a2399939ddae6039c15ce6ac1c1..41cffa668fc8d91397427bf7ad4da2763afb4f1c 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshSceneInterface.cpp +++ b/ParticleGenerator/src/Interface/Scene/MeshScene.cpp.old @@ -1,14 +1,14 @@ -#include "MeshSceneInterface.hpp" +#include "MeshScene.hpp" #include <imgui.h> #include "../../Scene/Scenes/Mesh.hpp" #include "../../tfd/tinyfiledialogs.h" -namespace pg { - MeshSceneInterface::MeshSceneInterface(scene::Mesh * scene, PathParticleGenerator * path, PhysicsParticleGenerator * physic) +namespace pg::interface { + MeshScene::MeshScene(scene::Mesh * scene, PathParticleGenerator * path, PhysicsParticleGenerator * physic) : _scene(scene), - _currentInterface(nullptr), + _current(nullptr), _pathGenerator(path), _physicGenerator(physic), _max(1024), @@ -21,7 +21,7 @@ namespace pg { } - void MeshSceneInterface::render(double current_time) { + void MeshScene::render(double current_time) { ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max); ImGui::SameLine(); if(ImGui::Button("Clear")) { diff --git a/ParticleGenerator/src/Interface/Scene/MeshSceneInterface.hpp b/ParticleGenerator/src/Interface/Scene/MeshScene.hpp.old similarity index 67% rename from ParticleGenerator/src/Interface/Scene/MeshSceneInterface.hpp rename to ParticleGenerator/src/Interface/Scene/MeshScene.hpp.old index 4cb4c05f06b0b1a5dbec83149503877d23970290..7613ade336fb1df51a2e08ef5b1e8aa355f9f005 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshSceneInterface.hpp +++ b/ParticleGenerator/src/Interface/Scene/MeshScene.hpp.old @@ -1,22 +1,22 @@ #pragma once #include "../Interface.hpp" -#include "../Generator/PathGeneratorInterface.hpp" -#include "../Generator/PhysicGeneratorInterface.hpp" +#include "../Generator/PathGenerator.hpp" +#include "../Generator/PhysicGenerator.hpp" #include <glm/vec4.hpp> -namespace pg { - namespace scene { - class Mesh; - } +namespace pg::scene { + class Mesh; +} - class MeshSceneInterface : public Interface { +namespace pg::interface { + class MeshScene : public Interface { private: scene::Mesh * _scene; - Interface * _currentInterface; - PathGeneratorInterface _pathGenerator; - PhysicGeneratorInterface _physicGenerator; + Interface * _current; + PathGenerator _pathGenerator; + PhysicGenerator _physicGenerator; int _max; @@ -30,7 +30,7 @@ namespace pg { bool _enableRender; public: - MeshSceneInterface(scene::Mesh *, PathParticleGenerator *, PhysicsParticleGenerator *); + MeshScene(scene::Mesh *, PathParticleGenerator *, PhysicsParticleGenerator *); inline int getMaxParticle() const {return this->_max;} diff --git a/ParticleGenerator/src/Interface/Scene/PathSceneInterface.cpp b/ParticleGenerator/src/Interface/Scene/PathScene.cpp.old similarity index 91% rename from ParticleGenerator/src/Interface/Scene/PathSceneInterface.cpp rename to ParticleGenerator/src/Interface/Scene/PathScene.cpp.old index 7b1fb2fb4ddb7c63b3a9b225e3f9fb1abd45cc07..b305e15edcf30fc37dff7c484dd79c0e78980ff2 100644 --- a/ParticleGenerator/src/Interface/Scene/PathSceneInterface.cpp +++ b/ParticleGenerator/src/Interface/Scene/PathScene.cpp.old @@ -1,12 +1,12 @@ -#include "PathSceneInterface.hpp" +#include "PathScene.hpp" #include <imgui.h> #include "../../Scene/Scenes/Path.hpp" #include "../../tfd/tinyfiledialogs.h" -namespace pg { - PathSceneInterface::PathSceneInterface(scene::Path * scene) +namespace pg::interface { + PathScene::PathScene(scene::Path * scene) : _scene(scene), _interface(&scene->_generator, &scene->_trajectory), _max(1024), @@ -17,7 +17,7 @@ namespace pg { _enableRender(true), _enableSpawning(true) {} - void PathSceneInterface::render(double current_time) { + void PathScene::render(double current_time) { ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max); ImGui::Checkbox("Enable Rendering", &this->_enableRender); ImGui::Separator(); diff --git a/ParticleGenerator/src/Interface/Scene/PathSceneInterface.hpp b/ParticleGenerator/src/Interface/Scene/PathScene.hpp.old similarity index 79% rename from ParticleGenerator/src/Interface/Scene/PathSceneInterface.hpp rename to ParticleGenerator/src/Interface/Scene/PathScene.hpp.old index e170597832e5ec71177da263b05a90c71ea51ff5..0ccf7eef2e6a3994f266ed8169e2fbea7d0e8cf1 100644 --- a/ParticleGenerator/src/Interface/Scene/PathSceneInterface.hpp +++ b/ParticleGenerator/src/Interface/Scene/PathScene.hpp.old @@ -1,19 +1,20 @@ #pragma once #include "../Interface.hpp" -#include "../Generator/PathGeneratorInterface.hpp" +#include "../Generator/PathGenerator.hpp" #include <glm/vec4.hpp> -namespace pg { - namespace scene { - class Path; - } - class PathSceneInterface : public Interface { +namespace pg::scene { + class Path; +} + +namespace pg::interface { + class PathScene : public Interface { private: scene::Path * _scene; - PathGeneratorInterface _interface; + PathGenerator _interface; int _max; int _spawnFrequence; @@ -26,7 +27,7 @@ namespace pg { bool _enableSpawning; public: - PathSceneInterface(scene::Path *); + PathScene(scene::Path *); inline int getMaxParticle() const {return this->_max;} inline int getSpawnFrequence() const {return this->_spawnFrequence;} @@ -45,6 +46,6 @@ namespace pg { inline void setEnableSpawning(bool state) {this->_enableSpawning = state;} virtual void render(double); - inline std::string title() const {return "Path Scene Interface";} + inline std::string title() const {return "Path Scene ";} }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.cpp b/ParticleGenerator/src/Interface/Scene/PhysicScene.cpp.old similarity index 91% rename from ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.cpp rename to ParticleGenerator/src/Interface/Scene/PhysicScene.cpp.old index 6e7883b4d4b8524061bad30440b454caca62ffaf..b5d822f9b994f23e2de684d38b9f0ce58dccfe82 100644 --- a/ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.cpp +++ b/ParticleGenerator/src/Interface/Scene/PhysicScene.cpp.old @@ -1,4 +1,4 @@ -#include "PhysicSceneInterface.hpp" +#include "PhysicScene.hpp" #include <imgui.h> #include "../../tfd/tinyfiledialogs.h" @@ -7,8 +7,8 @@ #include <iostream> -namespace pg { - PhysicSceneInterface::PhysicSceneInterface(scene::Physic * scene) +namespace pg::interface { + PhysicScene::PhysicScene(scene::Physic * scene) : _scene(scene), _generator(&scene->_generator), _max(1024), @@ -19,7 +19,7 @@ namespace pg { _enableRender(true), _enableSpawning(true) {} - void PhysicSceneInterface::render(double current_time) { + void PhysicScene::render(double current_time) { ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max); //ImGui::Text("Frame Per Second : %f.", this->_fps); ImGui::Checkbox("Enable Rendering", &this->_enableRender); diff --git a/ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.hpp b/ParticleGenerator/src/Interface/Scene/PhysicScene.hpp.old similarity index 78% rename from ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.hpp rename to ParticleGenerator/src/Interface/Scene/PhysicScene.hpp.old index 3f1b3a80734c53635e32dc3e319b2e69f159c176..ad4b40d19e1be9ce8725e1988f50ef0c9a90064d 100644 --- a/ParticleGenerator/src/Interface/Scene/PhysicSceneInterface.hpp +++ b/ParticleGenerator/src/Interface/Scene/PhysicScene.hpp.old @@ -1,19 +1,19 @@ #pragma once #include "../Interface.hpp" -#include "../Generator/PhysicGeneratorInterface.hpp" +#include "../Generator/PhysicGenerator.hpp" #include <glm/vec4.hpp> -namespace pg { - namespace scene { - class Physic; - } +namespace pg::scene { + class Physic; +} - class PhysicSceneInterface : public Interface { +namespace pg::interface { + class PhysicScene : public Interface { private: scene::Physic * _scene; - PhysicGeneratorInterface _generator; + PhysicGenerator _generator; int _max; int _spawnFrequence; @@ -26,7 +26,7 @@ namespace pg { bool _enableSpawning; public: - PhysicSceneInterface(scene::Physic *); + PhysicScene(scene::Physic *); inline int getMaxParticle() const {return this->_max;} inline int getSpawnFrequence() const {return this->_spawnFrequence;} @@ -45,6 +45,6 @@ namespace pg { inline void setEnableSpawning(bool state) {this->_enableSpawning = state;} virtual void render(double); - inline std::string title() const {return "Physic Scene Interface";} + inline std::string title() const {return "Physic Scene ";} }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp b/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp index 312ca00c762c250e4bbffac5699d4a30129f8ed7..9efcc9e973dea2e4c0aacc054702e3229a39425e 100644 --- a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp @@ -3,8 +3,11 @@ #include "ParticleGenerator.hpp" #include "../PathParticle.hpp" + namespace pg { - class PathGeneratorInterface; + namespace interface { + class PathGenerator; + } class PathParticleGenerator : public ParticleGenerator { private: @@ -30,6 +33,6 @@ namespace pg { std::vector<std::unique_ptr<Particle>> generate(size_t count, size_t birth = 0) const override; - friend class PathGeneratorInterface; + friend class interface::PathGenerator; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp b/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp index a2f2141715004012b73e2add6f6de3e2ea56b24b..155a07c212091e2029b763664c54acba40d47fe2 100644 --- a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp @@ -3,7 +3,7 @@ #include "ParticleGenerator.hpp" #include "../PhysicsParticle.hpp" -#include "../../Interface/Generator/PhysicGeneratorInterface.hpp" +#include "../../Interface/Generator/PhysicGenerator.hpp" namespace pg { template <typename T> @@ -41,6 +41,6 @@ namespace pg { std::vector<std::unique_ptr<Particle>> generate(size_t count, size_t birth = 0) const override; - friend class PhysicGeneratorInterface; + friend class interface::PhysicGenerator; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Manager.cpp b/ParticleGenerator/src/Scene/Manager.cpp index 6859612415a249c7757b080dc7ed7b22f09fbd03..8f93c281e09351a41a6bebb2bf6ad245d7ddd198 100644 --- a/ParticleGenerator/src/Scene/Manager.cpp +++ b/ParticleGenerator/src/Scene/Manager.cpp @@ -1,38 +1,39 @@ #include "Scenes/Grid.hpp" #include "Manager.hpp" -#include <imgui.h> +#include <algorithm> namespace pg { - Manager::Manager(const Window & window, Scene * scene) - : _current(scene), - _scenes(), - _renderer(window), - _interface(this) { - if(scene != nullptr) { - scene->initialize(); - } - } + Manager::Manager(const Window & window) + : _current(this->_scenes.begin()), + _sceneRenderer(window, *this) {} Manager::~Manager() { - if(this->_current != nullptr) { - this->_current->destroy(); + if(this->_current != this->_scenes.end()) { + (*this->_current)->destroy(); } } - void Manager::setScene(Scene * scene) { - if(this->_current != nullptr) { - this->_current->destroy(); + std::optional<scene::Scene *> Manager::current() const { + return this->_current != this->_scenes.end() ? std::optional<scene::Scene *>((*this->_current).get()) : std::optional<scene::Scene *>(); + } + + void Manager::setCurrent(scene::Scene & scene) { + if(this->_current != this->_scenes.end()) { + (*this->_current)->destroy(); } - this->_current = scene; - this->_current->initialize(); + auto ptr = std::shared_ptr<scene::Scene>(&scene); + if(!this->_scenes.contains(ptr)) { + this->_scenes.insert(ptr); + } + + this->_current = std::find(this->_scenes.begin(), this->_scenes.end(), ptr); + (*this->_current)->initialize(); } void Manager::render(const Camera & camera, double current_time) { - if(this->_current != nullptr) { - this->_renderer.update(*this->_current, current_time); - this->_renderer.render(*this->_current, camera, current_time); - } + auto current = this->current(); + this->_sceneRenderer.render(current, camera, current_time); } } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Manager.hpp b/ParticleGenerator/src/Scene/Manager.hpp index e4fea92dee0f3ec49a09c6ec3db458e257d2097e..ca30daf84eea527802b4494d36a0a7d88f7432d6 100644 --- a/ParticleGenerator/src/Scene/Manager.hpp +++ b/ParticleGenerator/src/Scene/Manager.hpp @@ -1,37 +1,37 @@ #pragma once -#include <vector> +#include <set> #include <memory> #include "Renderer.hpp" #include "Scenes/Scene.hpp" + #include "../Renderer/Camera/Camera.hpp" -#include "../Interface/SceneManagerInterface.hpp" namespace pg { + using SceneContainer = std::set<std::shared_ptr<scene::Scene>>; + class Manager { private: - Scene * _current; - std::vector<Scene *> _scenes; + SceneContainer _scenes; + SceneContainer::iterator _current; - Renderer _renderer; - SceneManagerInterface _interface; + scene::Renderer _sceneRenderer; - public: - Manager(const Window &, Scene * = nullptr); + Manager() = delete; + Manager(const Window &); ~Manager(); + + inline const SceneContainer & getScenes() const {return this->_scenes;} + inline const scene::Renderer & getSceneRenderer() const {return this->_sceneRenderer;} - inline Scene * current() const {return this->_current;} - inline const std::vector<Scene *> scenes() const {return this->_scenes;} - inline SceneManagerInterface & interface() {return this->_interface;} + inline void add(scene::Scene * scene) {this->_scenes.insert(std::shared_ptr<scene::Scene>(scene));} - inline void add(Scene & scene) {this->_scenes.push_back(&scene);} + std::optional<scene::Scene *> current() const; - void setScene(Scene *); + void setCurrent(scene::Scene & scene); virtual void render(const Camera &, double); - - friend class SceneManagerInterface; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Renderer.cpp b/ParticleGenerator/src/Scene/Renderer.cpp index f750c4fb1bd2dc701342e8d6ffc2eb7172d5ed1f..c8264994ec3f7832ead60f4b4ba5680b6f8828d0 100644 --- a/ParticleGenerator/src/Scene/Renderer.cpp +++ b/ParticleGenerator/src/Scene/Renderer.cpp @@ -4,9 +4,10 @@ #include "../Renderer/Shader/Source.hpp" -namespace pg { - Renderer::Renderer(const Window & window) +namespace pg::scene { + Renderer::Renderer(const Window & window, Manager & manager) : _window(window), + _manager(manager), _grid(), _chronometer(), _accumulator(0.f), @@ -18,7 +19,7 @@ namespace pg { this->_grid.destroy(); } - void Renderer::update(Scene & scene, double current_time) { + void Renderer::update(scene::Scene & scene, double current_time) { double deltaTime = this->_chronometer.getElapsedTime().seconds; this->_chronometer.restart(); @@ -29,15 +30,17 @@ namespace pg { } } - void Renderer::render(Scene & scene, const Camera & camera, double current_time) { + void Renderer::render(std::optional<Scene *> scene, const Camera & camera, double current_time) { glClearColor(0.f, 0.f, 0.f, 1.f); glEnable(GL_BLEND); glEnable(GL_MULTISAMPLE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); this->_grid.render(camera, current_time); - scene.render(camera, current_time); + + if(scene.has_value()) { + (*scene)->render(camera, current_time); + } error::OpenGLError::check(); } diff --git a/ParticleGenerator/src/Scene/Renderer.hpp b/ParticleGenerator/src/Scene/Renderer.hpp index 32cc1d878284bdd9f7ae1bcbd6a85f33793f9380..a834d51bd75adb5bbf1531953290fdd7e0580cae 100644 --- a/ParticleGenerator/src/Scene/Renderer.hpp +++ b/ParticleGenerator/src/Scene/Renderer.hpp @@ -1,32 +1,34 @@ #pragma once -#include <vector> -#include <map> - +#include <optional> #include "Scenes/Grid.hpp" + #include "../Renderer/Renderer.hpp" #include "../System/Window.hpp" #include "../System/Chronometer.hpp" namespace pg { + class Manager; +} + +namespace pg::scene { class Renderer { private: const Window & _window; - scene::Grid _grid; + Manager & _manager; + Grid _grid; Chronometer _chronometer; float _accumulator, _timestep; public: - Renderer(const Window &); + Renderer(const Window &, Manager &); ~Renderer(); - + inline const Window & getWindow() const {return this->_window;} + void update(Scene &, double); - void render(Scene &, const Camera &, double); - - static std::vector<float> GetRendererShape(); - + void render(std::optional<Scene *>, const Camera &, double); }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Grid.cpp b/ParticleGenerator/src/Scene/Scenes/Grid.cpp index a5e2e637c80237cde46a3359fade3daf9367a4c4..160db938c45d601e5aba7c958540c5f40cad69a5 100644 --- a/ParticleGenerator/src/Scene/Scenes/Grid.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Grid.cpp @@ -58,13 +58,7 @@ namespace pg::scene } - std::string Grid::name() const - { + std::string Grid::name() const { return "Grid"; } - - Interface* Grid::interface() - { - return nullptr; - } } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Grid.hpp b/ParticleGenerator/src/Scene/Scenes/Grid.hpp index 9d2280e470e17cb155d2d69af1f73a1dcaca654c..bc2f71ec847cb1ad96ee02fea55e3639a875af3b 100644 --- a/ParticleGenerator/src/Scene/Scenes/Grid.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Grid.hpp @@ -25,6 +25,5 @@ namespace pg::scene void destroy() override; std::string name() const override; - Interface* interface() override; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Mesh.cpp b/ParticleGenerator/src/Scene/Scenes/Mesh.cpp.old similarity index 99% rename from ParticleGenerator/src/Scene/Scenes/Mesh.cpp rename to ParticleGenerator/src/Scene/Scenes/Mesh.cpp.old index d60ced35bf1f2cf5731f3f55aca35e0c69b14e82..c80904f0b3dd84718f2b63e8306d33611d6dbb0d 100644 --- a/ParticleGenerator/src/Scene/Scenes/Mesh.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Mesh.cpp.old @@ -189,7 +189,7 @@ namespace pg::scene return "Mesh Scene"; } - Interface* Mesh::interface() { + interface::Interface* Mesh::interface() { return &this->_interface; } diff --git a/ParticleGenerator/src/Scene/Scenes/Mesh.hpp b/ParticleGenerator/src/Scene/Scenes/Mesh.hpp.old similarity index 87% rename from ParticleGenerator/src/Scene/Scenes/Mesh.hpp rename to ParticleGenerator/src/Scene/Scenes/Mesh.hpp.old index 14252444ad9153649034607779c56621739e63eb..385128e1b2b582a38eedf191eb6b118a792dcb4c 100644 --- a/ParticleGenerator/src/Scene/Scenes/Mesh.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Mesh.hpp.old @@ -10,7 +10,7 @@ #include "../../Particle/generator/PathParticleGenerator.hpp" #include "../../Particle/generator/PhysicsParticleGenerator.hpp" -#include "../../Interface/Scene/MeshSceneInterface.hpp" +#include "../../Interface/Scene/MeshScene.hpp" #include "../../Mesh/Skybox.hpp" @@ -32,7 +32,7 @@ namespace pg::scene std::vector<std::unique_ptr<Particle>> _particles; SkyBox _skybox; - MeshSceneInterface _interface; + interface::MeshScene _interface; GLuint _ubo; @@ -50,12 +50,12 @@ namespace pg::scene void destroy() override; std::string name() const override; - Interface* interface() override; + interface::Interface* interface() override; void setMesh(const std::string &); void setTexture(const std::string &); void setTextureUse(bool); - friend class pg::MeshSceneInterface; + friend class pg::interface::MeshScene; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp.old similarity index 100% rename from ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp rename to ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp.old diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp.old similarity index 84% rename from ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp rename to ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp.old index fbd6a656bf99a85263b69a925943549e5ffab116..9bbefc8e2212a750bf73cb6708e2ffd2123569e6 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp.old @@ -9,7 +9,7 @@ #include "../../Mesh/Billboard.hpp" #include "../../Renderer/Renderer.hpp" #include "../../Particle/generator/PhysicsParticleGenerator.hpp" -#include "../../Interface/Scene/MeshGeneratorInterface.hpp" +#include "../../Interface/Scene/MeshGenerator.hpp" namespace pg::scene { class MeshGenerator : public Scene { @@ -26,7 +26,7 @@ namespace pg::scene { Program _billboardProgram; GLuint _ubo; - MeshGeneratorInterface _interface; + interface::MeshGenerator _interface; public: MeshGenerator(); @@ -40,14 +40,14 @@ namespace pg::scene { virtual void destroy(); virtual std::string name() const {return "Mesh Generator Scene";}; - virtual Interface * interface() {return &this->_interface;} + virtual interface::Interface * interface() {return &this->_interface;} void changeMesh(const std::string &); void changeTexture(const std::string &); void spawn(size_t count, double current_time); - friend class pg::MeshGeneratorInterface; + friend class pg::interface::MeshGenerator; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Path.cpp b/ParticleGenerator/src/Scene/Scenes/Path.cpp.old similarity index 100% rename from ParticleGenerator/src/Scene/Scenes/Path.cpp rename to ParticleGenerator/src/Scene/Scenes/Path.cpp.old diff --git a/ParticleGenerator/src/Scene/Scenes/Path.hpp b/ParticleGenerator/src/Scene/Scenes/Path.hpp.old similarity index 84% rename from ParticleGenerator/src/Scene/Scenes/Path.hpp rename to ParticleGenerator/src/Scene/Scenes/Path.hpp.old index 8e808ba2aea80b476c58a6e4aa02ce1b5732ad73..b50c5a47231936f5fef70f9884bb046de3e30bbb 100644 --- a/ParticleGenerator/src/Scene/Scenes/Path.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Path.hpp.old @@ -4,7 +4,7 @@ #include "../../Renderer/Renderer.hpp" #include "../../Particle/generator/PathParticleGenerator.hpp" -#include "../../Interface/Scene/PathSceneInterface.hpp" +#include "../../Interface/Scene/PathScene.hpp" #include "../../Mesh/Billboard.hpp" #include "../../Mesh/Trajectory.hpp" @@ -22,7 +22,7 @@ namespace pg::scene { PathParticleGenerator _generator; std::vector<std::unique_ptr<Particle>> _particles; - PathSceneInterface _interface; + interface::PathScene _interface; public: Path(ct::CurveGenerator *, const ct::Curve &); @@ -39,8 +39,8 @@ namespace pg::scene { void changeParticletexture(const std::string &); virtual std::string name() const {return "Path Scene";} - virtual Interface * interface() {return &this->_interface;} + virtual interface::Interface * interface() {return &this->_interface;} - friend class pg::PathSceneInterface; + friend class pg::interface::PathScene; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Physic.cpp b/ParticleGenerator/src/Scene/Scenes/Physic.cpp.old similarity index 100% rename from ParticleGenerator/src/Scene/Scenes/Physic.cpp rename to ParticleGenerator/src/Scene/Scenes/Physic.cpp.old diff --git a/ParticleGenerator/src/Scene/Scenes/Physic.hpp b/ParticleGenerator/src/Scene/Scenes/Physic.hpp.old similarity index 83% rename from ParticleGenerator/src/Scene/Scenes/Physic.hpp rename to ParticleGenerator/src/Scene/Scenes/Physic.hpp.old index 36cd2d7f4da9e096321ce3ce3040f7af68d69307..65d1c993a22ffb2db91446de3ac3f15f20701c3a 100644 --- a/ParticleGenerator/src/Scene/Scenes/Physic.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Physic.hpp.old @@ -4,7 +4,7 @@ #include "../../Renderer/Renderer.hpp" #include "../../Particle/generator/PhysicsParticleGenerator.hpp" -#include "../../Interface/Scene/PhysicSceneInterface.hpp" +#include "../../Interface/Scene/PhysicScene.hpp" #include "../../Mesh/Billboard.hpp" #include "../../System/Window.hpp" @@ -18,26 +18,27 @@ namespace pg::scene { Billboard _billboards; PhysicsParticleGenerator _generator; std::vector<std::unique_ptr<Particle>> _particles; - - PhysicSceneInterface _interface; + + interface::PhysicScene _interface; public: Physic(); - virtual void initialize(); - virtual void render(const Camera &, double); - virtual void update(double); - virtual void destroy(); - inline const Program & getProgram() const {return this->_program;} inline const Material & getTexture() const {return this->_texture;} inline const PhysicsParticleGenerator & getGenerator() const {return this->_generator;} + void changeParticletexture(const std::string &); + virtual std::string name() const {return "Physic Scene";} - virtual Interface * interface() {return &this->_interface;} - void changeParticletexture(const std::string &); + virtual void initialize(); + virtual void render(const Camera &, double); + virtual void update(double); + virtual void destroy(); + + - friend class pg::PhysicSceneInterface; + friend class pg::interface::PhysicScene; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/Scene.hpp b/ParticleGenerator/src/Scene/Scenes/Scene.hpp index f6eb3f6564e38ee008f338437da502bb68a2b362..454a9dcaaec58ce4bbdfeb813f64a9ce9e02757a 100644 --- a/ParticleGenerator/src/Scene/Scenes/Scene.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Scene.hpp @@ -1,21 +1,23 @@ #pragma once #include <string> +#include <optional> #include "../../Interface/Interface.hpp" #include "../../Renderer/Camera/Camera.hpp" -namespace pg { +namespace pg::scene { class Scene { public: + Scene() = default; + virtual ~Scene() = default; + + virtual std::string name() const {return "Scene";} + virtual std::optional<interface::Interface *> interface() const {return std::optional<interface::Interface *>();} + virtual void initialize() = 0; virtual void update(double) = 0; virtual void render(const Camera &, double) = 0; virtual void destroy() = 0; - - virtual std::string name() const = 0; - virtual Interface * interface() = 0; - - virtual ~Scene() = default; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/System/FrameHistorical.cpp b/ParticleGenerator/src/System/FrameHistorical.cpp index 640a913d3ffa7eb1f3280e7e61c3da699a82be80..551833a0ccec5772a5c1c4506f3eb5103b605435 100644 --- a/ParticleGenerator/src/System/FrameHistorical.cpp +++ b/ParticleGenerator/src/System/FrameHistorical.cpp @@ -3,7 +3,7 @@ #include <imgui.h> #include <algorithm> -namespace pg { +namespace pg::interface { FrameHistorical::FrameHistorical() { for(short i = 0; i < 100; i++) { this->_frames.push_back(0); diff --git a/ParticleGenerator/src/System/FrameHistorical.hpp b/ParticleGenerator/src/System/FrameHistorical.hpp index 8b3f3a2affdcdd6edb291354293c793a4cc9c56c..625d0ff011fd4970657c0d28581d326f7a77a01d 100644 --- a/ParticleGenerator/src/System/FrameHistorical.hpp +++ b/ParticleGenerator/src/System/FrameHistorical.hpp @@ -5,8 +5,8 @@ #include <vector> -namespace pg { - class FrameHistorical : public FrameCounter, public Interface { +namespace pg::interface { + class FrameHistorical : public FrameCounter, public interface::Interface { private: std::vector<float> _frames; diff --git a/ParticleGenerator/src/main.cpp b/ParticleGenerator/src/main.cpp index c7120740630bef3c0ed296750847bda9c82ec490..282260691a5f9f2ffc46807a1a57171403b0e7ca 100644 --- a/ParticleGenerator/src/main.cpp +++ b/ParticleGenerator/src/main.cpp @@ -1,28 +1,21 @@ #include <iostream> +#include <CurveTools/CPU/BezierGenerator.hpp> +#include <GL/glew.h> -#include "Renderer/Renderer.hpp" - +#include "Renderer/Camera/OrbitCamera.hpp" #include "System/Window.hpp" #include "Scene/Manager.hpp" -#include "Scene/Scenes/Grid.hpp" -#include "Scene/Scenes/Physic.hpp" -#include "Scene/Scenes/Path.hpp" -#include "Scene/Scenes/Mesh.hpp" -#include "Scene/Scenes/MeshGenerator.hpp" +#include "Interface/Manager.hpp" -#include "Interface/GlobalInterface.hpp" +//#include "Scene/Scenes/Physic.hpp" +//#include "Scene/Scenes/Path.hpp" +//#include "Scene/Scenes/Mesh.hpp" +//#include "Scene/Scenes/MeshGenerator.hpp" -#include "Renderer/Error/OpenGLError.hpp" - -#include <CurveTools/CPU/BezierGenerator.hpp> +#include "Interface/Manager.hpp" -#ifndef WINDOW_DEFAULT_WIDTH - #define WINDOW_DEFAULT_WIDTH 1600 -#endif - -#ifndef WINDOW_DEFAULT_HEIGHT - #define WINDOW_DEFAULT_HEIGHT 900 -#endif +#define WINDOW_DEFAULT_WIDTH 1600 +#define WINDOW_DEFAULT_HEIGHT 900 int main(int argc, const char * argv[]) { try { @@ -73,7 +66,6 @@ int main(int argc, const char * argv[]) { }); } - ct::Curve ctrlPoints { { 10.f, 0.f, 0.f}, {-10.f, 0.f, 0.f} @@ -81,28 +73,20 @@ int main(int argc, const char * argv[]) { ct::BezierGenerator bezier(ctrlPoints.size()); - pg::scene::Physic physicScene; - pg::scene::MeshGenerator meshGeneratorScene; - pg::scene::Path pathScene(&bezier, ctrlPoints); - pg::scene::Mesh meshScene(&bezier, ctrlPoints); + //pg::scene::Physic physic; + //pg::scene::MeshGenerator meshGenerator; + //pg::scene::Path path(&bezier, ctrlPoints); + //pg::scene::Mesh mesh(&bezier, ctrlPoints); - - pg::Manager manager(window, &physicScene); - manager.add(physicScene); - manager.add(pathScene); - manager.add(meshScene); - manager.add(meshGeneratorScene); - - - pg::GlobalInterface interface(window, manager, "Particle Generator Settings"); + pg::Manager manager(window); + pg::interface::Manager imanager(window, manager); + //pg::interface::Global interface(window, manager, "Particle Generator Settings"); while(window.isOpen()) { - window.pollEvents(); double current_time = glfwGetTime(); - + window.pollEvents(); manager.render(camera, current_time); - interface.render(current_time); - + imanager.render(current_time); window.swapBuffer(); } }