Archived

This topic is now archived and is closed to further replies.

Advanced particle system theory...

This topic is 5883 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 recently read the article at gamasutra.com on how to make an advanced particle system. I understand everything except that thingy that John Van Der Burg (is that how its spelt?) uses in his particle manager class. He uses something like a template array (if thats what its called). It allows a system to be added and removed without using an array. How does this work? Is it something like a linked list? I want to be able to add and remove systems like that so that I don''t have to allocate a big array of my particle effects. I was thinking of doing something a bit different: I would have a class called something like ParticleSystemID. It would have an integer and a bool for member variables. I would have an array of these ParticleSystemID classes (say 1000 of them). When I want to add an effect to the manager I loop through the array of ParticleSystemIDs until I find one that isn''t in use (by checking the bool variable). When I find one that isn''t being used, I create a new effect and assign it to the ID. When I want to render or do something to the individual effects, I would search through the array of IDs. Would this work?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think his template thingie is just his templated array class with a counter.

I guess its something similar to this

  
template <class T>
class templateArray
{
T* objects;
int counter;

void addobject(T*);
void removeobject(int);
}


ask me if ya need any more help, I implemented a particle system similar to what Van der Burg does, but with some improvements and more "plug-in" friendly.

Paul

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You never heard of the STL? Use it!
What you want is a vector, use it like this:

// Make it like this:
vector Systems;

// To add one:
ParticleSystemID sys;
// Set up sys
System.push_back(sys);

// To remove one:
System.remove(System.begin() + index);

#include or #include to use it
You can get the STL from many sources, try a search on google.


Share this post


Link to post
Share on other sites