Saturday, August 22, 2009

Masked Collision & Turbulent Pixels



View example





View example

Stardust project homepage

Here are two more examples for Stardust.

The first one demonstrates the particle masking feature: each particle is assigned an integer mask, and two particles would only collide against each other if the bitwise-AND of their masks is non-zero. In this example, red particles are given a mask of (1 | 2 | 4), green ones 2, and blue ones 4. The result is that each particle collides with others of the same color; moreover, red particles also collide with particles of the other two colors. You can notice that a green particle does not collide with a blue particle, since the bitwise-AND of 2 and 4 is zero.

The second example shows the PixelRenderer class in action. This class renders pixels into a BitmapData object. The turbulence effect is created using Perlin noise along with a BitmapField object used as a gravity field.

No comments: