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

Add SpritePhysicScene

parent ef4888f9
No related branches found
No related tags found
No related merge requests found
Showing
with 300 additions and 191 deletions
......@@ -2,7 +2,11 @@
Pos=60,60
Size=400,400
[Window][Dear ImGui Demo]
Pos=891,315
Size=550,680
[Window][Particle Generator]
Pos=60,60
Size=838,505
Size=263,184
File added
#version 330 core
out vec4 FragColor;
in vec2 zTex;
in vec4 zFrame;
uniform sampler2D uTexture;
uniform vec2 uSize;
uniform vec4 uColor;
void main() {
vec2 coord = vec2(
(zFrame.x / uSize.x) + (zFrame.z / uSize.x) * zTex.x,
(zFrame.y / uSize.y) + (zFrame.w / uSize.y) * zTex.y
);
FragColor = texture(uTexture, coord) * uColor;
}
\ No newline at end of file
#version 460 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTex;
layout(std140) uniform uParticle_t {
mat4 models[512];
vec4 frames[512];
};
uniform mat4 uView;
uniform mat4 uProj;
out vec2 zTex;
out vec4 zFrame;
void main() {
vec3 cameraRight = vec3(uView[0][0], uView[1][0], uView[2][0]);
vec3 cameraUp = vec3(uView[0][1], uView[1][1], uView[2][1]);
vec3 particlePosition = vec3(models[gl_InstanceID][0][3], models[gl_InstanceID][1][3], models[gl_InstanceID][2][3]);
vec2 particleSize = vec2(1.0, 1.0);
vec3 vertexPosition = particlePosition + cameraRight * aPos.x * particleSize.x + cameraUp * aPos.y * particleSize.y;
gl_Position = uProj * uView * models[gl_InstanceID] * vec4(vertexPosition, 1.0);
zTex = aTex;
zFrame = frames[gl_InstanceID];
}
\ No newline at end of file
ParticleGenerator/res/textures/SpriteParticleTest.png

1.62 KiB

ParticleGenerator/res/textures/cube.png

208 B | W: | H:

ParticleGenerator/res/textures/cube.png

208 B | W: | H:

