Skip to content
Snippets Groups Projects
Commit b3336636 authored by BATON Theau's avatar BATON Theau
Browse files

Add generator selection for mesh generator scene

parent f322c5fc
No related branches found
No related tags found
No related merge requests found
ParticleGenerator/res/textures/grid.png

11.5 KiB | W: | H:

ParticleGenerator/res/textures/grid.png

11.5 KiB | W: | H:

ParticleGenerator/res/textures/grid.png
ParticleGenerator/res/textures/grid.png
ParticleGenerator/res/textures/grid.png
ParticleGenerator/res/textures/grid.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -11,6 +11,10 @@ namespace pg { ...@@ -11,6 +11,10 @@ namespace pg {
: _generator(generator) {} : _generator(generator) {}
void PhysicGeneratorInterface::render(double) { void PhysicGeneratorInterface::render(double) {
if(this->_generator == nullptr) {
return;
}
if(ImGui::CollapsingHeader("Generator Information")) { 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::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"); ImGui::SeparatorText("Velocity");
......
...@@ -12,6 +12,7 @@ namespace pg { ...@@ -12,6 +12,7 @@ namespace pg {
PhysicGeneratorInterface(PhysicsParticleGenerator *); PhysicGeneratorInterface(PhysicsParticleGenerator *);
inline PhysicsParticleGenerator * getGenerator() const {return this->_generator;} inline PhysicsParticleGenerator * getGenerator() const {return this->_generator;}
inline void setGenerator(PhysicsParticleGenerator * generator) {this->_generator = generator;}
virtual void render(double); virtual void render(double);
inline std::string title() const {return "Physic Generator Interface";} inline std::string title() const {return "Physic Generator Interface";}
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace pg { namespace pg {
MeshGeneratorInterface::MeshGeneratorInterface(scene::MeshGenerator * scene, size_t max) MeshGeneratorInterface::MeshGeneratorInterface(scene::MeshGenerator * scene, size_t max)
: _scene(scene), : _scene(scene),
_interface(nullptr),
_max(max), _max(max),
_spawnFrequence(2500), _spawnFrequence(2500),
_spawnCount(1), _spawnCount(1),
...@@ -49,5 +50,30 @@ namespace pg { ...@@ -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
#pragma once #pragma once
#include "../Interface.hpp" #include "../Interface.hpp"
#include "../Generator/PhysicGeneratorInterface.hpp"
namespace pg { namespace pg {
namespace scene { namespace scene {
...@@ -10,6 +11,7 @@ namespace pg { ...@@ -10,6 +11,7 @@ namespace pg {
class MeshGeneratorInterface : public Interface { class MeshGeneratorInterface : public Interface {
private: private:
scene::MeshGenerator * _scene; scene::MeshGenerator * _scene;
PhysicGeneratorInterface _interface;
size_t _max; size_t _max;
int _spawnFrequence; int _spawnFrequence;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment