Recently I started designing a particle system for a game I develop. But I have some issues with it. I mean, it works but I have a feeling that my design isn't good enough.
So, basically I have a Particle class which contains the particle's vars and couple of functions:
class OBJECTATTRIBUTE_API Particle
{
protected:
Vector3d position;
Vector3d direction;
Vector3d gravity;
float life;
float fade;
float red;
float green;
float blue;
bool isActive;
bool isInit;
public:
void Deinitialize();
void SetPosition(Vector3d position);
bool IsActive();
};
And I derive from that class the types of particles. Like this:
class OBJECTATTRIBUTE_API ParticleExplosion : public Particle
{
public:
void Initialize();
void Update();
void Render();
void Rejuvenate();
};
And at the end is the emitter. This is actually where I think my design fails. I make an emitter for every particle system and, at some point, I may have too much different emitters.
Here is an example of the particle emitter realisation:
// The base class
class OBJECTATTRIBUTE_API ParticleEmitter
{
protected:
Vector3d emitterPosition;
unsigned int particleTextureID;
unsigned int particleCount;
bool isEmitterStopped;
public:
ParticleEmitter();
ParticleEmitter(Vector3d emitterPosition);
};
// The derived emitter.
class OBJECTATTRIBUTE_API ParticleEmitter_Explosion : public ParticleEmitter
{
private:
ParticleExplosion *particles;
public:
void AddParticles(unsigned int particleCount);
void Initialize();
void Start();
void Stop();
void Reposition(Vector3d newPosition);
void SetParticleTextureID(unsigned int particleTextureID);
};
And the question - Is my particle system design good? If not, what can I do to improve it?
EDIT : I was told that the question was too subjective, so I will try to add couple of specifications.
Firstly, I started making the particle system for explosion simulation and also some attack animations in my game. It works very well with that, so I think this goal is achieved.
Secondly, the performance hit is acceptable and I am OK with that.
And finally, the question was about is this design good for flexible adding of new particle effects implementation?