ParticleGenerator/res/textures/cube.png
ParticleGenerator/res/textures/cube.png
ParticleGenerator/res/textures/cube.png
ParticleGenerator/res/textures/cube.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -13,33 +13,29 @@ namespace pg::interface {
_next(0.f, 0.f, 0.f),
_index(0) {}
void PathGenerator::draw(double) {
/*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::Separator();
ImGui::Text("Default u : %f", this->_generator->m_u);
ImGui::Text("u increment : %f", this->_generator->m_increment);
ImGui::Separator();
ImGui::Text("Spacing : %f", this->_generator->m_spacing);
ImGui::Text("Life Limitor : %f", this->_generator->m_limitor);
}
void PathGenerator::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("Default u : %f", this->parent()->m_u);
ImGui::Text("u increment : %f", this->parent()->m_increment);
ImGui::Text("Spacing : %f", this->parent()->m_spacing);
ImGui::Text("Life Limitor : %f", this->parent()->m_limitor);
if(ImGui::CollapsingHeader("Generator Position")) {
ImGui::DragFloat3("Generator Position (x, y, z)", &this->_generator->m_position[0], 0.1f);
ImGui::SliderFloat3("Generator Roation (x, y, z)", &this->_generator->m_rotation[0], -360.f, 360.f);
ImGui::DragFloat("Position Variation", &this->_generator->m_positionVariation, 0.001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Generator Position (x, y, z)", &this->parent()->m_position[0], 0.1f);
ImGui::SliderFloat3("Generator Roation (x, y, z)", &this->parent()->m_rotation[0], -360.f, 360.f);
ImGui::DragFloat("Position Variation", &this->parent()->m_positionVariation, 0.001f, 0.f, 0.f, "%.4f");
}
if(ImGui::CollapsingHeader("Parameter")) {
ImGui::InputFloat("Parameter Default Value", &this->_generator->m_u, 0.1f, 0.5f);
ImGui::DragFloat("Parameter Increment Value", &this->_generator->m_increment, 0.01f);
ImGui::DragFloat("Spacing", &this->_generator->m_spacing, 0.001f);
ImGui::InputFloat("Life Limitor", &this->_generator->m_limitor, 1.0f, 2.0f);
ImGui::InputFloat("Parameter Default Value", &this->parent()->m_u, 0.1f, 0.5f);
ImGui::DragFloat("Parameter Increment Value", &this->parent()->m_increment, 0.01f);
ImGui::DragFloat("Spacing", &this->parent()->m_spacing, 0.001f);
ImGui::InputFloat("Life Limitor", &this->parent()->m_limitor, 1.0f, 2.0f);
}
if(ImGui::CollapsingHeader("Control Points")) {
for(size_t i = 0; i < this->_generator->m_controlPoints.size(); ++i) {
glm::vec3 current = static_cast<glm::vec3>(this->_generator->m_controlPoints[i]);
for(size_t i = 0; i < this->parent()->m_controlPoints.size(); ++i) {
glm::vec3 current = static_cast<glm::vec3>(this->parent()->m_controlPoints[i]);
ImGui::Text("%i : %f / %f / %f.", i, current.x, current.y, current.z);
}
......@@ -50,40 +46,38 @@ namespace pg::interface {
ImGui::TextColored(ImVec4(0.75f, 0.f, 0.f, 1.f), "Negative index !");
}
else {
if(this->_index > this->_generator->getControlPoint().size()) {
if(this->_index > this->parent()->getControlPoint().size()) {
ImGui::TextColored(ImVec4(1.f, 1.f, 0.f, 1.f), "Index out of range, new point will be at the back !");
}
if(ImGui::Button("Push Point")) {
if(this->_index > this->_generator->getControlPoint().size()) {
this->_generator->m_controlPoints.push_back(static_cast<ct::Point>(this->_next));
if(this->_index > this->parent()->getControlPoint().size()) {
this->parent()->m_controlPoints.push_back(static_cast<ct::Point>(this->_next));
}
else {
this->_generator->m_controlPoints.insert(this->_generator->m_controlPoints.begin() + this->_index, static_cast<ct::Point>(this->_next));
this->parent()->m_controlPoints.insert(this->parent()->m_controlPoints.begin() + this->_index, static_cast<ct::Point>(this->_next));
}
if(this->_trajectory != nullptr) {
this->_trajectory->update();
this->_trajectory->update(current_time);
}
}
ImGui::SameLine();
if(ImGui::Button("Pop Point")) {
if(this->_index > this->_generator->getControlPoint().size()) {
this->_generator->m_controlPoints.pop_back();
if(this->_index > this->parent()->getControlPoint().size()) {
this->parent()->m_controlPoints.pop_back();
}
else {
this->_generator->m_controlPoints.erase(this->_generator->m_controlPoints.begin() + this->_index);
this->parent()->m_controlPoints.erase(this->parent()->m_controlPoints.begin() + this->_index);
}
if(this->_trajectory != nullptr) {
this->_trajectory->update();
this->_trajectory->update(current_time);
}
}
}
}
}*/
ImGui::Text("Path Generator : %i", this->parent());
}
}
......@@ -11,50 +11,48 @@ namespace pg::interface {
: Generator(parent) {}
void PhysicGenerator::draw(double) {
/*if(this->_generator == nullptr) {
if(this->parent() == 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::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::SeparatorText("Velocity");
ImGui::Text("X : %f - variation : [%f , %f].", this->_generator->m_velocity.x, this->_generator->m_velocityVariation.lower.x, this->_generator->m_velocityVariation.upper.x);
ImGui::Text("Y : %f - variation : [%f , %f].", this->_generator->m_velocity.y, this->_generator->m_velocityVariation.lower.y, this->_generator->m_velocityVariation.upper.y);
ImGui::Text("Z : %f - variation : [%f , %f].", this->_generator->m_velocity.z, this->_generator->m_velocityVariation.lower.z, this->_generator->m_velocityVariation.upper.z);
ImGui::Text("X : %f - variation : [%f , %f].", this->parent()->m_velocity.x, this->parent()->m_velocityVariation.lower.x, this->parent()->m_velocityVariation.upper.x);
ImGui::Text("Y : %f - variation : [%f , %f].", this->parent()->m_velocity.y, this->parent()->m_velocityVariation.lower.y, this->parent()->m_velocityVariation.upper.y);
ImGui::Text("Z : %f - variation : [%f , %f].", this->parent()->m_velocity.z, this->parent()->m_velocityVariation.lower.z, this->parent()->m_velocityVariation.upper.z);
ImGui::SeparatorText("Acceleration");
ImGui::Text("X : %f - variation : [%f , %f].", this->_generator->m_acceleration.x, this->_generator->m_accelerationVariation.lower.x, this->_generator->m_accelerationVariation.upper.x);
ImGui::Text("Y : %f - variation : [%f , %f].", this->_generator->m_acceleration.y, this->_generator->m_accelerationVariation.lower.y, this->_generator->m_accelerationVariation.upper.y);
ImGui::Text("Z : %f - variation : [%f , %f].", this->_generator->m_acceleration.z, this->_generator->m_accelerationVariation.lower.z, this->_generator->m_accelerationVariation.upper.z);
ImGui::Text("X : %f - variation : [%f , %f].", this->parent()->m_acceleration.x, this->parent()->m_accelerationVariation.lower.x, this->parent()->m_accelerationVariation.upper.x);
ImGui::Text("Y : %f - variation : [%f , %f].", this->parent()->m_acceleration.y, this->parent()->m_accelerationVariation.lower.y, this->parent()->m_accelerationVariation.upper.y);
ImGui::Text("Z : %f - variation : [%f , %f].", this->parent()->m_acceleration.z, this->parent()->m_accelerationVariation.lower.z, this->parent()->m_accelerationVariation.upper.z);
ImGui::SeparatorText("Friction");
ImGui::Text("X : %f - variation : [0 , %f].", this->_generator->m_friction.x, this->_generator->m_frictionVariation.x);
ImGui::Text("Y : %f - variation : [0 , %f].", this->_generator->m_friction.y, this->_generator->m_frictionVariation.y);
ImGui::Text("Z : %f - variation : [0 , %f].", this->_generator->m_friction.z, this->_generator->m_frictionVariation.z);
}
ImGui::Text("X : %f - variation : [0 , %f].", this->parent()->m_friction.x, this->parent()->m_frictionVariation.x);
ImGui::Text("Y : %f - variation : [0 , %f].", this->parent()->m_friction.y, this->parent()->m_frictionVariation.y);
ImGui::Text("Z : %f - variation : [0 , %f].", this->parent()->m_friction.z, this->parent()->m_frictionVariation.z);
if(ImGui::CollapsingHeader("Generator Position")) {
ImGui::DragFloat3("Generator Position (x, y, z)", &this->_generator->m_position[0], 0.1f);
ImGui::SliderFloat3("Generator Roation (x, y, z)", &this->_generator->m_rotation[0], -360.f, 360.f);
ImGui::DragFloat("Position Variation", &this->_generator->m_positionVariation, 0.01f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Generator Position (x, y, z)", &this->parent()->m_position[0], 0.1f);
ImGui::SliderFloat3("Generator Roation (x, y, z)", &this->parent()->m_rotation[0], -360.f, 360.f);
ImGui::DragFloat("Position Variation", &this->parent()->m_positionVariation, 0.01f, 0.f, 0.f, "%.4f");
}
if(ImGui::CollapsingHeader("Generation Settings")) {
ImGui::DragFloat3("Velocity (x, y, z)", &this->_generator->m_velocity[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Acceleration (x, y, z)", &this->_generator->m_acceleration[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Friction (x, y, z)", &this->_generator->m_friction[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Velocity (x, y, z)", &this->parent()->m_velocity[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Acceleration (x, y, z)", &this->parent()->m_acceleration[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Friction (x, y, z)", &this->parent()->m_friction[0], 0.0001f, 0.f, 0.f, "%.4f");
}
if(ImGui::CollapsingHeader("Variation")) {
ImGui::SeparatorText("Velocity");
ImGui::DragFloat3("Upper Boundary (x, y, z)", &this->_generator->m_velocityVariation.upper[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Lower Boundary (x, y, z)", &this->_generator->m_velocityVariation.lower[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Upper Boundary (x, y, z)", &this->parent()->m_velocityVariation.upper[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Lower Boundary (x, y, z)", &this->parent()->m_velocityVariation.lower[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::SeparatorText("Acceleration");
ImGui::PushID(1);
ImGui::DragFloat3("Upper Boundary (x, y, z)", &this->_generator->m_accelerationVariation.upper[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Lower Boundary (x, y, z)", &this->_generator->m_accelerationVariation.lower[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Upper Boundary (x, y, z)", &this->parent()->m_accelerationVariation.upper[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::DragFloat3("Lower Boundary (x, y, z)", &this->parent()->m_accelerationVariation.lower[0], 0.0001f, 0.f, 0.f, "%.4f");
ImGui::PopID();
ImGui::SeparatorText("Friction");
ImGui::DragFloat3("Variation", &this->_generator->m_frictionVariation[0], 0.0001f, 0.f, 0.f, "%.4f");
}*/
ImGui::DragFloat3("Variation", &this->parent()->m_frictionVariation[0], 0.0001f, 0.f, 0.f, "%.4f");
}
ImGui::Text("Physic Generator : %i", this->parent());
}
}
......@@ -42,5 +42,6 @@ namespace pg::interface {
virtual ~Generator() = default;
inline T * parent() const {return this->_parent;}
inline void setParent(T * parent) {this->_parent = parent;}
};
}
\ No newline at end of file
#include "Manager.hpp"
#include "../Scene/Manager.hpp"
#include "Style/Red.hpp"
#include <imgui.h>
#include <imgui_impl_glfw.h>
......@@ -14,6 +15,10 @@ namespace pg::interface {
ImGui_ImplGlfw_InitForOpenGL(window.address(), true);
ImGui_ImplOpenGL3_Init("#version 330 core");
ImGuiStyle & style = ImGui::GetStyle();
style::Red red;
red.apply(style);
}
Manager::~Manager() {
......@@ -29,12 +34,16 @@ namespace pg::interface {
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::ShowDemoWindow();
this->_historical.count(current_time);
if(ImGui::Begin(this->_title.c_str())) {
if(ImGui::CollapsingHeader("Performaces")) {
this->_historical.draw(current_time);
}
auto current = this->_manager.current();
if(ImGui::BeginTabBar("")) {
if(ImGui::BeginTabItem("Scene")) {
if(!this->_manager.getScenes().empty()) {
std::string name = !current.has_value() ? (*this->_manager.getScenes().begin())->name() : (*current)->name();
if(ImGui::BeginCombo("Current Scene", name.c_str())) {
......@@ -46,22 +55,11 @@ namespace pg::interface {
}
ImGui::EndCombo();
}
ImGui::Separator();
}
if(current.has_value() && (*current)->interface().has_value()) {
(*(*current)->interface())->draw(current_time);
}
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Performance")) {
this->_historical.draw(current_time);
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}
ImGui::End();
......
......@@ -9,52 +9,38 @@ namespace pg::interface {
: Scene(parent), SceneParticle(parent), _interface(nullptr) {}
void MeshGenerator::draw(double current_time) {
/*ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max);
ImGui::SameLine();
if(ImGui::Button("Spawn")) {
this->_scene->spawn(1, current_time);
}
ImGui::SameLine();
if(ImGui::Button("Clear")) {
this->_scene->_particles.clear();
}
ImGui::Text("Particles Batchs : %i", static_cast<int>(this->_scene->_particles.size() / 1024) + 1);
ImGui::Separator();
ImGui::Checkbox("Enable Rendering", &this->_enableRender);
ImGui::Checkbox("Enable Spawning", &this->_enableSpawn);
ImGui::Separator();
ImGui::InputInt("Lifetime (s)", &this->_lifetime, 1, 2);
ImGui::InputInt("Spawn Frequence (ms)", &this->_spawnFrequence, 100, 500);
ImGui::SliderInt("Spawning Number", &this->_spawnCount, 1, static_cast<int>(this->_max));
SceneParticle::draw(current_time);
ImGui::SeparatorText("Model");
if(ImGui::Button("Change Model")) {
char const * imagePatterns[1] = {"*.obj"};
std::string path = tinyfd_openFileDialog("Model Browser", "", 1, imagePatterns, "Model File", false);
this->_scene->changeMesh(path);
this->parent()->changeMesh(path);
}
if(ImGui::CollapsingHeader("Global Genrator Parameter")) {
if(ImGui::Button("Apply")) {
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("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(!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->_scene->_generators) {
bool is_selected = std::to_string(reinterpret_cast<intptr_t>(&generator)) == std::to_string(reinterpret_cast<intptr_t>(this->_interface.getGenerator()));
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.setGenerator(&generator);
this->_interface.setParent(&generator);
}
if (is_selected) {
......@@ -64,11 +50,6 @@ namespace pg::interface {
ImGui::EndCombo();
}
}
this->_interface.render(current_time);*/
SceneParticle::draw(current_time);
this->_interface.draw(current_time);
ImGui::Text("Mesh Generator : %i", this->parent());
}
}
\ No newline at end of file
......@@ -6,49 +6,32 @@
#include "../../tfd/tinyfiledialogs.h"
namespace pg::interface {
Path::Path(scene::Path * parent, pg::PathParticleGenerator * generator)
: Scene(parent), SceneParticle(parent), _interface(generator) {}
Path::Path(scene::Path * parent, pg::PathParticleGenerator * generator, pg::scene::Trajectory * trajectory)
: Scene(parent), SceneParticle(parent), _interface(generator, trajectory) {}
void Path::draw(double current_time) {
/*ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max);
ImGui::Checkbox("Enable Rendering", &this->_enableRender);
ImGui::Separator();
ImGui::Checkbox("Enable Spawning", &this->_enableSpawning);
ImGui::SliderInt("Spawning Number", &this->_spawnCount, 1, 1024);
ImGui::InputInt("Spawn Frequence (ms)", &this->_spawnFrequence, 25, 100);
ImGui::Separator();
ImGui::InputInt("Particles Lifetime (s)", &this->_lifetime, 1, 5);
ImGui::ColorEdit4("GlobalColor", &this->_color[0]);
if(ImGui::Button("Clear")) {
this->_scene->_particles.clear();
}
ImGui::SameLine();
if(ImGui::Button("Spawn")) {
std::vector<std::unique_ptr<pg::Particle>> newParticles = this->_scene->_generator.generate(1, static_cast<size_t>(current_time));
this->_scene->_particles.insert(this->_scene->_particles.begin(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end()));
}
SceneParticle::draw(current_time);
ImGui::Separator();
ImGui::SeparatorText("Texture");
if(ImGui::CollapsingHeader("Texture")) {
ImGui::Image((void*)(intptr_t)this->_scene->getTexture().identifier(), ImVec2(256, 256), ImVec2(0, 1), ImVec2(1, 0));
if(ImGui::Button("Change 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 path = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image Files", false);
this->_scene->changeParticletexture(path);
}
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]);
ImGui::SeparatorText("Generator");
this->_interface.render(current_time);*/
SceneParticle::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);
}
ImGui::Text("Path Scene : %i", this->parent());
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "../Interface.hpp"
#include "SceneParticle.hpp"
#include "../Generator/PathGenerator.hpp"
#include "../../Scene/Scenes/Trajectory.hpp"
#include <glm/vec4.hpp>
......@@ -17,7 +18,7 @@ namespace pg::interface {
PathGenerator _interface;
public:
Path(scene::Path *, pg::PathParticleGenerator *);
Path(scene::Path *, pg::PathParticleGenerator *, pg::scene::Trajectory * = nullptr);
virtual ~Path() = default;
virtual void draw(double);
......
......@@ -12,42 +12,21 @@ namespace pg::interface {
: Scene(parent), SceneParticle(parent), _interface(generator) {}
void Physic::draw(double current_time) {
/*ImGui::Text("Particles Number : %i / %i.", this->_scene->_particles.size(), this->_max);
//ImGui::Text("Frame Per Second : %f.", this->_fps);
ImGui::Checkbox("Enable Rendering", &this->_enableRender);
ImGui::Separator();
ImGui::Checkbox("Enable Spawning", &this->_enableSpawning);
ImGui::SliderInt("Spawning Number", &this->_spawnCount, 1, 1024);
ImGui::InputInt("Spawn Frequence (ms)", &this->_spawnFrequence, 25, 100);
ImGui::Separator();
ImGui::InputInt("Particles Lifetime (s)", &this->_lifetime, 1, 5);
ImGui::ColorEdit4("GlobalColor", &this->_color[0]);
if(ImGui::Button("Clear")) {
this->_scene->_particles.clear();
}
ImGui::SameLine();
if(ImGui::Button("Spawn")) {
std::vector<std::unique_ptr<pg::Particle>> newParticles = this->_scene->_generator.generate(1, static_cast<size_t>(current_time));
this->_scene->_particles.insert(this->_scene->_particles.begin(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end()));
}
SceneParticle::draw(current_time);
ImGui::Separator();
ImGui::SeparatorText("Texture");
if(ImGui::CollapsingHeader("Texture")) {
ImGui::Image((void*)(intptr_t)this->_scene->getTexture().identifier(), ImVec2(256, 256), ImVec2(0, 1), ImVec2(1, 0));
if(ImGui::Button("Change 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 path = tinyfd_openFileDialog("Image Browser", "", 1, imagePatterns, "Image File", false);
this->_scene->changeParticletexture(path);
}
this->parent()->changeParticletexture(path);
}
ImGui::SameLine();
ImGui::ColorEdit4("Color", &this->parent()->_color[0]);
ImGui::SeparatorText("Generator");
this->_generator.render(current_time);*/
SceneParticle::draw(current_time);
this->_interface.draw(current_time);
ImGui::Text("Phsyic Interface : %i", this->parent());
}
}
\ No newline at end of file
......@@ -8,8 +8,44 @@ namespace pg::interface {
SceneParticle::SceneParticle(scene::SceneParticle * scene)
: _scene(scene) {}
void SceneParticle::draw(double) {
ImGui::Text("Particule Number : %i / %i", this->_scene->_particles.size(), this->_scene->_max);
ImGui::Text("Scene Particle Interface !");
void SceneParticle::draw(double current_time) {
ImGui::SeparatorText("Scene Particles");
int count = static_cast<int>(this->_scene->_particles.size());
int max = this->_scene->_max;
ImVec2 size = ImGui::GetWindowSize();
ImGui::Bullet();
ImGui::SameLine();
ImVec4 color = ImVec4(1.f, 1.f, 1.f, 1.f);
float pc = static_cast<float>(count) / static_cast<float>(max);
if(pc > 0.9f) {
color = ImVec4(0.75f, 0.15f, 0.15f, 1.f);
}
else if(pc > 0.7f) {
color = ImVec4(0.75f, 0.75f, 0.15f, 1.f);
}
ImGui::TextColored(color, "Particule Number : %i / %i", count, max);
ImGui::ProgressBar(pc);
if(ImGui::Button("Spawn", ImVec2(size.x * 0.5f, 25))) {
this->_scene->spawn(1, current_time);
}
ImGui::SameLine();
if(ImGui::Button("Clear", ImVec2(size.x * 0.5f, 25))) {
this->_scene->_particles.clear();
}
ImGui::SeparatorText("Spawning Settings");
ImGui::SliderInt("Spawning Numbers", &this->_scene->_spawn, 1, max);
ImGui::DragInt("Spawning Frequence (ms)", &this->_scene->_frequence);
ImGui::DragInt("Lifetime", &this->_scene->_lifetime);
ImGui::Checkbox("Enable Spawning", &this->_scene->_enableSpawn);
ImGui::Checkbox("Enable Rendering", &this->_scene->_enableRender);
ImGui::Checkbox("Freezing", &this->_scene->_enableFreeze);
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ namespace pg::scene {
namespace pg::interface {
class SceneParticle : virtual public Interface {
private:
const scene::SceneParticle * _scene;
scene::SceneParticle * _scene;
public:
SceneParticle(scene::SceneParticle *);
......
......@@ -2,11 +2,16 @@
#include <imgui.h>
#include "../../Scene/Scenes/Trajectory.hpp"
namespace pg::interface {
Trajectory::Trajectory(scene::Trajectory * parent)
: Scene(parent) {}
void Trajectory::draw(double) {
ImGui::Text("Trajectory Interface : %i", this->parent());
ImGui::ColorEdit4("Curve Color", &this->parent()->_color[0]);
ImGui::SliderFloat("Point Size", &this->parent()->_pointSize, 1.f, 512.f);
ImGui::SliderFloat("Line Size", &this->parent()->_lineSize, 1.f, 512.f);
ImGui::Checkbox("Show Control Line", &this->parent()->_controlLine);
}
}
\ No newline at end of file
#include "Red.hpp"
namespace pg::interface::style {
void Red::apply(ImGuiStyle & style) const {
// Window Size
style.WindowPadding = ImVec2(10, 5);
style.FramePadding = ImVec2(5, 5);
style.ItemSpacing = ImVec2(10, 2);
style.ItemInnerSpacing = ImVec2(10, 5);
style.FrameBorderSize = 1.f;
style.WindowRounding = 2.f;
style.FrameRounding = 1.f;
style.ScrollbarRounding = 0.f;
style.WindowTitleAlign = ImVec2(0.5f, 0.5f);
style.SeparatorTextAlign = ImVec2(0.5f, 0.5f);
// Window Color
ImVec4 * colors = style.Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.47f, 0.48f, 0.43f, 1.00f);
colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.50f);
colors[ImGuiCol_FrameBg] = ImVec4(0.48f, 0.16f, 0.29f, 0.54f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.98f, 0.26f, 0.36f, 0.40f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.98f, 0.26f, 0.42f, 0.67f);
colors[ImGuiCol_TitleBg] = ImVec4(0.21f, 0.09f, 0.13f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.36f, 0.10f, 0.17f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(1.00f, 0.77f, 0.00f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.98f, 0.26f, 0.40f, 0.40f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.98f, 0.26f, 0.36f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.98f, 0.06f, 0.31f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.98f, 0.26f, 0.50f, 0.31f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.98f, 0.26f, 0.50f, 0.80f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.98f, 0.26f, 0.56f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.75f, 0.10f, 0.37f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.75f, 0.10f, 0.24f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.98f, 0.26f, 0.52f, 0.20f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.98f, 0.26f, 0.60f, 0.67f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.98f, 0.26f, 0.46f, 0.95f);
colors[ImGuiCol_Tab] = ImVec4(0.58f, 0.18f, 0.33f, 0.86f);
colors[ImGuiCol_TabHovered] = ImVec4(0.98f, 0.26f, 0.62f, 0.80f);
colors[ImGuiCol_TabActive] = ImVec4(0.68f, 0.20f, 0.37f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.15f, 0.07f, 0.11f, 0.97f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.42f, 0.14f, 0.29f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 0.97f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.84f, 0.84f, 0.20f, 0.78f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.98f, 0.26f, 0.62f, 0.35f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.98f, 0.26f, 0.65f, 1.00f);
}
}
\ No newline at end of file
#pragma once
#include "Style.hpp"
namespace pg::interface::style {
class Red : public Style {
public:
Red() = default;
virtual ~Red() = default;
void apply(ImGuiStyle &) const override;
inline std::string name() const {return "Red";}
};
}
\ No newline at end of file
#pragma once
#include <string>
#include <imgui.h>
namespace pg::interface::style {
class Style {
public:
Style() = default;
virtual ~Style() = default;
virtual void apply(ImGuiStyle &) const = 0;
virtual std::string name() const = 0;
};
}
\ 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