Game Development Reference
In-Depth Information
14.3.1 Sample Application: Snow
Figure 14.2: A
screen shot of
the Snow sample
The Snow system's class is defined as:
class Snow : public PSystem
{
public:
Snow(d3d::BoundingBox* boundingBox, int numParticles);
void resetParticle(Attribute* attribute);
void update(float timeDelta);
};
Remark: Notice how simple the interface is for the Snow system
because the parent class takes care of most of the work. In fact, all
three of the particle systems that we implement in this section have
simple interfaces and are relatively easy to implement.
The constructor takes a pointer to a bounding box structure and the
number of particles the system will have. The bounding box describes
the volume that the snowflakes will fall in. If the snowflakes go outside
this volume, they are killed and respawned. This way, the Snow system
always has the same amount of particles active. The constructor is
implemented as follows:
Snow::Snow(d3d::BoundingBox* boundingBox, int numParticles)
{
_boundingBox
= *boundingBox;
_size
= 0.8f;
_vbSize
= 2048;
_vbOffset
= 0;
_vbBatchSize
= 512;
Search WWH ::




Custom Search