diff --git a/ParticleGenerator/res/config/imgui.ini b/ParticleGenerator/res/config/imgui.ini index 1e8440f51fd18d1b7932ceb8f4b12ec543a34cdc..2689187f8485437d98bb77d8297f1f9d77b690f1 100644 --- a/ParticleGenerator/res/config/imgui.ini +++ b/ParticleGenerator/res/config/imgui.ini @@ -3,10 +3,10 @@ Pos=60,60 Size=400,400 [Window][Dear ImGui Demo] -Pos=1021,19 +Pos=1032,14 Size=550,680 [Window][Particle Generator] -Pos=60,60 -Size=553,820 +Pos=-1,11 +Size=823,650 diff --git a/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp index 01c6f58b1e07f85bc20fda74f8615bb65724a53b..dc19281803e142eb9ca4f3d1d1abdaf436479910 100644 --- a/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp +++ b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp @@ -10,7 +10,7 @@ namespace pg::particle { } namespace pg::interface { - class PathGenerator : public Generator<particle::PathGenerator> { + class PathGenerator : virtual public Generator<particle::PathGenerator> { private: scene::Trajectory * _trajectory; diff --git a/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.cpp b/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.cpp index 5b78d60d8a3eb27561b2d9181ff476769072152c..ecebe1762ba981b3a0ca1abca061f8b9ea133977 100644 --- a/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.cpp +++ b/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.cpp @@ -14,7 +14,7 @@ namespace pg::interface { _index(0) {} void PathMultyGenerator::draw(double current_time) { - /*ImGui::Text("Physic generator at %f / %f / %f (x, y, z) - variation : %f.", this->parent()->m_position.x, this->parent()->m_position.y, this->parent()->m_position.z, this->parent()->m_positionVariation); + ImGui::Text("Physic generator at %f / %f / %f (x, y, z) - variation : %f.", this->parent()->m_position.x, this->parent()->m_position.y, this->parent()->m_position.z, this->parent()->m_positionVariation); ImGui::Text("Default u : %f", this->parent()->m_u); ImGui::Text("u increment : %f", this->parent()->m_increment); ImGui::Text("Spacing : %f", this->parent()->m_spacing); @@ -78,8 +78,8 @@ namespace pg::interface { } } } - }*/ - ImGui::Text("Path Multy Generator : %i", this->parent()); + } + ImGui::SeparatorText("Trajectory"); if(this->_trajectory->interface().has_value()) { (*this->_trajectory->interface())->draw(current_time); } diff --git a/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.hpp b/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.hpp index eaa79d9fb362441b4cc8b7fd4a21e36c40b3adc2..b0a29ab2a228d7068956b5e74bee45a408ed8a0d 100644 --- a/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.hpp +++ b/ParticleGenerator/src/Interface/Generator/PathMultyGenerator.hpp @@ -10,7 +10,7 @@ namespace pg::particle { } namespace pg::interface { - class PathMultyGenerator : public Generator<particle::PathMultyGenerator> { + class PathMultyGenerator : virtual public Generator<particle::PathMultyGenerator> { private: scene::TrajectoryMulty * _trajectory; diff --git a/ParticleGenerator/src/Interface/Scene/MultyPath.cpp b/ParticleGenerator/src/Interface/Scene/MultyPath.cpp index 7da70e48bb0b831ab3d773c4a8d329ca31b29708..13ec32108cab01ad815291aa13b654292a78f413 100644 --- a/ParticleGenerator/src/Interface/Scene/MultyPath.cpp +++ b/ParticleGenerator/src/Interface/Scene/MultyPath.cpp @@ -12,13 +12,13 @@ namespace pg::interface { void MultyPath::draw(double current_time) { SceneParticle::draw(current_time); - /*ImGui::SeparatorText("Texture"); + ImGui::SeparatorText("Texture"); ImGui::Image((void*)(intptr_t)this->parent()->getTexture().identifier(), ImVec2(128, 128), ImVec2(0, 1), ImVec2(1, 0)); if(ImGui::Button("Change Texture", ImVec2(128, 25))) { char const * imagePatterns[1] = {"*.png"}; - std::string MultyPath = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image File", false); - this->parent()->changeParticletexture(MultyPath); + std::string path = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image File", false); + this->parent()->changeParticletexture(path); } ImGui::SameLine(); ImGui::ColorEdit4("Color", &this->parent()->_color[0]); @@ -26,14 +26,5 @@ namespace pg::interface { ImGui::SeparatorText("Generator"); this->_interface.draw(current_time); - - ImGui::SeparatorText("Trajectory"); - - auto tinterface = this->parent()->_trajectory.interface(); - if(tinterface.has_value()) { - (*tinterface)->draw(current_time); - }*/ - - this->_interface.draw(current_time); } } \ No newline at end of file diff --git a/ParticleGenerator/src/Interface/Scene/TrajectoryMulty.cpp b/ParticleGenerator/src/Interface/Scene/TrajectoryMulty.cpp index 6b358a3836207d037db0c69ebc55be9a0a1e4c37..523ee433ff725d59a2b10fe4774c2846e7fdbcaa 100644 --- a/ParticleGenerator/src/Interface/Scene/TrajectoryMulty.cpp +++ b/ParticleGenerator/src/Interface/Scene/TrajectoryMulty.cpp @@ -9,32 +9,38 @@ namespace pg::interface { : Scene(parent) {} void TrajectoryMulty::draw(double current_time) { - /*ImGui::ColorEdit4("Curve Color", &this->parent()->_color[0]); - ImGui::Checkbox("Enable Render", &this->parent()->_enableRender); - ImGui::Separator(); ImGui::Checkbox("Enable Control Line", &this->parent()->_controlLine); - - ImGui::Separator(); - ImGui::SliderFloat("Point Size", &this->parent()->_pointSize, 1.f, 64.f); - ImGui::SliderFloat("Line Size", &this->parent()->_lineSize, 1.f, 10.f); - if(ImGui::InputDouble("Curve Precision", &this->parent()->_increment, 0.01, 0.1)) { - if(this->parent()->_increment > 0.0) { - this->parent()->update(current_time); - } - }*/ + ImGui::Checkbox("Enable Control Point", &this->parent()->_enableControl); + ImGui::Checkbox("Enable Curve Line", &this->parent()->_enableLine); + ImGui::Separator(); size_t color_nb = this->parent()->_colors.size(); size_t i = 0; + ImGui::Columns(2); for(auto &[name, generator] : this->parent()->_generators->getGenerators()) { - size_t index = i%color_nb; - ImGui::Text("%s : ", name.c_str()); - ImGui::SameLine(); + ImGui::Text("%s", name.c_str()); + } + + ImGui::NextColumn(); + + for(auto &[name, generator] : this->parent()->_generators->getGenerators()) { + size_t index = i%color_nb; if(ImGui::ColorEdit4("", &this->parent()->_colors.at(index)[0])) { this->parent()->update(current_time); } ++i; } - ImGui::Text("Trajectory Multy : %i", this->parent()); + + ImGui::Columns(); + + ImGui::Separator(); + ImGui::SliderFloat("Point Size", &this->parent()->_pointSize, 1.f, 64.f); + ImGui::SliderFloat("Line Size", &this->parent()->_lineSize, 1.f, 10.f); + if(ImGui::InputDouble("Curve Precision", &this->parent()->_increment, 0.01, 0.1)) { + if(this->parent()->_increment > 0.0) { + this->parent()->update(current_time); + } + } } } \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/PathGenerator.hpp b/ParticleGenerator/src/Particle/generator/PathGenerator.hpp index 80dcadc3c5c17dea3bb64ccd481a967d0ec0b84a..a34f9688fddc1f5b7b4367fac2c82789d6bd9541 100644 --- a/ParticleGenerator/src/Particle/generator/PathGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PathGenerator.hpp @@ -5,6 +5,8 @@ namespace pg::interface { class PathGenerator; + class PathMultyGenerator; + class PathUniqueGenerator; } namespace pg::particle { @@ -28,5 +30,7 @@ namespace pg::particle { inline void setParameterLifeLimitor(float limitor) {this->m_limitor = limitor;} friend class pg::interface::PathGenerator; + friend class pg::interface::PathMultyGenerator; + friend class pg::interface::PathUniqueGenerator; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/PathMultyGenerator.hpp b/ParticleGenerator/src/Particle/generator/PathMultyGenerator.hpp index 52001c5b5a38dc1e8f479fc8846b8279f010ff23..326d69847e31b1036142eb19556b672933108069 100644 --- a/ParticleGenerator/src/Particle/generator/PathMultyGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PathMultyGenerator.hpp @@ -6,6 +6,10 @@ #include <map> #include <memory> +namespace pg::interface { + class PathMultyGenerator; +}; + namespace pg::particle { class PathMultyGenerator : public PathGenerator { private: @@ -19,5 +23,7 @@ namespace pg::particle { inline const std::map<std::string, std::unique_ptr<ct::CurveGenerator>> & getGenerators() const {return this->_generators;} virtual std::vector<std::unique_ptr<Path>> generate(size_t count, size_t birth = 0) const; + + friend class pg::interface::PathMultyGenerator; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp b/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp index 63cb5e109f1c4e31af8c589837acb7006b1687f1..cc920a0ed90424c838312fde7c1281a83fe911ae 100644 --- a/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp +++ b/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp @@ -15,6 +15,7 @@ namespace pg::scene { _texture(), _generator(ctrlpoint), _trajectory(&this->_generator), + _color(1.f), _interface(this, &this->_generator, &this->_trajectory) { this->_generator.add("Bezier", new ct::BezierGenerator()); this->_generator.add("Catmull-Rom", new ct::CatmullRomGenerator()); @@ -108,7 +109,7 @@ namespace pg::scene { this->_program.setUniform("uView", VIEW_MATRIX); this->_program.setUniform("uProj", PROJECTION_MATRIX); this->_program.setUniform("uSlot", 0); - this->_program.setUniform("uColor", glm::vec4(1.f)); + this->_program.setUniform("uColor", this->_color); pg::error::OpenGLError::check(); diff --git a/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp b/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp index 7dd1d93d860ec2cce203f8a3b768544006a5373f..37ec50dac3d5b964f2a91d25f2765dfae5d18f83 100644 --- a/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp @@ -18,6 +18,7 @@ namespace pg::scene { TrajectoryMulty _trajectory; Material _texture; particle::PathMultyGenerator _generator; + glm::vec4 _color; interface::MultyPath _interface; @@ -40,5 +41,7 @@ namespace pg::scene { virtual std::optional<interface::Interface *> interface() {return std::optional<interface::Interface *>(&this->_interface);} virtual void spawn(int, double); + + friend class interface::MultyPath; }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.cpp b/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.cpp index 611821192e9c845d44c03479ce640089550e95f3..1fcba54016066c9e30806e58f0ddccbf9b514123 100644 --- a/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.cpp +++ b/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.cpp @@ -10,6 +10,8 @@ namespace pg::scene { _pointSize(8.f), _lineSize(1.f), _controlLine(false), + _enableControl(true), + _enableLine(true), _enableRender(true), _interface(this) {} @@ -104,8 +106,13 @@ namespace pg::scene { GLsizei raw = static_cast<GLsizei>(this->_generators->getControlPoint().size()); GLsizei total = static_cast<GLsizei>(this->_vbo.vertices()); - glDrawArrays(GL_LINES, raw, total - raw); - glDrawArrays(this->_controlLine ? GL_LINE_STRIP : GL_POINTS, 0, static_cast<GLsizei>(this->_generators->getControlPoint().size())); + if(this->_enableLine) { + glDrawArrays(GL_LINES, raw, total - raw); + } + + if(this->_enableControl) { + glDrawArrays(this->_controlLine ? GL_LINE_STRIP : GL_POINTS, 0, static_cast<GLsizei>(this->_generators->getControlPoint().size())); + } } } diff --git a/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.hpp b/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.hpp index b371627b27a596321f98917efb97e670187f2643..0c024703fe8994e795d7e6316df6b694cec53e13 100644 --- a/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.hpp +++ b/ParticleGenerator/src/Scene/Scenes/TrajectoryMulty.hpp @@ -22,7 +22,10 @@ namespace pg::scene { float _pointSize; float _lineSize; bool _controlLine; + bool _enableControl; + bool _enableLine; bool _enableRender; + interface::TrajectoryMulty _interface;