diff --git a/ParticleGenerator/res/config/imgui.ini b/ParticleGenerator/res/config/imgui.ini index c470b92e2f94199bc9bc548f02d398d333414d02..17856c7f8cbbc54b9bb374fa559f0284303e49f5 100644 --- a/ParticleGenerator/res/config/imgui.ini +++ b/ParticleGenerator/res/config/imgui.ini @@ -4,5 +4,5 @@ Size=400,400 [Window][Particle Generator] Pos=60,60 -Size=848,714 +Size=733,329 diff --git a/ParticleGenerator/src/Interface/Scene/SceneParticle.cpp b/ParticleGenerator/src/Interface/Scene/SceneParticle.cpp index 52a7e85d36ec5cbaea5452bf0eb4f4fdd280965d..0f7a62dba8b3dc18bbcfe789bbbc1739456c18a7 100644 --- a/ParticleGenerator/src/Interface/Scene/SceneParticle.cpp +++ b/ParticleGenerator/src/Interface/Scene/SceneParticle.cpp @@ -47,5 +47,6 @@ namespace pg::interface { ImGui::Checkbox("Enable Spawning", &this->_scene->_enableSpawn); ImGui::Checkbox("Enable Rendering", &this->_scene->_enableRender); ImGui::Checkbox("Freezing", &this->_scene->_enableFreeze); + ImGui::Checkbox("Wireframe", &this->_scene->_enableWireframe); } } \ No newline at end of file diff --git a/ParticleGenerator/src/Mesh/Skybox.hpp b/ParticleGenerator/src/Mesh/Skybox.hpp index 888ec04bcc133e2e2751a386db094383ae7ea413..458f305fcec36a7fcbbcd21ac9238cb6ca63c00c 100644 --- a/ParticleGenerator/src/Mesh/Skybox.hpp +++ b/ParticleGenerator/src/Mesh/Skybox.hpp @@ -18,8 +18,7 @@ namespace pg { public: - SkyBox() = delete; - SkyBox(const std::string &, const std::string &); + SkyBox(const std::string & = "res/shaders/system/Skybox.vert", const std::string & = "res/shaders/system/Skybox.frag"); inline const CubemapMaterial & material() const {return this->_material;} diff --git a/ParticleGenerator/src/Scene/Scene.cpp b/ParticleGenerator/src/Scene/Scene.cpp index 5e8ded00c7f5c0e90567ce02d68a0bfc0fe9fb88..14ce37b7712f024b874d87d8507b0716a68df8fd 100644 --- a/ParticleGenerator/src/Scene/Scene.cpp +++ b/ParticleGenerator/src/Scene/Scene.cpp @@ -2,5 +2,5 @@ namespace pg::scene { SceneParticle::SceneParticle(int max) - : Scene(), _max(max), _spawn(1), _frequence(500), _lifetime(5), _enableRender(true), _enableSpawn(true), _enableFreeze(false) {} + : Scene(), _max(max), _spawn(1), _frequence(500), _lifetime(5), _enableRender(true), _enableSpawn(true), _enableFreeze(false), _enableWireframe(false) {} } \ No newline at end of file diff --git a/ParticleGenerator/src/Scene/Scene.hpp b/ParticleGenerator/src/Scene/Scene.hpp index f3bb177b7255850de4b19ad3d72d21264be60242..a37777efd74d92de917f40365eb5cbb8107fea0b 100644 --- a/ParticleGenerator/src/Scene/Scene.hpp +++ b/ParticleGenerator/src/Scene/Scene.hpp @@ -35,6 +35,7 @@ namespace pg::scene { bool _enableRender; bool _enableSpawn; bool _enableFreeze; + bool _enableWireframe; protected: ParticleContainer _particles; @@ -48,9 +49,10 @@ namespace pg::scene { inline int getSpawnCount() const {return this->_spawn;} inline int getSpawnFrequence() const {return this->_frequence;} inline int getLifetime() const {return this->_lifetime;} - inline bool isRenderEnable() {return this->_enableRender;} - inline bool isSpawnEnable() {return this->_enableSpawn;} - inline bool isFreezeEnable() {return this->_enableFreeze;} + inline bool isRenderEnable() const {return this->_enableRender;} + inline bool isSpawnEnable() const {return this->_enableSpawn;} + inline bool isFreezeEnable() const {return this->_enableFreeze;} + inline bool isWireframeEnable() const {return this->_enableWireframe;} inline void setSpawnCount(int sc) {this->_spawn = sc;} inline void setSpawnFrequence(int sf) {this->_frequence = sf;} diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp index 4f8228b67c53d65f4d7b17f53c25f92ba2e8b17e..6035e000386e9342ce654ff3c2bca32899f74615 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp @@ -26,6 +26,15 @@ namespace pg::scene { this->changeMesh("res/models/sphere.obj"); } + this->_skybox.load({ + "res/textures/skybox/snow/right.png", + "res/textures/skybox/snow/left.png", + "res/textures/skybox/snow/top.png", + "res/textures/skybox/snow/bottom.png", + "res/textures/skybox/snow/front.png", + "res/textures/skybox/snow/back.png" + }, Texture::AUTO, false); + if(!this->_meshProgram.usable()) { Source vert("res/shaders/scene/Color.vert", Source::Categorie::VERTEX); Source frag("res/shaders/scene/Color.frag", Source::Categorie::FRAGMENT); @@ -98,6 +107,8 @@ namespace pg::scene { // -------- + this->_skybox.draw(camera); + this->_meshProgram.use(); glm::mat4 model = glm::mat4(1.f); @@ -144,16 +155,16 @@ namespace pg::scene { pg::error::OpenGLError::check(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); if(this->isRenderEnable()) { this->_billboard.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); particle_accumulator += 1024; } - - // -------- } void MeshGenerator::destroy() { diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp index d5382bcae02c6ee70b73af9ba1f42ddac79e2898..aab0596bb2a056a0f97a7de446ad4f23eb82639b 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp @@ -6,6 +6,7 @@ #include <memory> #include "../../Mesh/Mesh.hpp" +#include "../../Mesh/Skybox.hpp" #include "../../Mesh/Billboard.hpp" #include "../../Renderer/Renderer.hpp" #include "../../Particle/generator/PhysicsGenerator.hpp" @@ -15,6 +16,7 @@ namespace pg::scene { class MeshGenerator : public SceneParticle { private: Mesh _mesh; + SkyBox _skybox; Program _meshProgram; glm::vec3 _meshPosition; glm::vec3 _meshRotation; diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.cpp b/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.cpp index 8803b22641da69a205559b84c0d72b964c5b864c..978742cfb8f25742b0e413344e599bdfaeaf79f5 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.cpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.cpp @@ -26,6 +26,15 @@ namespace pg::scene { this->changeMesh("res/models/sphere.obj"); } + this->_skybox.load({ + "res/textures/skybox/snow/right.png", + "res/textures/skybox/snow/left.png", + "res/textures/skybox/snow/top.png", + "res/textures/skybox/snow/bottom.png", + "res/textures/skybox/snow/front.png", + "res/textures/skybox/snow/back.png" + }, Texture::AUTO, false); + if(!this->_meshParticle.isGenerated()) { this->changeMeshParticle("res/models/sphere.obj"); } @@ -116,8 +125,6 @@ namespace pg::scene { pg::error::OpenGLError::check(); - // -------- - size_t particle_accumulator = 0; while(particle_accumulator < this->_particles.size()) { std::vector<glm::mat4> models; @@ -142,9 +149,11 @@ namespace pg::scene { pg::error::OpenGLError::check(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); if(this->isRenderEnable()) { this->_meshParticle.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.hpp b/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.hpp index 11ee44f92f71a426086423a6142b9540a43db119..4fd1a63edb1703365b882e237049a5307a28b031 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGeneratorModel.hpp @@ -6,6 +6,7 @@ #include <memory> #include "../../Mesh/Mesh.hpp" +#include "../../Mesh/Skybox.hpp" #include "../../Mesh/Billboard.hpp" #include "../../Renderer/Renderer.hpp" #include "../../Particle/generator/PhysicsGenerator.hpp" @@ -21,6 +22,7 @@ namespace pg::scene { private: Mesh _mesh; Program _meshProgram; + SkyBox _skybox; glm::vec3 _meshPosition; glm::vec3 _meshRotation; diff --git a/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp b/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp index cc920a0ed90424c838312fde7c1281a83fe911ae..bd724d0ef4726578231ff6623715605f1df2299e 100644 --- a/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp +++ b/ParticleGenerator/src/Scene/Scenes/MultyPath.cpp @@ -23,6 +23,15 @@ namespace pg::scene { } void MultyPath::initialize() { + this->_skybox.load({ + "res/textures/skybox/snow/right.png", + "res/textures/skybox/snow/left.png", + "res/textures/skybox/snow/top.png", + "res/textures/skybox/snow/bottom.png", + "res/textures/skybox/snow/front.png", + "res/textures/skybox/snow/back.png" + }, Texture::AUTO, false); + this->_billboard.initialize(); this->_trajectory.initialize(); if(!this->_program.usable()) { @@ -88,6 +97,8 @@ namespace pg::scene { const glm::mat4 VIEW_MATRIX = camera.getViewMatrix(); const glm::mat4 PROJECTION_MATRIX = camera.getViewFrustum().getProjectionMatrix(); + this->_skybox.draw(camera); + this->_trajectory.render(camera, current_time); pg::error::OpenGLError::check(); @@ -113,10 +124,12 @@ namespace pg::scene { pg::error::OpenGLError::check(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); this->_texture.bind(); if(this->isRenderEnable()) { this->_billboard.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); } diff --git a/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp b/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp index 37ec50dac3d5b964f2a91d25f2765dfae5d18f83..0611464e360b4db25872ab4ed53f33d011046b71 100644 --- a/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MultyPath.hpp @@ -3,6 +3,7 @@ #include "../Scene.hpp" #include "../../Renderer/Renderer.hpp" +#include "../../Mesh/Skybox.hpp" #include "../../Particle/generator/PathMultyGenerator.hpp" #include "../../Mesh/Billboard.hpp" #include "TrajectoryMulty.hpp" @@ -12,6 +13,7 @@ namespace pg::scene { class MultyPath : public SceneParticle { private: + SkyBox _skybox; GLuint _ubo; Program _program; Billboard _billboard; diff --git a/ParticleGenerator/src/Scene/Scenes/Path.cpp b/ParticleGenerator/src/Scene/Scenes/Path.cpp index 26d7798ba3532be85dfc04a921ac7931524b3702..015c7f79d2dbafd36d65ea414a27ff99186b5e52 100644 --- a/ParticleGenerator/src/Scene/Scenes/Path.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Path.cpp @@ -10,7 +10,7 @@ namespace pg::scene { _program(), _texture(), _generator(generator, ctrlpoint), - _trajectory(&this->_generator), + _trajectory(&this->_generator, 0.01), _color(1.f), _interface(this, &this->_generator, &this->_trajectory) {} @@ -104,10 +104,12 @@ namespace pg::scene { pg::error::OpenGLError::check(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); this->_texture.bind(); if(this->isRenderEnable()) { this->_billboard.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); } diff --git a/ParticleGenerator/src/Scene/Scenes/PathAnimated.cpp b/ParticleGenerator/src/Scene/Scenes/PathAnimated.cpp index 0a4d599684bfe2226a366bdd9fb36d45024ad76b..0f659ca35e08efb6ced36ce5715f8feed78988bf 100644 --- a/ParticleGenerator/src/Scene/Scenes/PathAnimated.cpp +++ b/ParticleGenerator/src/Scene/Scenes/PathAnimated.cpp @@ -130,10 +130,12 @@ namespace pg::scene { pg::error::OpenGLError::check(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); this->_texture.bind(); if(this->isRenderEnable()) { this->_mesh.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); glDisable(GL_DEPTH_TEST); diff --git a/ParticleGenerator/src/Scene/Scenes/PathPregenerated.cpp b/ParticleGenerator/src/Scene/Scenes/PathPregenerated.cpp index f1c4c2e7bed17cb3e2050603c737aee009b3712b..e650136bf0fa9fb0b9b7b06f7fe4b0afc8815daf 100644 --- a/ParticleGenerator/src/Scene/Scenes/PathPregenerated.cpp +++ b/ParticleGenerator/src/Scene/Scenes/PathPregenerated.cpp @@ -104,9 +104,11 @@ namespace pg::scene { pg::error::OpenGLError::check(); this->_texture.bind(); + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); if(this->isRenderEnable()) { this->_billboard.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); } diff --git a/ParticleGenerator/src/Scene/Scenes/Physic.cpp b/ParticleGenerator/src/Scene/Scenes/Physic.cpp index 132bfb3bc254cf77d19f3e1c5a6181f9762cd6b7..d48f2b92cf051375dd5e8fd2a93c936ece288043 100644 --- a/ParticleGenerator/src/Scene/Scenes/Physic.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Physic.cpp @@ -98,10 +98,11 @@ namespace pg::scene { this->_program.setUniform("uColor", this->_color); pg::error::OpenGLError::check(); - + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); if(this->isRenderEnable()) { this->_billboards.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); } diff --git a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp index dfb35fd2d188fea8d3eb657a3193bbad478c5de7..a7c5503aa54ac4c6e8191b226a48a06870e664fa 100644 --- a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp +++ b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp @@ -109,10 +109,11 @@ namespace pg::scene { this->_program.setUniform("uColor", this->_color); pg::error::OpenGLError::check(); - + glPolygonMode(GL_FRONT_AND_BACK, this->isWireframeEnable() ? GL_LINE : GL_FILL); if(this->isRenderEnable()) { this->_billboards.draw(this->_particles.size()); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pg::error::OpenGLError::check(); }