From 270082d49b7d70f0ebbe357b7e2f3320fc7cb42d Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 12 Sep 2013 21:43:18 +0200 Subject: [PATCH] [DEV] real start dev of particule elements --- ege/Environement.cpp | 7 +++++ ege/Environement.h | 16 +++++++++- ege/Particule.cpp | 6 ++++ ege/Particule.h | 37 +++++++++++----------- ege/ParticuleEngine.cpp | 69 +++++++++++++++++++++++++++++++++++++++++ ege/ParticuleEngine.h | 23 ++++++++++---- ege/ParticuleSimple.cpp | 66 +++++++++++++++++++++++++++++++++++++++ ege/ParticuleSimple.h | 67 +++++++++++++++++++++++++++++++++++++++ lutin_ege.py | 1 + 9 files changed, 266 insertions(+), 26 deletions(-) create mode 100644 ege/ParticuleSimple.cpp create mode 100644 ege/ParticuleSimple.h diff --git a/ege/Environement.cpp b/ege/Environement.cpp index 97143d3..b4d59f4 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -283,3 +283,10 @@ void ege::Environement::GenerateInteraction(ege::ElementInteraction& _event) */ } } + +ege::Environement::Environement(void) : + m_dynamicsWorld(NULL), + m_particuleEngine(*this) +{ + // nothing to do ... +} diff --git a/ege/Environement.h b/ege/Environement.h index 7b36ae6..1bc4ba2 100644 --- a/ege/Environement.h +++ b/ege/Environement.h @@ -9,6 +9,11 @@ #ifndef __EGE_ENVIRONEMENT_H__ #define __EGE_ENVIRONEMENT_H__ +namespace ege { + class Environement; + class ElementInteraction; +}; + #include #include class btDynamicsWorld; @@ -17,6 +22,7 @@ class btDynamicsWorld; #include #include #include +#include namespace ege { typedef enum { @@ -66,7 +72,7 @@ namespace ege { btDynamicsWorld* m_dynamicsWorld; //!< curent system world description etk::Vector m_listElementGame; //!< List of all element added in the Game public: - Environement(void) : m_dynamicsWorld(NULL) { }; + Environement(void); virtual ~Environement(void) { }; public: /** @@ -141,6 +147,14 @@ namespace ege { * @param[in] _event event that might be apply ... */ void GenerateInteraction(ege::ElementInteraction& _event); + private: + ege::ParticuleEngine m_particuleEngine; //!< Particule engine properties + public: + /** + * @brief Get the particule engine reference. + * @return The requested reference on the engine + */ + ege::ParticuleEngine& GetParticuleEngine(void) { return m_particuleEngine; }; }; }; diff --git a/ege/Particule.cpp b/ege/Particule.cpp index caa0194..2a33adb 100644 --- a/ege/Particule.cpp +++ b/ege/Particule.cpp @@ -9,3 +9,9 @@ #include #include +ege::Particule::Particule(ege::ParticuleEngine& _particuleEngine) : + m_particuleEngine(_particuleEngine) +{ + m_particuleEngine.Add(this); +} + diff --git a/ege/Particule.h b/ege/Particule.h index 6780a29..3d8b41d 100644 --- a/ege/Particule.h +++ b/ege/Particule.h @@ -9,6 +9,10 @@ #ifndef __EGE_PARTICULE_H__ #define __EGE_PARTICULE_H__ +namespace ege { + class Particule; +}; + #include #include @@ -22,23 +26,25 @@ namespace ege { class Particule { private: - etk::UString m_name; //!< name of the particule + ege::ParticuleEngine& m_particuleEngine; public: /** * @brief Constructor. - * @param[in] _name Name of the particule. - * @param[in] _standalone The particule are created and have there own life (no dynamic control) + * @param[in] _env reference on the envorionement ... */ - Particule(ege::Environement& _env, const etk::UString& _name) : m_name(_name) { }; + Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType); /** * @brief Destructor. */ - ~Particule(void) { }; + virtual ~Particule(void) { }; /** - * @brief Get the particule type name. - * @return the particule name. + * @brief Init the particule */ - const etk::UString& GetName(void) { return m_name; }; + virtual void Init(void) { }; + /** + * @brief Un-init the particule + */ + virtual void UnInit(void) { }; /** * @brief Update the paticule properties * @param[in] _delta Delta time from the previous call @@ -48,19 +54,12 @@ namespace ege { * @brief Draw the current particule */ virtual void Draw(void) { }; - - // note : For multiple instance only (standalone==false) /** - * + * @brief Check if the element might be removed + * @return true : The element might be removed + * @return false : The element might be keeped */ - /* - virtual int32_t Add(void) { return -1; }; - virtual void SetLife(int32_t _id, float _life); - virtual void SetLevel(int32_t _id, float _level); - virtual void SetPosition(int32_t _id, const vec3& _pos); - virtual void SetAngleSpeed(int32_t _id, const vec4& _angle); - virtual void SetMoveSpeed(int32_t _id, const vec3& _speed); - */ + virtual bool NeedRemove(void) { return false; }; }; }; diff --git a/ege/ParticuleEngine.cpp b/ege/ParticuleEngine.cpp index 80c700d..17c837f 100644 --- a/ege/ParticuleEngine.cpp +++ b/ege/ParticuleEngine.cpp @@ -9,3 +9,72 @@ #include #include +ege::ParticuleEngine::ParticuleEngine(ege::Environement& _env) : + m_env(_env) +{ + +} + +ege::ParticuleEngine::~ParticuleEngine(void) +{ + +} + +void ege::ParticuleEngine::Add(Particule* _particule, const char* _particuleType) +{ + if (_particule==NULL) { + EGE_ERROR("Try to add particule NULL"); + return; + } + for (esize_t iii=0; iiiUpdate(_deltaTime); + } + // check removing elements + for (esize_t iii=0; iiiNeedRemove()) { + delete m_particuleList[iii]; + m_particuleList[iii] = NULL; + } + } +} + +void ege::ParticuleEngine::Draw(void) +{ + for (esize_t iii=0; iiiDraw(); + } +} + +void ege::ParticuleEngine::Clear(void) +{ + for (esize_t iii=0; iii + #ifndef __EGE_PARTICULE_ENGINE_H__ #define __EGE_PARTICULE_ENGINE_H__ +namespace ege { + class ParticuleEngine; +}; + #include +#include #include -#include namespace ege { - class PariculeEngine + class ParticuleEngine { + private: + ege::Environement& m_env; public: - PariculeEngine(ege::Environement& _env); // note : Need the engine to register has an dynamic element ... (the first ...) - ~PariculeEngine(void); - Particule* LocalKeep(const etk::UString& _name); - void LocalRelease(Particule* _particule); + ParticuleEngine(ege::Environement& _env); // note : Need the engine to register has an dynamic element ... (the first ...) + ~ParticuleEngine(void); + private: + etk::Vector m_particuleList; + public: + void Clear(void); + void Add(Particule* _particule, const char* _particuleType); void Update(float _deltaTime); void Draw(void); }; diff --git a/ege/ParticuleSimple.cpp b/ege/ParticuleSimple.cpp new file mode 100644 index 0000000..00aed40 --- /dev/null +++ b/ege/ParticuleSimple.cpp @@ -0,0 +1,66 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include +#include + + + +ege::ParticuleSimple::ParticuleSimple(ege::ParticuleEngine& _particuleEngine, const char* _particuleType) : + Particule(_particuleEngine, _particuleType) +{ + Init(); +} + + +void ege::ParticuleSimple::Init(void) +{ + m_life = 0; + m_level = 0; + m_pos = vec3(0,0,0); + m_angle = vec4(0,0,0,0); + m_speed = vec3(0,0,0); +} + +bool ege::ParticuleSimple::NeedRemove(void) +{ + return m_life<0.0f; +} + + +void ege::ParticuleSimple::Update(float _delta) +{ + m_life -= _delta; + m_pos += m_speed; +} + +void ege::ParticuleSimple::SetLife(float _life) +{ + m_life = _life; +} + +void ege::ParticuleSimple::SetLevel(float _level) +{ + m_level = _level; +} + +void ege::ParticuleSimple::SetPosition(const vec3& _pos) +{ + m_pos = _pos; +} + +void ege::ParticuleSimple::SetAngleSpeed(const vec4& _angle) +{ + m_angle = _angle; +} + +void ege::ParticuleSimple::SetMoveSpeed(const vec3& _speed) +{ + m_speed = _speed; +} + diff --git a/ege/ParticuleSimple.h b/ege/ParticuleSimple.h new file mode 100644 index 0000000..bdc744d --- /dev/null +++ b/ege/ParticuleSimple.h @@ -0,0 +1,67 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __EGE_PARTICULE_SIMPLE_H__ +#define __EGE_PARTICULE_SIMPLE_H__ + +namespace ege { + class ParticuleSimple; +}; + +#include +#include +#include +#include +#include +#include + + +namespace ege { + /** + * @brief The particule class is an element with no control, when it will be created, + * it does not have any control, for example smoke or reactor generation ... + * or explosion particule ... + */ + class ParticuleSimple : public Particule + { + public: + /** + * @brief Constructor. + * @param[in] _name Name of the particule. + * @param[in] _standalone The particule are created and have there own life (no dynamic control) + */ + ParticuleSimple(ege::ParticuleEngine& _particuleEngine, const char* _particuleType); + /** + * @brief Destructor. + */ + virtual ~ParticuleSimple(void) { }; + public: // herited elements: + virtual void Update(float _delta); + //virtual void Draw(void) { }; + virtual bool NeedRemove(void); + virtual void Init(void); + private: + float m_life; + float m_level; + vec3 m_pos; + vec4 m_angle; + vec3 m_speed; + /** + * + */ + virtual void SetLife(float _life); + virtual void SetLevel(float _level); + virtual void SetPosition(const vec3& _pos); + virtual void SetAngleSpeed(const vec4& _angle); + virtual void SetMoveSpeed(const vec3& _speed); + }; +}; + +#endif + + diff --git a/lutin_ege.py b/lutin_ege.py index 731bb33..7c6f3ac 100644 --- a/lutin_ege.py +++ b/lutin_ege.py @@ -16,6 +16,7 @@ def Create(target): 'ege/ElementGame.cpp', 'ege/Particule.cpp', 'ege/ParticuleEngine.cpp', + 'ege/ParticuleSimple.cpp', 'ege/Scene.cpp', 'ege/Environement.cpp' ])