Unfortunately, most of the time I am working on ‘secret’ projects or projects on which we simply cannot share as much as we would like. So this post will be about something I am doing in my ‘spare’ time. At least what is left of it ;)
As some of you might know I am a big fan of everything that involves particles. Especially explosions!
Unfortunately, Adobe Director’s own particle system doesn’t really suit my needs. It is ok for a lot of quick things but for the games we make it is a little outdated. For example; you cannot rotate or animate particles individually and you don’t have any blending options (additive blending) yet. Finally, there is no general time or speed multiplier for the entire particle system. Our games sometimes feature slow motion and so we’re unable to dynamically change the speed and lifetime of the system. All in all it was time for our own particle system. So about 10 games ago (more or less,..) I decided to create my own particle system from scratch.
At this time, 10 games later, I still haven’t got a perfect particle system up and running. Mostly because I noticed early on that creating a system that could do everything that I (or one of my colleagues) want is simply not possible. The variations are impossible to count. Furthermore, as I can’t go as low-level as the default Adobe Director particle systems I run into performance problems.
So as we speak we have a default particle system class which handles general particle behavior and when we need an additional or new effect we simple use this one as a base for new particle classes. The default setup handles birth, life, texture animation (if necessary), position, rotation and scale. For the transform properties we also have speed and direction. The slightly more advanced ‘default’ ;) version also does drag, gravity and wind. Each frame the particles are updated until they reach the end of their life after which the are deleted. When all particles are deleted the particle system cease to exists. For most particle systems we use planes (simple 2 triangles forming a square) on which we display the animated (texture). However, we could also use other types of geometry (which we could even add to the physics solution). With the basic setup we can pretty much build any possible particle system we need and can do everything the default system can’t. The biggest and perhaps the only downside is that bigger, more complex system can cause too much of a performance drain.
So to end this post a couple of short cases of particle effects based upon the base particle class.
1. Particle trail
Sometimes you want a consistent trail of particles with a constant size. You cannot spawn a new particle each frame, because;
a. The distanced travelled can exceed the particle size and thus creating gaps
b. In slowmotion this would mean lots of particles would be spawned at almost the same place.
For this system I calculate the distance and direction between the systems current position and previous one. If this exceeds the size of the particle (with buffer) I fill the distance travelled with particles (not forgetting to update all particle settings accordingly).
2. ‘Volume’ explosions
It always bothered me that our previous explosions always start from a single point and move outwards. While this would work perfectly for a grenade it always looks weird with bigger objects. I could spawn a explosion particle system and update it instantly at how it would look over 10 frames or so. I experimented with this, but I simply wanted an explosion to fill up the object. There were a couple of options. Iterate through all vertices of an object and spawn a particle at that world position. Still something I would like to test ;) but I didn’t expect this to be very fast. So for a quicker solution I opted to use the volume of the bounding of the object to define particle positions using a 3d grid. As I store bounding boxes of available meshes anyway this could be done fairly easy. You could say this won’t look nice with weird irregular shaped object and I agree ;) Nevertheless, most of it is blocked by smoke and fire and it all looks cool anyway!
I am off now!
Cheers
Pieter
Geen opmerkingen:
Een reactie posten