diff --git a/ParticleGenerator/res/config/imgui.ini b/ParticleGenerator/res/config/imgui.ini index 36effb4dfb9021f787afd278a3c641a86ae0c1bb..2debb9c1f584f73decc8c1256714d66791c3523c 100644 --- a/ParticleGenerator/res/config/imgui.ini +++ b/ParticleGenerator/res/config/imgui.ini @@ -2,11 +2,12 @@ Pos=60,60 Size=400,400 -[Window][Dear ImGui Demo] -Pos=891,315 -Size=550,680 - [Window][Particle Generator] -Pos=60,60 -Size=263,184 +Pos=86,73 +Size=848,814 + +[Window][Dear ImGui Demo] +Pos=984,78 +Size=598,693 +Collapsed=1 diff --git a/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp b/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp index 188915407ac088b51884bb1c1c3107ad82935c34..887f7a097a5247927e268f1010374d4cd87c8cf0 100644 --- a/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp +++ b/ParticleGenerator/src/Interface/Generator/PathGenerator.cpp @@ -4,10 +4,10 @@ #include <imgui.h> -#include "../../Particle/generator/PathParticleGenerator.hpp" +#include "../../Particle/generator/PathGenerator.hpp" namespace pg::interface { - PathGenerator::PathGenerator(PathParticleGenerator * parent, scene::Trajectory * trajectory) + PathGenerator::PathGenerator(particle::PathGenerator * parent, scene::Trajectory * trajectory) : Generator(parent), _trajectory(trajectory), _next(0.f, 0.f, 0.f), diff --git a/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp index d1f480fe3eeb76ba56ddcb1fd1b0b91ef5791db8..01c6f58b1e07f85bc20fda74f8615bb65724a53b 100644 --- a/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp +++ b/ParticleGenerator/src/Interface/Generator/PathGenerator.hpp @@ -5,12 +5,12 @@ #include <glm/vec3.hpp> -namespace pg { - class PathParticleGenerator; +namespace pg::particle { + class PathGenerator; } namespace pg::interface { - class PathGenerator : public Generator<pg::PathParticleGenerator> { + class PathGenerator : public Generator<particle::PathGenerator> { private: scene::Trajectory * _trajectory; @@ -18,7 +18,7 @@ namespace pg::interface { int _index; public: - PathGenerator(PathParticleGenerator *, scene::Trajectory * = nullptr); + PathGenerator(particle::PathGenerator *, scene::Trajectory * = nullptr); virtual ~PathGenerator() = default; void draw(double) override; diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp index cf3cdb0114b86869d3e2b733b9a61e5d1ed34870..3f704e5cc603eced90798af087ccf215fc7fbef3 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.cpp @@ -4,10 +4,10 @@ #include <imgui.h> -#include "../../Particle/generator/PhysicsParticleGenerator.hpp" +#include "../../Particle/generator/PhysicsGenerator.hpp" namespace pg::interface { - PhysicGenerator::PhysicGenerator(pg::PhysicsParticleGenerator * parent) + PhysicGenerator::PhysicGenerator(particle::PhysicsGenerator * parent) : Generator(parent) {} void PhysicGenerator::draw(double) { diff --git a/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp index 4ec81519d83b74c48712a3093ed9455e36a8f1a6..1c1204b9df681f37f45a6ed3ca581d90545327f9 100644 --- a/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp +++ b/ParticleGenerator/src/Interface/Generator/PhysicGenerator.hpp @@ -2,14 +2,14 @@ #include "../Interface.hpp" -namespace pg { - class PhysicsParticleGenerator; +namespace pg::particle { + class PhysicsGenerator; } namespace pg::interface { - class PhysicGenerator : public Generator<pg::PhysicsParticleGenerator> { + class PhysicGenerator : public Generator<particle::PhysicsGenerator> { public: - PhysicGenerator(pg::PhysicsParticleGenerator *); + PhysicGenerator(particle::PhysicsGenerator *); virtual void draw(double = 0.0); inline std::string title() const {return "Physic Generator Interface";} diff --git a/ParticleGenerator/src/Interface/Scene/Path.cpp b/ParticleGenerator/src/Interface/Scene/Path.cpp index 93678aa620878cc089b4292c79c3252ff9c9091e..e6981583a59bec0c8e45ec35e6537b8397a547d9 100644 --- a/ParticleGenerator/src/Interface/Scene/Path.cpp +++ b/ParticleGenerator/src/Interface/Scene/Path.cpp @@ -6,7 +6,7 @@ #include "../../tfd/tinyfiledialogs.h" namespace pg::interface { - Path::Path(scene::Path * parent, pg::PathParticleGenerator * generator, pg::scene::Trajectory * trajectory) + Path::Path(scene::Path * parent, particle::PathGenerator * generator, scene::Trajectory * trajectory) : Scene(parent), SceneParticle(parent), _interface(generator, trajectory) {} void Path::draw(double current_time) { diff --git a/ParticleGenerator/src/Interface/Scene/Path.hpp b/ParticleGenerator/src/Interface/Scene/Path.hpp index edd89764fe6ad88937b8bcde62ff79398234b5e6..6359ed4546f847d9b9a1fe0aaf90bcf926fea6b3 100644 --- a/ParticleGenerator/src/Interface/Scene/Path.hpp +++ b/ParticleGenerator/src/Interface/Scene/Path.hpp @@ -18,7 +18,7 @@ namespace pg::interface { PathGenerator _interface; public: - Path(scene::Path *, pg::PathParticleGenerator *, pg::scene::Trajectory * = nullptr); + Path(scene::Path *, particle::PathGenerator *, pg::scene::Trajectory * = nullptr); virtual ~Path() = default; virtual void draw(double); diff --git a/ParticleGenerator/src/Interface/Scene/Physic.cpp b/ParticleGenerator/src/Interface/Scene/Physic.cpp index 4981e663b7e71239b22e6918f527a223f37c1c62..8f5e9756b029159ce69fcb11381693d2556affce 100644 --- a/ParticleGenerator/src/Interface/Scene/Physic.cpp +++ b/ParticleGenerator/src/Interface/Scene/Physic.cpp @@ -8,7 +8,7 @@ #include <iostream> namespace pg::interface { - Physic::Physic(scene::Physic * parent, pg::PhysicsParticleGenerator * generator) + Physic::Physic(scene::Physic * parent, particle::PhysicsGenerator * generator) : Scene(parent), SceneParticle(parent), _interface(generator) {} void Physic::draw(double current_time) { diff --git a/ParticleGenerator/src/Interface/Scene/Physic.hpp b/ParticleGenerator/src/Interface/Scene/Physic.hpp index 9db411c8a79d4f5c10f83bcbce17322b3b752274..cbb7f65f59067303150de2f5f1678a04c16a1d1f 100644 --- a/ParticleGenerator/src/Interface/Scene/Physic.hpp +++ b/ParticleGenerator/src/Interface/Scene/Physic.hpp @@ -3,7 +3,7 @@ #include "../Interface.hpp" #include "SceneParticle.hpp" #include "../Generator/PhysicGenerator.hpp" -#include "../../Particle/generator/PhysicsParticleGenerator.hpp" +#include "../../Particle/generator/PhysicsGenerator.hpp" #include <glm/vec4.hpp> @@ -17,7 +17,7 @@ namespace pg::interface { PhysicGenerator _interface; public: - Physic(scene::Physic *, pg::PhysicsParticleGenerator *); + Physic(scene::Physic *, particle::PhysicsGenerator *); virtual ~Physic() = default; virtual void draw(double); diff --git a/ParticleGenerator/src/Particle/Particle.cpp b/ParticleGenerator/src/Particle/Particle.cpp index bd2ba6e20b604810b09438215221d6a50c966c9e..344eb48f90976a8bd292a9cea31073c0b35e704f 100644 --- a/ParticleGenerator/src/Particle/Particle.cpp +++ b/ParticleGenerator/src/Particle/Particle.cpp @@ -2,7 +2,7 @@ #include <chrono> -namespace pg { +namespace pg::particle { Particle::Particle(const ct::Point& position) : Particle(0, position) {} diff --git a/ParticleGenerator/src/Particle/Particle.hpp b/ParticleGenerator/src/Particle/Particle.hpp index 1f6097e0e480df1b0ce6fb3ad1b33de39f0a9e3c..0d0ef5529442f86b1be98bcc1a82684ae9dedfef 100644 --- a/ParticleGenerator/src/Particle/Particle.hpp +++ b/ParticleGenerator/src/Particle/Particle.hpp @@ -5,7 +5,7 @@ #include <CurveTools/CPU/CurveGenerator.hpp> -namespace pg +namespace pg::particle { class Particle { diff --git a/ParticleGenerator/src/Particle/PathParticle.cpp b/ParticleGenerator/src/Particle/Path.cpp similarity index 59% rename from ParticleGenerator/src/Particle/PathParticle.cpp rename to ParticleGenerator/src/Particle/Path.cpp index cc6682e794b41cc166121939004771e748eb7875..35b714c09c54811c5a01f98cc5bd10033ef52fa5 100644 --- a/ParticleGenerator/src/Particle/PathParticle.cpp +++ b/ParticleGenerator/src/Particle/Path.cpp @@ -1,9 +1,9 @@ -#include "PathParticle.hpp" +#include "Path.hpp" #include <iostream> -namespace pg { - PathParticle::PathParticle(ct::CurveGenerator* generator, const ct::Curve& path, double u, double inc) +namespace pg::particle { + Path::Path(ct::CurveGenerator* generator, const ct::Curve& path, double u, double inc) : Particle(), m_generator(generator), m_ctrlPoints(path), m_positionVariation(), m_u(u), m_increment(inc), m_limitor(0.0) { if(!path.empty()) { @@ -11,13 +11,13 @@ namespace pg { } } - PathParticle::PathParticle(size_t birth, ct::CurveGenerator* generator, const ct::Curve& controlPoints, double u, double inc) - : PathParticle(generator, controlPoints, u, inc) + Path::Path(size_t birth, ct::CurveGenerator* generator, const ct::Curve& controlPoints, double u, double inc) + : Path(generator, controlPoints, u, inc) { this->setBorn(birth); } - void PathParticle::update(double delta) + void Path::update(double delta) { this->m_u += this->m_increment; diff --git a/ParticleGenerator/src/Particle/PathParticle.hpp b/ParticleGenerator/src/Particle/Path.hpp similarity index 77% rename from ParticleGenerator/src/Particle/PathParticle.hpp rename to ParticleGenerator/src/Particle/Path.hpp index f149275e747cbd6866423ae34152c572bd00f8fb..5803191bce1baaae77c0d747ea847bb0cf0270b6 100644 --- a/ParticleGenerator/src/Particle/PathParticle.hpp +++ b/ParticleGenerator/src/Particle/Path.hpp @@ -3,8 +3,8 @@ #include "Particle.hpp" #include <CurveTools/CPU/CurveGenerator.hpp> -namespace pg { - class PathParticle : public Particle +namespace pg::particle { + class Path : public Particle { private: ct::CurveGenerator* m_generator; @@ -13,8 +13,8 @@ namespace pg { double m_u, m_increment, m_limitor; public: - PathParticle(size_t birth, ct::CurveGenerator* generator, const ct::Curve& controlPoints, double u = 0.0, double inc = 0.0); - PathParticle(ct::CurveGenerator* generator, const ct::Curve& path, double u = 0.0, double inc = 0.0); + Path(size_t birth, ct::CurveGenerator* generator, const ct::Curve& controlPoints, double u = 0.0, double inc = 0.0); + Path(ct::CurveGenerator* generator, const ct::Curve& path, double u = 0.0, double inc = 0.0); inline const ct::Curve & getControlPoints() const {return this->m_ctrlPoints;} inline glm::dvec3 getPositionVariation() const {return m_positionVariation;} diff --git a/ParticleGenerator/src/Particle/Physics.cpp b/ParticleGenerator/src/Particle/Physics.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2fff0f0676df019d44e1fc1464e428435f2cd52 --- /dev/null +++ b/ParticleGenerator/src/Particle/Physics.cpp @@ -0,0 +1,16 @@ +#include "Physics.hpp" + +namespace pg::particle { + Physics::Physics(size_t birth, const ct::Point& position, const glm::dvec3& velocity) + : Particle(birth, position), m_velocity(velocity), m_acceleration(ct::Point()), m_friction(ct::Point()) {} + + Physics::Physics(const ct::Point& position, const glm::dvec3& velocity) + : Physics(0, position, velocity) {} + + void Physics::update(double t) { + m_acceleration -= static_cast<glm::dvec3>(m_friction) * m_velocity; + m_velocity += m_acceleration; + + this->translate(this->m_velocity); + } +} \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/PhysicsParticle.hpp b/ParticleGenerator/src/Particle/Physics.hpp similarity index 70% rename from ParticleGenerator/src/Particle/PhysicsParticle.hpp rename to ParticleGenerator/src/Particle/Physics.hpp index 2942097f51d54f964419391bf684063516200f7a..b56a4c76daa6e4b75c62c02fcad94cc234aff6d0 100644 --- a/ParticleGenerator/src/Particle/PhysicsParticle.hpp +++ b/ParticleGenerator/src/Particle/Physics.hpp @@ -2,8 +2,8 @@ #include "Particle.hpp" -namespace pg { - class PhysicsParticle : public Particle +namespace pg::particle { + class Physics : public Particle { private: glm::dvec3 m_velocity; @@ -11,8 +11,8 @@ namespace pg { glm::dvec3 m_friction; public: - PhysicsParticle(size_t birth, const ct::Point& position = ct::Point(), const glm::dvec3& velocity = ct::Point()); - PhysicsParticle(const ct::Point& position = ct::Point(), const glm::dvec3& velocity = ct::Point()); + Physics(size_t birth, const ct::Point& position = ct::Point(), const glm::dvec3& velocity = ct::Point()); + Physics(const ct::Point& position = ct::Point(), const glm::dvec3& velocity = ct::Point()); inline glm::dvec3 getVelocity() const {return this->m_velocity;} inline glm::dvec3 getAcceleration() const {return this->m_acceleration;} diff --git a/ParticleGenerator/src/Particle/PhysicsParticle.cpp b/ParticleGenerator/src/Particle/PhysicsParticle.cpp deleted file mode 100644 index 097b53754cbc170dd2e74afbe37789537fec3651..0000000000000000000000000000000000000000 --- a/ParticleGenerator/src/Particle/PhysicsParticle.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "PhysicsParticle.hpp" - -namespace pg { - PhysicsParticle::PhysicsParticle(size_t birth, const ct::Point& position, const glm::dvec3& velocity) - : Particle(birth, position), m_velocity(velocity), m_acceleration(ct::Point()), m_friction(ct::Point()) {} - - PhysicsParticle::PhysicsParticle(const ct::Point& position, const glm::dvec3& velocity) - : PhysicsParticle(0, position, velocity) {} - - void PhysicsParticle::update(double t) - { - m_acceleration -= static_cast<glm::dvec3>(m_friction) * m_velocity; - m_velocity += m_acceleration; - - this->translate(this->m_velocity); - } -} \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/ParticleGenerator.hpp b/ParticleGenerator/src/Particle/generator/Generator.hpp similarity index 66% rename from ParticleGenerator/src/Particle/generator/ParticleGenerator.hpp rename to ParticleGenerator/src/Particle/generator/Generator.hpp index 7536d755df7d706410c1b4f9518e8393548a272f..ae234afe8f41e00aa4375b72831a4506d762fcb8 100644 --- a/ParticleGenerator/src/Particle/generator/ParticleGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/Generator.hpp @@ -3,15 +3,17 @@ #include <memory> #include "../Particle.hpp" -namespace pg { - class ParticleGenerator { +namespace pg::particle { + + template <typename T> + class Generator { protected: float m_positionVariation; glm::vec3 m_position; glm::vec3 m_rotation; public: - ParticleGenerator(const glm::vec3& position = glm::vec3(0.f), float positionVariation = 0.0) + Generator(const glm::vec3& position = glm::vec3(0.f), float positionVariation = 0.0) : m_position(position), m_positionVariation(positionVariation), m_rotation(0.0) {} inline float getPositionVariation() const {return this->m_positionVariation;} @@ -22,8 +24,7 @@ namespace pg { inline void setPosition(const glm::vec3& position) {this->m_position = position;} inline void setRotation(const glm::vec3& rotation) {this->m_rotation = rotation;} - virtual std::vector<std::unique_ptr<Particle>> generate(size_t count, size_t birth = 0) const = 0; - - inline std::vector<std::unique_ptr<Particle>> operator()(size_t count, size_t birth = 0) const {return this->generate(count, birth);} + virtual std::vector<std::unique_ptr<T>> generate(size_t count, size_t birth = 0) const = 0; + inline std::vector<std::unique_ptr<T>> operator()(size_t count, size_t birth = 0) const {return this->generate(count, birth);} }; } \ No newline at end of file diff --git a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp b/ParticleGenerator/src/Particle/generator/PathGenerator.cpp similarity index 67% rename from ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp rename to ParticleGenerator/src/Particle/generator/PathGenerator.cpp index 009867c3d03d0558227528eb01589d252c771451..fc759fff437a217a938514440ed155b0744d7014 100644 --- a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.cpp +++ b/ParticleGenerator/src/Particle/generator/PathGenerator.cpp @@ -1,26 +1,26 @@ -#include "PathParticleGenerator.hpp" +#include "PathGenerator.hpp" #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) { +namespace pg::particle { + PathGenerator::PathGenerator(ct::CurveGenerator * generator, const ct::Curve& controlPoints, const ct::Point& position, float positionVariation) + : Generator(position, positionVariation), m_generator(generator), m_controlPoints(), m_u(0.0), m_spacing(0.0), m_increment(0.0) { for(auto & point : controlPoints) { this->m_controlPoints.push_back(this->m_position + glm::vec3(point)); } } - std::vector<std::unique_ptr<Particle>> PathParticleGenerator::generate(size_t count, size_t birth) const { + std::vector<std::unique_ptr<Path>> PathGenerator::generate(size_t count, size_t birth) const { std::random_device device; std::mt19937 randomEngine(device()); using ureal_dist = std::uniform_real_distribution<double>; ureal_dist positionGenerator(-this->getPositionVariation(), this->getPositionVariation()); - std::vector<std::unique_ptr<Particle>> particles; + std::vector<std::unique_ptr<Path>> particles; particles.reserve(count); std::vector<ct::Point> realCtrlPoint; @@ -43,7 +43,7 @@ namespace pg { positionVariation.y = positionGenerator(randomEngine); positionVariation.z = positionGenerator(randomEngine); - PathParticle * particle = new PathParticle(birth, m_generator, realCtrlPoint, m_u + u_space, m_increment); + Path * particle = new Path(birth, m_generator, realCtrlPoint, m_u + u_space, m_increment); particle->setPositionVariation(positionVariation); particle->setParameterLifeLimitor(this->m_limitor); @@ -52,7 +52,7 @@ namespace pg { u_space = 0.0; } - particles.push_back(std::unique_ptr<PathParticle>(particle)); + particles.push_back(std::unique_ptr<Path>(particle)); } return particles; diff --git a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp b/ParticleGenerator/src/Particle/generator/PathGenerator.hpp similarity index 69% rename from ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp rename to ParticleGenerator/src/Particle/generator/PathGenerator.hpp index 477f1eb198661991c2ddfe9b41797364a8036efc..8263cdb64e3d5ecec9c8c3eea084d2ce6ab70440 100644 --- a/ParticleGenerator/src/Particle/generator/PathParticleGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PathGenerator.hpp @@ -1,22 +1,21 @@ #pragma once -#include "ParticleGenerator.hpp" -#include "../PathParticle.hpp" +#include "Generator.hpp" +#include "../Path.hpp" +namespace pg::interface { + class PathGenerator; +} -namespace pg { - namespace interface { - class PathGenerator; - } - - class PathParticleGenerator : public ParticleGenerator { +namespace pg::particle { + class PathGenerator : public Generator<Path> { private: ct::Curve m_controlPoints; ct::CurveGenerator * m_generator; float m_u, m_spacing, m_increment, m_limitor; public: - PathParticleGenerator(ct::CurveGenerator * generator, const ct::Curve& controlPoints, const ct::Point& position = ct::Point(), float positionVariation = 0.0); + PathGenerator(ct::CurveGenerator * generator, const ct::Curve& controlPoints, const ct::Point& position = ct::Point(), float positionVariation = 0.0); inline ct::CurveGenerator * getGenerator() const {return this->m_generator;} inline const ct::Curve& getControlPoint() const {return this->m_controlPoints;} @@ -31,7 +30,7 @@ namespace pg { inline void setParameterIncrement(float inc) {this->m_increment = inc;} inline void setParameterLifeLimitor(float limitor) {this->m_limitor = limitor;} - virtual std::vector<std::unique_ptr<Particle>> generate(size_t count, size_t birth = 0) const = 0; + virtual std::vector<std::unique_ptr<Path>> generate(size_t count, size_t birth = 0) const; friend class interface::PathGenerator; }; diff --git a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.cpp b/ParticleGenerator/src/Particle/generator/PhysicsGenerator.cpp similarity index 83% rename from ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.cpp rename to ParticleGenerator/src/Particle/generator/PhysicsGenerator.cpp index 5841bb70abcbcce2d2b0efb183692d92b1cc9871..ed0665858ff87e38e3a51bad7375d8a1dccddf29 100644 --- a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.cpp +++ b/ParticleGenerator/src/Particle/generator/PhysicsGenerator.cpp @@ -1,4 +1,4 @@ -#include "PhysicsParticleGenerator.hpp" +#include "PhysicsGenerator.hpp" #include <random> @@ -7,10 +7,10 @@ #define GLM_ENABLE_EXPERIMENTAL #include <glm/gtx/rotate_vector.hpp> -namespace pg +namespace pg::particle { - PhysicsParticleGenerator::PhysicsParticleGenerator(const ct::Point& position, float positionVariation, const glm::dvec3& velocity) - : ParticleGenerator(position, positionVariation), + PhysicsGenerator::PhysicsGenerator(const ct::Point& position, float positionVariation, const glm::dvec3& velocity) + : Generator(position, positionVariation), m_velocity(velocity), m_acceleration(), m_friction(), @@ -18,7 +18,7 @@ namespace pg m_velocityVariation(), m_accelerationVariation() {} - std::vector<std::unique_ptr<Particle>> PhysicsParticleGenerator::generate(size_t count, size_t birth) const { + std::vector<std::unique_ptr<Physics>> PhysicsGenerator::generate(size_t count, size_t birth) const { std::random_device device; std::mt19937 randomEngine(device()); @@ -40,10 +40,10 @@ namespace pg ureal_dist fy(0.0, this->m_frictionVariation.y); ureal_dist fz(0.0, this->m_frictionVariation.z); - std::vector<std::unique_ptr<Particle>> particles; + std::vector<std::unique_ptr<Physics>> particles; for (size_t i = 0; i < count; ++i) { - PhysicsParticle * particle = new PhysicsParticle(birth, this->getPosition()); + Physics * particle = new Physics(birth, this->getPosition()); particle->translate({p(randomEngine), p(randomEngine), p(randomEngine)}); @@ -71,7 +71,7 @@ namespace pg particle->setAcceleration(realAcceleration); particle->setFriction(realFriction); - particles.push_back(std::unique_ptr<Particle>(particle)); + particles.push_back(std::unique_ptr<Physics>(particle)); } return particles; diff --git a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp b/ParticleGenerator/src/Particle/generator/PhysicsGenerator.hpp similarity index 80% rename from ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp rename to ParticleGenerator/src/Particle/generator/PhysicsGenerator.hpp index 155a07c212091e2029b763664c54acba40d47fe2..d5efbd150bffd4e375d7ee08eb9eefd57c178d98 100644 --- a/ParticleGenerator/src/Particle/generator/PhysicsParticleGenerator.hpp +++ b/ParticleGenerator/src/Particle/generator/PhysicsGenerator.hpp @@ -1,18 +1,18 @@ #pragma once -#include "ParticleGenerator.hpp" -#include "../PhysicsParticle.hpp" +#include "Generator.hpp" +#include "../Physics.hpp" #include "../../Interface/Generator/PhysicGenerator.hpp" -namespace pg { +namespace pg::particle { template <typename T> struct Interval { T upper; T lower; }; - class PhysicsParticleGenerator : public ParticleGenerator { + class PhysicsGenerator : public Generator<Physics> { private: glm::vec3 m_velocity; glm::vec3 m_acceleration; @@ -22,7 +22,7 @@ namespace pg { Interval<glm::vec3> m_accelerationVariation; public: - PhysicsParticleGenerator(const ct::Point& position = ct::Point(), float positionVariation = 0.0, const glm::dvec3& velocity = glm::dvec3(0.0, 0.0, 0.0)); + PhysicsGenerator(const ct::Point& position = ct::Point(), float positionVariation = 0.0, const glm::dvec3& velocity = glm::dvec3(0.0, 0.0, 0.0)); inline const glm::vec3 & getVelocity() const {return this->m_velocity;} inline const glm::vec3 & getAcceleration() const {return this->m_acceleration;} @@ -39,7 +39,7 @@ namespace pg { inline void setAccelerationVariation(const Interval<glm::vec3> & accelerationVariation) {this->m_accelerationVariation = accelerationVariation;} inline void setFrictionVariation(const glm::vec3 & frictionVariation) {this->m_frictionVariation = frictionVariation;} - std::vector<std::unique_ptr<Particle>> generate(size_t count, size_t birth = 0) const override; + std::vector<std::unique_ptr<Physics>> generate(size_t count, size_t birth = 0) const override; friend class interface::PhysicGenerator; }; diff --git a/ParticleGenerator/src/Scene/Scene.hpp b/ParticleGenerator/src/Scene/Scene.hpp index 0539574465327c2745155fc5e4ceb4630afa7149..f3bb177b7255850de4b19ad3d72d21264be60242 100644 --- a/ParticleGenerator/src/Scene/Scene.hpp +++ b/ParticleGenerator/src/Scene/Scene.hpp @@ -24,7 +24,7 @@ namespace pg::scene { virtual void destroy() = 0; }; - using ParticleContainer = std::vector<std::unique_ptr<pg::Particle>>; + using ParticleContainer = std::vector<std::unique_ptr<pg::particle::Particle>>; class SceneParticle : public Scene { private: diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp index 8294c0ef06f5a32200a711a7da45fcdab8c6beaa..2c8daad45a60a8010caa6527b33328770b600c88 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.cpp @@ -76,7 +76,7 @@ namespace pg::scene { auto end = std::chrono::high_resolution_clock::now(); if(!this->isFreezeEnable()) { - pg::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); + particle::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); if(duration_cast<std::chrono::milliseconds>(end - start).count() >= this->getSpawnFrequence()) { start = std::chrono::high_resolution_clock::now(); if(this->isSpawnEnable()) { @@ -170,7 +170,7 @@ namespace pg::scene { auto & indices = geometry.indices; for(size_t i = 0; i < geometry.indices.size(); i+= 3) { - PhysicsParticleGenerator generator; + particle::PhysicsGenerator generator; glm::vec3 & p1 = vertices[indices[i]].position, p2 = vertices[indices[i+1]].position, p3 = vertices[indices[i+2]].position; glm::vec3 baricenter = (p1 + p2 + p3) / 3.f; @@ -187,7 +187,7 @@ namespace pg::scene { void MeshGenerator::spawn(int count, double current_time) { for(auto & generator : this->_generators) { if((count + this->_particles.size()) <= this->getMaxParticles()) { - std::vector<std::unique_ptr<pg::Particle>> newParticles = generator.generate(count, static_cast<size_t>(current_time)); + std::vector<std::unique_ptr<particle::Physics>> newParticles = generator.generate(count, static_cast<size_t>(current_time)); this->_particles.insert(this->_particles.begin(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end())); } } diff --git a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp index 428d93e0b7642d370aba2cd2a2b3ad7a1e683ab6..82ef60d06dfe518ed6979e435de9018020298e5c 100644 --- a/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp +++ b/ParticleGenerator/src/Scene/Scenes/MeshGenerator.hpp @@ -8,7 +8,7 @@ #include "../../Mesh/Mesh.hpp" #include "../../Mesh/Billboard.hpp" #include "../../Renderer/Renderer.hpp" -#include "../../Particle/generator/PhysicsParticleGenerator.hpp" +#include "../../Particle/generator/PhysicsGenerator.hpp" #include "../../Interface/Scene/MeshGenerator.hpp" namespace pg::scene { @@ -19,7 +19,7 @@ namespace pg::scene { glm::vec3 _meshPosition; glm::vec3 _meshRotation; - std::vector<PhysicsParticleGenerator> _generators; + std::vector<particle::PhysicsGenerator> _generators; Billboard _billboard; Material _billboardTexture; Program _billboardProgram; diff --git a/ParticleGenerator/src/Scene/Scenes/Path.cpp b/ParticleGenerator/src/Scene/Scenes/Path.cpp index cf776fb61e1b653d8c6d5174a9a48f0a70eec2ee..c16a95786467caa3c24f18968e50cc182007612e 100644 --- a/ParticleGenerator/src/Scene/Scenes/Path.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Path.cpp @@ -60,7 +60,7 @@ namespace pg::scene { auto end = std::chrono::high_resolution_clock::now(); if(!this->isFreezeEnable()) { - pg::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); + pg::particle::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); if(duration_cast<std::chrono::milliseconds>(end - start).count() >= 500) { start = std::chrono::high_resolution_clock::now(); if(this->isSpawnEnable()) { @@ -128,7 +128,7 @@ namespace pg::scene { void Path::spawn(int count, double current_time) { if((count + this->_particles.size()) <= this->getMaxParticles()) { - std::vector<std::unique_ptr<pg::Particle>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); + std::vector<std::unique_ptr<pg::particle::Path>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); this->_particles.insert(this->_particles.begin(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end())); } diff --git a/ParticleGenerator/src/Scene/Scenes/Path.hpp b/ParticleGenerator/src/Scene/Scenes/Path.hpp index 246a6ddd00b67a29351acf7796641f7e2c4c0adf..3c16f4cc9260550f96b5cee5392df01ead8cdbc1 100644 --- a/ParticleGenerator/src/Scene/Scenes/Path.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Path.hpp @@ -4,7 +4,7 @@ #include "Trajectory.hpp" #include "../../Renderer/Renderer.hpp" -#include "../../Particle/generator/PathParticleGenerator.hpp" +#include "../../Particle/generator/PathGenerator.hpp" #include "../../Interface/Scene/Path.hpp" #include "../../Mesh/Billboard.hpp" #include "../../System/Window.hpp" @@ -18,7 +18,7 @@ namespace pg::scene { Billboard _billboard; Trajectory _trajectory; Material _texture; - PathParticleGenerator _generator; + particle::PathGenerator _generator; glm::vec4 _color; interface::Path _interface; @@ -34,7 +34,7 @@ namespace pg::scene { inline const Program & getProgram() const {return this->_program;} inline const Material & getTexture() const {return this->_texture;} - inline const PathParticleGenerator & getGenerator() const {return this->_generator;} + inline const particle::PathGenerator & getGenerator() const {return this->_generator;} void changeParticletexture(const std::string &); diff --git a/ParticleGenerator/src/Scene/Scenes/Physic.cpp b/ParticleGenerator/src/Scene/Scenes/Physic.cpp index eee1755e79fa6f42c9d3dcd1fc63658cc9eac5ac..9e08faa169aee03d5392967eca8444d27ceb02cf 100644 --- a/ParticleGenerator/src/Scene/Scenes/Physic.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Physic.cpp @@ -56,7 +56,7 @@ namespace pg::scene { auto end = std::chrono::high_resolution_clock::now(); if(!this->isFreezeEnable()) { - pg::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); + particle::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); if(duration_cast<std::chrono::milliseconds>(end - start).count() >= this->getSpawnFrequence()) { start = std::chrono::high_resolution_clock::now(); if(this->isSpawnEnable()) { @@ -122,7 +122,7 @@ namespace pg::scene { void Physic::spawn(int count, double current_time) { if((count + this->_particles.size()) <= this->getMaxParticles()) { - std::vector<std::unique_ptr<pg::Particle>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); + std::vector<std::unique_ptr<pg::particle::Physics>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); this->_particles.insert(this->_particles.begin(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end())); } } diff --git a/ParticleGenerator/src/Scene/Scenes/Physic.hpp b/ParticleGenerator/src/Scene/Scenes/Physic.hpp index 17c9bf1c8ba2de13ebe5c7b1097ccb69781a5f80..8b36ea2cae9af5c0aa65628d38e6906294b02f54 100644 --- a/ParticleGenerator/src/Scene/Scenes/Physic.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Physic.hpp @@ -3,7 +3,7 @@ #include "../Scene.hpp" #include "../../Renderer/Renderer.hpp" -#include "../../Particle/generator/PhysicsParticleGenerator.hpp" +#include "../../Particle/generator/PhysicsGenerator.hpp" #include "../../Interface/Scene/Physic.hpp" #include "../../Mesh/Billboard.hpp" @@ -16,7 +16,7 @@ namespace pg::scene { Program _program; Material _texture; Billboard _billboards; - PhysicsParticleGenerator _generator; + particle::PhysicsGenerator _generator; glm::vec4 _color; interface::Physic _interface; @@ -27,7 +27,7 @@ namespace pg::scene { inline const Program & getProgram() const {return this->_program;} inline const Material & getTexture() const {return this->_texture;} - inline const PhysicsParticleGenerator & getGenerator() const {return this->_generator;} + inline const particle::PhysicsGenerator & getGenerator() const {return this->_generator;} void changeParticletexture(const std::string &); diff --git a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp index 494c2f6d59ef5cef624823de6c6e5dd5ac4ea863..c97ca9bf913a3e311a8081970a3187fd11fc3120 100644 --- a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp +++ b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.cpp @@ -61,7 +61,7 @@ namespace pg::scene { auto end = std::chrono::high_resolution_clock::now(); if(!this->isFreezeEnable()) { - pg::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); + pg::particle::Particle::purge(this->_particles, static_cast<size_t>(current_time), this->getLifetime()); if(duration_cast<std::chrono::milliseconds>(end - start).count() >= this->getSpawnFrequence()) { start = std::chrono::high_resolution_clock::now(); if(this->isSpawnEnable()) { @@ -134,7 +134,7 @@ namespace pg::scene { void PhysicSprite::spawn(int count, double current_time) { if((count + this->_particles.size()) <= this->getMaxParticles()) { - std::vector<std::unique_ptr<pg::Particle>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); + std::vector<std::unique_ptr<pg::particle::Physics>> newParticles = this->_generator.generate(count, static_cast<size_t>(current_time)); this->_particles.insert(this->_particles.end(), std::make_move_iterator(newParticles.begin()), std::make_move_iterator(newParticles.end())); } } diff --git a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.hpp b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.hpp index 8a7d74c8e463ba4ba32e967a4e70903104519c32..59e489e5ef43e7b8592916877aa0a31f217b775f 100644 --- a/ParticleGenerator/src/Scene/Scenes/PhysicSprite.hpp +++ b/ParticleGenerator/src/Scene/Scenes/PhysicSprite.hpp @@ -3,7 +3,7 @@ #include "../Scene.hpp" #include "../../Renderer/Renderer.hpp" -#include "../../Particle/generator/PhysicsParticleGenerator.hpp" +#include "../../Particle/generator/PhysicsGenerator.hpp" #include "../../Interface/Scene/Physic.hpp" #include "../../Mesh/Billboard.hpp" @@ -17,7 +17,7 @@ namespace pg::scene { Material _texture; Billboard _billboards; std::vector<glm::vec4> _frames; - PhysicsParticleGenerator _generator; + particle::PhysicsGenerator _generator; glm::vec4 _color; public: @@ -26,7 +26,7 @@ namespace pg::scene { inline const Program & getProgram() const {return this->_program;} inline const Material & getTexture() const {return this->_texture;} - inline const PhysicsParticleGenerator & getGenerator() const {return this->_generator;} + inline const particle::PhysicsGenerator & getGenerator() const {return this->_generator;} void changeParticletexture(const std::string &); diff --git a/ParticleGenerator/src/Scene/Scenes/Trajectory.cpp b/ParticleGenerator/src/Scene/Scenes/Trajectory.cpp index 3038418eb3a8a73a0c6567ab6cc4d154e94a196b..ec73c94b40bbe4231639f208bda34beb3bdd86db 100644 --- a/ParticleGenerator/src/Scene/Scenes/Trajectory.cpp +++ b/ParticleGenerator/src/Scene/Scenes/Trajectory.cpp @@ -4,7 +4,7 @@ #include <CurveTools/CPU/CurveSampler.hpp> namespace pg::scene { - Trajectory::Trajectory(PathParticleGenerator * generator, double increment) + Trajectory::Trajectory(particle::PathGenerator * generator, double increment) : _generator(generator), _vbo(this->_vao, {layout::POSITION, layout::COLOR}), _increment(increment), diff --git a/ParticleGenerator/src/Scene/Scenes/Trajectory.hpp b/ParticleGenerator/src/Scene/Scenes/Trajectory.hpp index 9baa8216a1f045623f62aa2b046cdbf6b641502f..c9a1d6cf3a6dc648087c3ef566a31cdf134bfcee 100644 --- a/ParticleGenerator/src/Scene/Scenes/Trajectory.hpp +++ b/ParticleGenerator/src/Scene/Scenes/Trajectory.hpp @@ -1,14 +1,14 @@ #pragma once #include "../../Renderer/Renderer.hpp" -#include "../../Particle/generator/PathParticleGenerator.hpp" +#include "../../Particle/generator/PathGenerator.hpp" #include "../../Interface/Scene/Trajectory.hpp" #include "../Scene.hpp" namespace pg::scene { class Trajectory : public Scene { private: - PathParticleGenerator * _generator; + particle::PathGenerator * _generator; VertexArray _vao; VerticeBuffer _vbo; Program _program; @@ -22,9 +22,9 @@ namespace pg::scene { interface::Trajectory _interface; public: - Trajectory(PathParticleGenerator *, double = 0.01f); + Trajectory(particle::PathGenerator *, double = 0.01f); - inline PathParticleGenerator * getGenerator() const {return this->_generator;} + inline particle::PathGenerator * getGenerator() const {return this->_generator;} inline double getIncrement() const {return this->_increment;} inline const glm::vec4 & getColor() const {return this->_color;} inline float getPointSize() const {return this->_pointSize;}