[DEV] real start dev of particule elements
This commit is contained in:
parent
2eefd14470
commit
270082d49b
@ -283,3 +283,10 @@ void ege::Environement::GenerateInteraction(ege::ElementInteraction& _event)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
ege::Environement::Environement(void) :
|
||||
m_dynamicsWorld(NULL),
|
||||
m_particuleEngine(*this)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
|
@ -9,6 +9,11 @@
|
||||
#ifndef __EGE_ENVIRONEMENT_H__
|
||||
#define __EGE_ENVIRONEMENT_H__
|
||||
|
||||
namespace ege {
|
||||
class Environement;
|
||||
class ElementInteraction;
|
||||
};
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <BulletDynamics/Dynamics/btActionInterface.h>
|
||||
class btDynamicsWorld;
|
||||
@ -17,6 +22,7 @@ class btDynamicsWorld;
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <ejson/ejson.h>
|
||||
#include <exml/exml.h>
|
||||
#include <ege/ParticuleEngine.h>
|
||||
|
||||
namespace ege {
|
||||
typedef enum {
|
||||
@ -66,7 +72,7 @@ namespace ege {
|
||||
btDynamicsWorld* m_dynamicsWorld; //!< curent system world description
|
||||
etk::Vector<ege::ElementGame*> 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; };
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,9 @@
|
||||
#include <ege/debug.h>
|
||||
#include <ege/Particule.h>
|
||||
|
||||
ege::Particule::Particule(ege::ParticuleEngine& _particuleEngine) :
|
||||
m_particuleEngine(_particuleEngine)
|
||||
{
|
||||
m_particuleEngine.Add(this);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
#ifndef __EGE_PARTICULE_H__
|
||||
#define __EGE_PARTICULE_H__
|
||||
|
||||
namespace ege {
|
||||
class Particule;
|
||||
};
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <ege/Environement.h>
|
||||
|
||||
@ -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; };
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,72 @@
|
||||
#include <ege/debug.h>
|
||||
#include <ege/ParticuleEngine.h>
|
||||
|
||||
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; iii<m_particuleList.Size(); ++iii) {
|
||||
if (m_particuleList[iii] != NULL) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii] = _particule;
|
||||
return;
|
||||
}
|
||||
// Just add it at the end ...
|
||||
m_particuleList.PushBack();
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::Update(float _deltaTime)
|
||||
{
|
||||
for (esize_t iii=0; iii<m_particuleList.Size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii]->Update(_deltaTime);
|
||||
}
|
||||
// check removing elements
|
||||
for (esize_t iii=0; iii<m_particuleList.Size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (m_particuleList[iii]->NeedRemove()) {
|
||||
delete m_particuleList[iii];
|
||||
m_particuleList[iii] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::Draw(void)
|
||||
{
|
||||
for (esize_t iii=0; iii<m_particuleList.Size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii]->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::Clear(void)
|
||||
{
|
||||
for (esize_t iii=0; iii<m_particuleList.Size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
delete m_particuleList[iii];
|
||||
m_particuleList[iii] = NULL;
|
||||
}
|
||||
m_particuleList.Clear();
|
||||
}
|
||||
|
@ -6,21 +6,32 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/Environement.h>
|
||||
|
||||
#ifndef __EGE_PARTICULE_ENGINE_H__
|
||||
#define __EGE_PARTICULE_ENGINE_H__
|
||||
|
||||
namespace ege {
|
||||
class ParticuleEngine;
|
||||
};
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <ege/Particule.h>
|
||||
#include <ege/Environement.h>
|
||||
|
||||
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<Particule*> m_particuleList;
|
||||
public:
|
||||
void Clear(void);
|
||||
void Add(Particule* _particule, const char* _particuleType);
|
||||
void Update(float _deltaTime);
|
||||
void Draw(void);
|
||||
};
|
||||
|
66
ege/ParticuleSimple.cpp
Normal file
66
ege/ParticuleSimple.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/ParticuleSimple.h>
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
67
ege/ParticuleSimple.h
Normal file
67
ege/ParticuleSimple.h
Normal file
@ -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 <etk/UString.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <ege/Environement.h>
|
||||
#include <ege/Particule.h>
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
@ -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'
|
||||
])
|
||||
|
Loading…
x
Reference in New Issue
Block a user