A number of naturally occurring phenomenon are very hard to render with 3D objects. Smoke, fire, explosions and waterfalls are examples that are too fluid and intricate to try and reproduce with a 3D animation. Typically in situations where you need to visualize these systems in real time, like a game, they are represented using particles. Particles are small, simple objects that can be created in great numbers. When they move as a group according to some simple rules it is quite easy to get some nice looking effects that mimic their real world counterparts without the computational overhead.
Papervision doesn’t natively include a comprehensive particle system, but luckily for us the Flash particle system Flint can be used with the Papervision engine. Flint is a mature product (version 2 was just released at the time of writing) that includes a number of effects which you can combine to create an almost infinite number of possibilities. By using Flint and Papervision together we can achieve some pretty cool 3D particle effects.
Flint includes 3 renderers which can be used in conjunction with Papervision: the PV3DPixelRenderer, the PV3DParticleRenderer and the PV3DRenderer.
PV3DPixelRenderer renders each particle as a single pixel on the screen. It is great for dense effects (i.e. those that have a lot of particles) like fireworks. However for less involved particle systems the fact that each particle is rendered as a single pixel can mean that the effect is hard to see. In my testing the pixel renderer was quite fast, and also rendered the Flint particle systems as you would expect.
The PV3DParticleRenderer can render each particle as a Papervision Particle object. The main advantage of the PV3DParticleRenderer over the PV3DPixelRenderer is that you can specify the size of the particles. This makes less dense particle systems much easier to see. You can even apply a texture to the particles to get an added level of detail. Unfortunately some of the Flint color “actions” (an action is a class that modifies the properties of a particle to change its color, position, movement etc) currently don’t render properly with the PV3DParticleRenderer. You will see this effect when comparing the fireworks particle systems in the demo – the PV3DPixelRenderer correctly assigns different colors to the pixels in the fireworks explosion leading to multicolored fireworks, whereas the PV3DParticleRenderer assigns the same color to every particle in the particle system leading to each firework explosion being of one color.
The PV3DRenderer creates new Papervision display object for each particle. This means that each particle could be any 3D object (from a full 3D model to a simple plane) that can be rendered by Papervision. The downside is that is much slower than the other two renderers, and like the PV3DParticleRenderer some of the Flint color actions don’t work.
To demonstrate the differences between the classes I have created a small demo that allows you to select from a number of particle systems and renderers. See the Related Files section below for the links.
This post is part of the series: Papervision 3D Flash programming tutorial
A series of articles that show you how to use the Papervision 3D engine to create Flash 3D effects in your web pages.
- Papervision 3D Programming Tutorial - Loading and Displaying a 3D Model
- Working With Particle Systems in Papervision 3D
- Papervision 3D Programming Tutorial - Modify Textures At Runtime
- Using WOW Physics With Papervision 3D
- Shading in Papervision 3D
- Creating Effects With Papervision 3D
- Animated Textures in Papervision 3D