From cc68450ab525b8c63b4306f2ae1c3bcf1c42f1b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9au?= <theau.baton@etu.univ-amu.fr>
Date: Mon, 20 May 2024 14:44:37 +0200
Subject: [PATCH] Add rotation on path particle generator

---
 .../Interface/Generator/PathGeneratorInterface.cpp    |  1 +
 .../src/Particle/generator/PathParticleGenerator.cpp  | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp b/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp
index 1661a22..6f712d1 100644
--- a/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp
+++ b/ParticleGenerator/src/Interface/Generator/PathGeneratorInterface.cpp
@@ -23,6 +23,7 @@ namespace pg {
 
         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");
         }
 
diff --git a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp b/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp
index cb69211..009867c 100644
--- a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp
+++ b/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp
@@ -2,6 +2,9 @@
 
 #include <random>
 
+#define GLM_ENABLE_EXPERIMENTAL
+#include <glm/gtx/rotate_vector.hpp>
+
 namespace pg {
 	PathParticleGenerator::PathParticleGenerator(ct::CurveGenerator * generator, const ct::Curve& controlPoints, const ct::Point& position, float positionVariation) 
 	: ParticleGenerator(position, positionVariation), m_generator(generator), m_controlPoints(), m_u(0.0), m_spacing(0.0), m_increment(0.0) {
@@ -22,7 +25,13 @@ namespace pg {
 
 		std::vector<ct::Point> realCtrlPoint;
 		for(auto & point : m_controlPoints) {
-			realCtrlPoint.push_back(point + ct::Point(m_position));
+			glm::dvec3 glmPoint = point; 
+
+			glmPoint = glm::rotateZ<double>(glmPoint, glm::radians<double>(this->m_rotation.z));
+			glmPoint = glm::rotateY<double>(glmPoint, glm::radians<double>(this->m_rotation.y));
+			glmPoint = glm::rotateX<double>(glmPoint, glm::radians<double>(this->m_rotation.x));
+			
+			realCtrlPoint.push_back(glmPoint + ct::Point(m_position));
 		}
 
 		double u_space = 0.0;
-- 
GitLab