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

Add interface for MeshGeneratorModel scene

parent 15e848a0
No related branches found
No related tags found
No related merge requests found
......@@ -2,13 +2,12 @@
Pos=60,60
Size=400,400
[Window][Particle Generator]
Pos=60,60
Size=704,561
[Window][Dear ImGui Demo]
Pos=1051,35
Pos=971,50
Size=550,680
Collapsed=1
[Window][Particle Generator]
Pos=7,9
Size=476,521
Collapsed=1
#include "MeshGeneratorModel.hpp"
#include <imgui.h>
#include "../../Scene/Scenes/MeshGeneratorModel.hpp"
#include "../../tfd/tinyfiledialogs.h"
namespace pg::interface {
MeshGeneratorModel::MeshGeneratorModel(scene::MeshGeneratorModel * parent)
: Scene(parent), SceneParticle(parent), _interface(nullptr) {}
void MeshGeneratorModel::draw(double current_time) {
SceneParticle::draw(current_time);
ImGui::SeparatorText("Mesh");
if(ImGui::Button("Change Model")) {
char const * imagePatterns[1] = {"*.obj"};
std::string path = tinyfd_openFileDialog("Model Browser", "", 1, imagePatterns, "Model File", false);
this->parent()->changeMesh(path);
}
ImGui::SeparatorText("Particles");
ImGui::PushID(1);
if(ImGui::Button("Change Model")) {
char const * imagePatterns[1] = {"*.obj"};
std::string path = tinyfd_openFileDialog("Model Browser", "", 1, imagePatterns, "Model File", false);
this->parent()->changeMeshParticle(path);
}
ImGui::SameLine();
if(ImGui::Button("Texture")) {
char const * imagePatterns[1] = {"*.png"};
std::string path = tinyfd_openFileDialog("Model Browser", "", 1, imagePatterns, "Image File", false);
this->parent()->changeTexture(path);
}
ImGui::SameLine();
ImGui::ColorEdit4("Color : ", &this->parent()->_color[0]);
ImGui::SeparatorText("Position");
ImGui::DragFloat3("Position", &this->parent()->_meshPosition[0]);
ImGui::DragFloat3("Rotation", &this->parent()->_meshRotation[0]);
ImGui::PopID();
ImGui::SeparatorText("Generators");
if(!this->parent()->_generators.empty()) {
std::string name = std::to_string(reinterpret_cast<intptr_t>(&this->parent()->_generators.front()));
if(this->_interface.parent() != nullptr) {
name = std::to_string(reinterpret_cast<intptr_t>(this->_interface.parent()));
}
if(ImGui::BeginCombo("Current Generator", name.c_str())) {
for(auto & generator : this->parent()->_generators) {
bool is_selected = std::to_string(reinterpret_cast<intptr_t>(&generator)) == std::to_string(reinterpret_cast<intptr_t>(this->_interface.parent()));
if(ImGui::Selectable(std::to_string(reinterpret_cast<intptr_t>(&generator)).c_str(), is_selected)) {
this->_interface.setParent(&generator);
}
if (is_selected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
}
this->_interface.draw(current_time);
}
}
\ No newline at end of file
#pragma once
#include "../Interface.hpp"
#include "SceneParticle.hpp"
#include "../Generator/PhysicGenerator.hpp"
namespace pg::scene {
class MeshGeneratorModel;
}
namespace pg::interface {
class MeshGeneratorModel : public Scene<scene::MeshGeneratorModel>, public SceneParticle {
private:
PhysicGenerator _interface;
public:
MeshGeneratorModel(scene::MeshGeneratorModel *);
virtual ~MeshGeneratorModel() = default;
void draw(double = 0.0) override;
inline std::string title() const override final {return "Mesh Generator Model Scene Interface";}
};
}
\ No newline at end of file
......@@ -18,7 +18,8 @@ namespace pg::scene {
_meshParticleTexture(),
_meshParticleProgram(),
_ubo(0),
_color(1.f) {}
_color(1.f),
_interface(this) {}
void MeshGeneratorModel::initialize() {
if(!this->_mesh.isGenerated()) {
......
......@@ -10,6 +10,12 @@
#include "../../Renderer/Renderer.hpp"
#include "../../Particle/generator/PhysicsGenerator.hpp"
#include "../../Interface/Scene/MeshGeneratorModel.hpp"
namespace pg::interface {
class MeshGeneratorModel;
}
namespace pg::scene {
class MeshGeneratorModel : public SceneParticle {
private:
......@@ -25,6 +31,8 @@ namespace pg::scene {
GLuint _ubo;
glm::vec4 _color;
interface::MeshGeneratorModel _interface;
public:
MeshGeneratorModel();
virtual ~MeshGeneratorModel() = default;
......@@ -34,12 +42,15 @@ namespace pg::scene {
virtual void render(const Camera &, double);
virtual void destroy();
virtual std::string name() const {return "Mesh Generator Model Scene";};
virtual std::string name() const {return "Mesh Generator Model Scene";}
virtual std::optional<interface::Interface *> interface() {return std::optional<interface::Interface *>(&this->_interface);}
void changeMesh(const std::string &);
void changeMeshParticle(const std::string &);
void changeTexture(const std::string &);
void spawn(int count, double current_time);
friend class interface::MeshGeneratorModel;
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment