Main Page
Modules Alphabetical List Data Structures Data Fields
Detailed Description
Crowd Plugin for RenderWare Graphics.
- Requirements
-
The RpCrowd plugin
provides efficient rendering of animated billboard crowds for use
as backgrounds in stadia, racetracks etc.
The plugin should be attached with RpCrowdPluginAttach.
RpCrowd
Concepts
A stadium may contain a number of crowds. These might be for
home and away teams, or for breaking a larger crowd into smaller
regions.
Each crowd is modelled as a number of stadium seating sections
(quads).
In each section, the spectators are displayed by rendering a
number of rows of billboards.
Animation is achieved by changing the texture rendered on each
billboard. On some platforms, this is done by simply offsetting
texture coordinates within a single crowd texture that contains
multiple animation frames.
Crowd Texture Maps
Crowd textures consist of several rows. Each row corresponds to
the same spectators but in different animation states. These
spectators are used to generate an entire crowd, but with random
offsets for each billboard. See RpCrowdTexture for details.
Crowd Animations
Crowd animations are required to specify how the rows of the
crowd texture should be applied to the billboards in sequence. See
RpCrowdAnimation for details.
Crowd Base Atomic
RpCrowd objects are
created from base atomics which specify the crowd seating sections
(quads). These would normally be created in a modelling package
where they can be aligned with a stadium model. Note that atomics
are exported within an RpClump and should be extracted with
RpClumpForAllAtomics. Base atomics
themselves are never rendered.
The base atomic should have a tri-list geometry where pairs of
triangles form quads for the sections. These should be aligned with
the ground as follows:-
back
u0,v0 u1,v0
h1 ----------
| |
| | Viewed from above.
| |
h0 ----------
u0,v1 u1,v1
front (pitch)
texture coordinates: u1 > u0, v1 > v0
height: h1 > h0
The quads need not be rectangular in shape, but the front and
back edges should be horizontal and parallel. The base atomic's
frame is used to position the crowd in world space.
The number of rows of spectators in the quad, and the number of
spectators in a row is based on the texture coordinates and is
controlled by creation parameters. For trapezium shaped sections,
the number of spectators in a row will be scaled to keep a constant
density, but always rounded to a whole number.
Note that quads should not share vertices with other quads.
Creation parameters
A crowd is created using RpCrowdCreate which takes a pointer to
set of creation parameters (RpCrowdParam). The parameter block
specifies the base atomic, the textures and the animations along
with other information such as the spectator density, the up-vector
for the billboards, and the layout of the crowd textures. See
RpCrowdParam for
the details.
Updating animation
Once a crowd has been created, the textures and animation can be
updated using
RpCrowdSetCurrentTexture, RpCrowdSetCurrentAnim,
RpCrowdSetCurrentAnimTime
RpCrowdAddAnimTime
RpCrowdGetCurrentTexture, RpCrowdGetCurrentAnim,
RpCrowdGetCurrentAnimTime
Rendering
Use RpCrowdRender to render a crowd.
Define Documentation
#define
rpCROWDANIMATIONMAXSTEPS (16) |
|
#define
rpCROWDANIMATIONNUMSEQ (4) |
|
Typedef Documentation
|
An RpCrowdTexture is a normal RwTexture organised into a
grid consisting of a row of spectators (columns A to X) in N
different poses (rows 0 to N-1) for animation. The number of
columns (X) should be a power of 2.
+----+----+----+----+----+----+---...----+
| A0 | B0 | C0 | D0 | E0 | F0 | ... X0 |
+----+----+----+----+----+----+---...----+
| A1 | B1 | C1 | D1 | E1 | F1 | ... X1 |
+----+----+----+----+----+----+---...----+
| A2 | B2 | C2 | D2 | E2 | F2 | ... X2 |
+----+----+----+----+----+----+---...----+
| A3 | B3 | C3 | D3 | E3 | F3 | ... X3 |
+----+----+----+----+----+----+---...----+
| A4 | B4 | C4 | D4 | E4 | F4 | ... X4 |
+----+----+----+----+----+----+---...----+
| A5 | B5 | C5 | D5 | E5 | F5 | ... X5 |
+----+----+----+----+----+----+---...----+
| A6 | B6 | C6 | D6 | E6 | F6 | ... X6 |
..........................................
|AN-1|BN-1|CN-1|CN-1|EN-1|FN-1| ...XN-1|
+----+----+----+----+----+----+---...----+
The row of spectators is used over and over again to generate
the whole crowd. A single crowd billboard will start at a random
spectator position along a row and can include any number of
spectators using texture wrapping. For instance, if 'H' is the last
column, an actual billboard might contain 'EFGHABCDEFGHAB'.
Crowd billboards are animated according to an RpCrowdAnimation which
specifies which texture rows to use as time advances. Different
billboards start off at different points in the animation to add to
the randomness.
When an RpCrowd is
created, any number of crowd textures can be registered, and the
application may switch between them using RpCrowdSetCurrentTexture. This might
be used to make the crowd react to certain events, for example.
- See also:
- RpCrowd Plugin
Overview
|
Function Documentation
|
RpCrowdCreate
creates a crowd using the given parameters. See RpCrowdParam for the full list of
parameters that must be specified. By default, the crowd is
initialized to use the first texture and set to time zero for the
first animation.
After this function call, the crowd object does not retain any
dependence on the base atomic, which may be destroyed by the
application.
Also, interal reference counts are added as necessary for the
crowd textures, so these may also be destroyed by the application
after calling this function (see RwTextureDestroy). Some platforms
(PC) convert the textures, and do not require the originals. In
this case, the reference count isn't incremented, and the textures
will be removed from the system when they are destroyed by the
application.
- Parameters:
-
param |
Parameters for the crowd. |
- Returns:
- A pointer to the created crowd, or NULL if an error
occurred.
- See also:
- RpCrowdDestroy
, RpCrowdSetCurrentTexture , RpCrowdGetCurrentTexture ,
RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim ,
RpCrowdSetCurrentAnimTime , RpCrowdGetCurrentAnimTime ,
RpCrowdAddAnimTime
, RpCrowdGetParam ,
RpCrowdRender ,
RpCrowdPluginAttach
, RpCrowd Plugin
Overview
|
RwBool RpCrowdPluginAttach |
( |
void |
|
) |
|
|
© 1993-2003 Criterion Software Limited. All
rights reserved. Built Tue Apr 22 12:46:24 2003. Send Feedback