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

Add interface for multy path scene

parent a9f3fa08
Branches
No related tags found
No related merge requests found
Showing
with 60 additions and 39 deletions
...@@ -3,10 +3,10 @@ Pos=60,60 ...@@ -3,10 +3,10 @@ Pos=60,60
Size=400,400 Size=400,400
[Window][Dear ImGui Demo] [Window][Dear ImGui Demo]
Pos=1021,19 Pos=1032,14
Size=550,680 Size=550,680
[Window][Particle Generator] [Window][Particle Generator]
Pos=60,60 Pos=-1,11
Size=553,820 Size=823,650
...@@ -10,7 +10,7 @@ namespace pg::particle { ...@@ -10,7 +10,7 @@ namespace pg::particle {
} }
namespace pg::interface { namespace pg::interface {
class PathGenerator : public Generator<particle::PathGenerator> { class PathGenerator : virtual public Generator<particle::PathGenerator> {
private: private:
scene::Trajectory * _trajectory; scene::Trajectory * _trajectory;
......
...@@ -14,7 +14,7 @@ namespace pg::interface { ...@@ -14,7 +14,7 @@ namespace pg::interface {
_index(0) {} _index(0) {}
void PathMultyGenerator::draw(double current_time) { 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("Default u : %f", this->parent()->m_u);
ImGui::Text("u increment : %f", this->parent()->m_increment); ImGui::Text("u increment : %f", this->parent()->m_increment);
ImGui::Text("Spacing : %f", this->parent()->m_spacing); ImGui::Text("Spacing : %f", this->parent()->m_spacing);
...@@ -78,8 +78,8 @@ namespace pg::interface { ...@@ -78,8 +78,8 @@ namespace pg::interface {
} }
} }
} }
}*/ }
ImGui::Text("Path Multy Generator : %i", this->parent()); ImGui::SeparatorText("Trajectory");
if(this->_trajectory->interface().has_value()) { if(this->_trajectory->interface().has_value()) {
(*this->_trajectory->interface())->draw(current_time); (*this->_trajectory->interface())->draw(current_time);
} }
......
...@@ -10,7 +10,7 @@ namespace pg::particle { ...@@ -10,7 +10,7 @@ namespace pg::particle {
} }
namespace pg::interface { namespace pg::interface {
class PathMultyGenerator : public Generator<particle::PathMultyGenerator> { class PathMultyGenerator : virtual public Generator<particle::PathMultyGenerator> {
private: private:
scene::TrajectoryMulty * _trajectory; scene::TrajectoryMulty * _trajectory;
......
...@@ -12,13 +12,13 @@ namespace pg::interface { ...@@ -12,13 +12,13 @@ namespace pg::interface {
void MultyPath::draw(double current_time) { void MultyPath::draw(double current_time) {
SceneParticle::draw(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)); 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))) { if(ImGui::Button("Change Texture", ImVec2(128, 25))) {
char const * imagePatterns[1] = {"*.png"}; char const * imagePatterns[1] = {"*.png"};
std::string MultyPath = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image File", false); std::string path = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image File", false);
this->parent()->changeParticletexture(MultyPath); this->parent()->changeParticletexture(path);
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::ColorEdit4("Color", &this->parent()->_color[0]); ImGui::ColorEdit4("Color", &this->parent()->_color[0]);
...@@ -26,14 +26,5 @@ namespace pg::interface { ...@@ -26,14 +26,5 @@ namespace pg::interface {
ImGui::SeparatorText("Generator"); ImGui::SeparatorText("Generator");
this->_interface.draw(current_time); 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
...@@ -9,32 +9,38 @@ namespace pg::interface { ...@@ -9,32 +9,38 @@ namespace pg::interface {
: Scene(parent) {} : Scene(parent) {}
void TrajectoryMulty::draw(double current_time) { void TrajectoryMulty::draw(double current_time) {
/*ImGui::ColorEdit4("Curve Color", &this->parent()->_color[0]);
ImGui::Checkbox("Enable Render", &this->parent()->_enableRender);
ImGui::Separator(); ImGui::Separator();
ImGui::Checkbox("Enable Control Line", &this->parent()->_controlLine); ImGui::Checkbox("Enable Control Line", &this->parent()->_controlLine);
ImGui::Checkbox("Enable Control Point", &this->parent()->_enableControl);
ImGui::Checkbox("Enable Curve Line", &this->parent()->_enableLine);
ImGui::Separator(); 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);
}
}*/
size_t color_nb = this->parent()->_colors.size(); size_t color_nb = this->parent()->_colors.size();
size_t i = 0; size_t i = 0;
ImGui::Columns(2);
for(auto &[name, generator] : this->parent()->_generators->getGenerators()) {
ImGui::Text("%s", name.c_str());
}
ImGui::NextColumn();
for(auto &[name, generator] : this->parent()->_generators->getGenerators()) { for(auto &[name, generator] : this->parent()->_generators->getGenerators()) {
size_t index = i%color_nb; size_t index = i%color_nb;
ImGui::Text("%s : ", name.c_str());
ImGui::SameLine();
if(ImGui::ColorEdit4("", &this->parent()->_colors.at(index)[0])) { if(ImGui::ColorEdit4("", &this->parent()->_colors.at(index)[0])) {
this->parent()->update(current_time); this->parent()->update(current_time);
} }
++i; ++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
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
namespace pg::interface { namespace pg::interface {
class PathGenerator; class PathGenerator;
class PathMultyGenerator;
class PathUniqueGenerator;
} }
namespace pg::particle { namespace pg::particle {
...@@ -28,5 +30,7 @@ namespace pg::particle { ...@@ -28,5 +30,7 @@ namespace pg::particle {
inline void setParameterLifeLimitor(float limitor) {this->m_limitor = limitor;} inline void setParameterLifeLimitor(float limitor) {this->m_limitor = limitor;}
friend class pg::interface::PathGenerator; friend class pg::interface::PathGenerator;
friend class pg::interface::PathMultyGenerator;
friend class pg::interface::PathUniqueGenerator;
}; };
} }
\ No newline at end of file
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#include <map> #include <map>
#include <memory> #include <memory>
namespace pg::interface {
class PathMultyGenerator;
};
namespace pg::particle { namespace pg::particle {
class PathMultyGenerator : public PathGenerator { class PathMultyGenerator : public PathGenerator {
private: private:
...@@ -19,5 +23,7 @@ namespace pg::particle { ...@@ -19,5 +23,7 @@ namespace pg::particle {
inline const std::map<std::string, std::unique_ptr<ct::CurveGenerator>> & getGenerators() const {return this->_generators;} 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; 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
...@@ -15,6 +15,7 @@ namespace pg::scene { ...@@ -15,6 +15,7 @@ namespace pg::scene {
_texture(), _texture(),
_generator(ctrlpoint), _generator(ctrlpoint),
_trajectory(&this->_generator), _trajectory(&this->_generator),
_color(1.f),
_interface(this, &this->_generator, &this->_trajectory) { _interface(this, &this->_generator, &this->_trajectory) {
this->_generator.add("Bezier", new ct::BezierGenerator()); this->_generator.add("Bezier", new ct::BezierGenerator());
this->_generator.add("Catmull-Rom", new ct::CatmullRomGenerator()); this->_generator.add("Catmull-Rom", new ct::CatmullRomGenerator());
...@@ -108,7 +109,7 @@ namespace pg::scene { ...@@ -108,7 +109,7 @@ namespace pg::scene {
this->_program.setUniform("uView", VIEW_MATRIX); this->_program.setUniform("uView", VIEW_MATRIX);
this->_program.setUniform("uProj", PROJECTION_MATRIX); this->_program.setUniform("uProj", PROJECTION_MATRIX);
this->_program.setUniform("uSlot", 0); this->_program.setUniform("uSlot", 0);
this->_program.setUniform("uColor", glm::vec4(1.f)); this->_program.setUniform("uColor", this->_color);
pg::error::OpenGLError::check(); pg::error::OpenGLError::check();
......
...@@ -18,6 +18,7 @@ namespace pg::scene { ...@@ -18,6 +18,7 @@ namespace pg::scene {
TrajectoryMulty _trajectory; TrajectoryMulty _trajectory;
Material _texture; Material _texture;
particle::PathMultyGenerator _generator; particle::PathMultyGenerator _generator;
glm::vec4 _color;
interface::MultyPath _interface; interface::MultyPath _interface;
...@@ -40,5 +41,7 @@ namespace pg::scene { ...@@ -40,5 +41,7 @@ namespace pg::scene {
virtual std::optional<interface::Interface *> interface() {return std::optional<interface::Interface *>(&this->_interface);} virtual std::optional<interface::Interface *> interface() {return std::optional<interface::Interface *>(&this->_interface);}
virtual void spawn(int, double); virtual void spawn(int, double);
friend class interface::MultyPath;
}; };
} }
\ No newline at end of file
...@@ -10,6 +10,8 @@ namespace pg::scene { ...@@ -10,6 +10,8 @@ namespace pg::scene {
_pointSize(8.f), _pointSize(8.f),
_lineSize(1.f), _lineSize(1.f),
_controlLine(false), _controlLine(false),
_enableControl(true),
_enableLine(true),
_enableRender(true), _enableRender(true),
_interface(this) {} _interface(this) {}
...@@ -104,10 +106,15 @@ namespace pg::scene { ...@@ -104,10 +106,15 @@ namespace pg::scene {
GLsizei raw = static_cast<GLsizei>(this->_generators->getControlPoint().size()); GLsizei raw = static_cast<GLsizei>(this->_generators->getControlPoint().size());
GLsizei total = static_cast<GLsizei>(this->_vbo.vertices()); GLsizei total = static_cast<GLsizei>(this->_vbo.vertices());
if(this->_enableLine) {
glDrawArrays(GL_LINES, raw, total - raw); 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())); glDrawArrays(this->_controlLine ? GL_LINE_STRIP : GL_POINTS, 0, static_cast<GLsizei>(this->_generators->getControlPoint().size()));
} }
} }
}
void TrajectoryMulty::destroy() { void TrajectoryMulty::destroy() {
......
...@@ -22,8 +22,11 @@ namespace pg::scene { ...@@ -22,8 +22,11 @@ namespace pg::scene {
float _pointSize; float _pointSize;
float _lineSize; float _lineSize;
bool _controlLine; bool _controlLine;
bool _enableControl;
bool _enableLine;
bool _enableRender; bool _enableRender;
interface::TrajectoryMulty _interface; interface::TrajectoryMulty _interface;
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment