Jump to content
  • Advertisement
Sign in to follow this  

Alternative method for setting particle system parameters

This topic is 4519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a bunch of different types of particle classes for rendering different types of particles. Some of these classes have special parameters on top of the base parameters for a particle. What I would like to know is, what would be a good design decision for setting the various parameters besides the usual "set" and "get" functions. I dont really want to bloat my code with a bunch of "set/get" functions for each and every type of parameter. Are there any good design alternatives? Jon

Share this post

Link to post
Share on other sites
You can go the way of OpenGL, and, since most of the particle operations are done in float or double data types, you can use simple enum for the parameter type and use a sample such as:

enum eParticleAttribute

class CParticle

virtual void SetAttributef(eParticleAttribute eAttrib, const float &fAttribValue);
virtual void SetAttributefv(eParticleAttribute eAttrib, float *pfAttribValue);

float m_fSpeed[3];
float m_fAcceleration[3];
float m_fDirection[3];

Thats one way. Another one is to utilize an std::map (std::map<std::string, float>), and use similar approach to the above mentioned, but use strings in the 'switch case'.
And last, but not least, is to use struct to expose all particle attributes and access them using one set of get/set functions.

Feel free to choose which one to use :)

Share this post

Link to post
Share on other sites
I have a fairly complicated particle system. There are a lot of parameters and they are distributed among several classes. Here are how my parameters are distributed:

Particle base class (per particle):
  • lifetime
  • age
  • position
  • velocity
  • color

Derived particle class (TexturedParticle, for example) (per particle):
  • radius
  • rotation

Environment class (shared by emitters):
  • gravity
  • wind velocity
  • air friction
  • wind gustiness
  • terminal velocity
  • bounce planes
  • clip planes

Appearance class (shared by particles):
  • material
  • texture
  • rate of change of the color
  • rate of change of the radius
  • angular velocity
  • line width or point size

BTW, many of these parameters have no set functions because the initial values are set in the constructor and once a particle is launched, it determines its own state.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!