Game Development Reference
In-Depth Information
14.1.1 Structure Format
We use the following vertex structure to describe the location and color
of our particles:
struct Particle
{
D3DXVECTOR3 _position;
D3DCOLOR _color;
static const DWORD FVF;
};
const DWORD Particle::FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
The structure simply stores the position of the particle and its color.
Depending on your application needs, you could also store a set of tex-
ture coordinates. We discuss texturing the point sprites in the next
section.
It is possible to add a floating-point variable to the Particle
structure to specify the size of the particle. We must add the D3DFVF_
PSIZE flag to our flexible vertex format to reflect this addition. Having
each particle maintain its own size is useful because it allows us to
specify and change the size of a particle on an individual basis. How-
ever, most graphics cards do not support controlling the size of the
particle this way so we avoid it. (Check the D3DFVFCAPS_PSIZE bit in
the FVFCaps member of the D3DCAPS9 structure to verify.) Instead,
we control the particle size with render states, as you soon see. An
example of a vertex structure with a size member:
struct Particle
{
D3DXVECTOR3 _position;
D3DCOLOR _color;
float _size;
static const DWORD FVF;
};
const DWORD Particle::FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE |
D3DFVF_PSIZE;
We note that it is possible to obtain per-particle size manipulation
through a vertex shader, even if D3DFVFCAPS_PSIZE is not supported.
Vertex shaders are covered in Part IV of this text.
14.1.2 Point Sprite Render States
The behavior of point sprites is largely controlled through render
states. Let's review these render states now.
D3DRS_POINTSPRITEENABLE —A Boolean value. The default
value is false.
Search WWH ::




Custom Search