Game Development Reference
In-Depth Information
D3DRS_POINTSIZE_MAX —Specifies the maximum size that a
point sprite can be. Here is an example of setting the maximum to
5.0:
_device->SetRenderState(D3DRS_POINTSIZE_MAX, d3d::FtoDw(5.0f));
D3DRS_POINTSCALE_A , D3DRS_POINTSCALE_B , D3DRS_
POINTSCALE_C —These three constants control how a point
sprite's size changes with distance—the distance being the dis-
tance from the point sprite to the camera.
Direct3D uses the following formula to calculate the final size of a point
sprite based on distance and these constants:
1
FinalSize
ViewportHe
ight
Size
2
A
B
D
C
D
where:
FinalSize : The final size of the point sprite after the distance
calculations
ViewportHeight : The height of the viewport
Size : Corresponds to the value specified by the D3DRS_POINT-
SIZE render state
A , B , C : Correspond to the values specified by D3DRS_POINT-
SCALE_A , D3DRS_POINTSCALE_B , and D3DRS_POINTSCALE_C ,
respectively
D : The distance of the point sprite in view space to the camera's
position. Since the camera is positioned at the origin in view space,
this value is Dxy
2
2
z
2
, where ( x , y , z ) is the position of
the point sprite in view space.
The following code sets the point sprite distance constants so that the
point sprites will get smaller with distance:
_device->SetRenderState(D3DRS_POINTSCALE_A, d3d::FtoDw(0.0f));
_device->SetRenderState(D3DRS_POINTSCALE_B, d3d::FtoDw(0.0f));
_device->SetRenderState(D3DRS_POINTSCALE_C, d3d::FtoDw(1.0f));
14.1.3 Particles and Their Attributes
A particle consists of many more attributes than its position and color;
for instance, a particle has a certain velocity. However, these additional
attributes are not needed to render the particle. Therefore, we keep the
data needed to render a particle and particle attributes in separate
structures. When we are creating, destroying, and updating particles,
Search WWH ::




Custom Search