diff --git a/ParticleGenerator/res/textures/grid.png b/ParticleGenerator/res/textures/grid.png index 4accbdc4038c8f80f609bc46d6a03f6c1f49884b..f2dda5f6d03b3e3e6e0fc5b5ac81a03287ba33bc 100644 Binary files a/ParticleGenerator/res/textures/grid.png and b/ParticleGenerator/res/textures/grid.png differ diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp index f7442ebe597a98e55e25b591b57284f4d32548d5..a5aade5044868a12a6436e80c714009acde288da 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.cpp @@ -11,6 +11,10 @@ namespace pg { : _generator(generator) {} void PhysicGeneratorInterface::render(double) { + if(this->_generator == nullptr) { + return; + } + 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::SeparatorText("Velocity"); diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp b/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp index d889fcd10e78392c8480e583be94a97967388d25..fc8f2ffea69456b27efc768094ae041d3fb04ec1 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGeneratorInterface.hpp @@ -12,6 +12,7 @@ namespace pg { PhysicGeneratorInterface(PhysicsParticleGenerator *); inline PhysicsParticleGenerator * getGenerator() const {return this->_generator;} + inline void setGenerator(PhysicsParticleGenerator * generator) {this->_generator = generator;} virtual void render(double); inline std::string title() const {return "Physic Generator Interface";} diff --git a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp index 19c74a61363ea96c3643b0e448b65b712eee87a2..128109217f5455ea6548f8618756e525f485ca24 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp +++ b/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.cpp @@ -7,6 +7,7 @@ namespace pg { MeshGeneratorInterface::MeshGeneratorInterface(scene::MeshGenerator * scene, size_t max) : _scene(scene), + _interface(nullptr), _max(max), _spawnFrequence(2500), _spawnCount(1), @@ -49,5 +50,30 @@ namespace pg { } } + + ImGui::SeparatorText("Generators"); + + if(!this->_scene->_generators.empty()) { + std::string name = std::to_string(reinterpret_cast<intptr_t>(&this->_scene->_generators.front())); + if(this->_interface.getGenerator() != nullptr) { + name = std::to_string(reinterpret_cast<intptr_t>(this->_interface.getGenerator())); + } + + if(ImGui::BeginCombo("Current Generator", name.c_str())) { + for(auto & generator : this->_scene->_generators) { + bool is_selected = std::to_string(reinterpret_cast<intptr_t>(&generator)) == std::to_string(reinterpret_cast<intptr_t>(this->_interface.getGenerator())); + if(ImGui::Selectable(std::to_string(reinterpret_cast<intptr_t>(&generator)).c_str(), is_selected)) { + this->_interface.setGenerator(&generator); + } + + if (is_selected) { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + } + + this->_interface.render(current_time); } } \ No newline at end of file diff --git a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp b/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp index 8c584af89f47c7d5aef72bf57c3c4f27ebde8f0f..0808a65ff4917a707df4f0aa81856069d4e7a872 100644 --- a/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp +++ b/ParticleGenerator/src/Interface/Scene/MeshGeneratorInterface.hpp @@ -1,6 +1,7 @@ #pragma once #include "../Interface.hpp" +#include "../Generator/PhysicGeneratorInterface.hpp" namespace pg { namespace scene { @@ -10,6 +11,7 @@ namespace pg { class MeshGeneratorInterface : public Interface { private: scene::MeshGenerator * _scene; + PhysicGeneratorInterface _interface; size_t _max; int _spawnFrequence;