Data Structures | |
| struct | RpCrowd |
| struct | RpCrowdAnimation |
| struct | RpCrowdParam |
Defines | |
| #define | rpCROWDANIMATIONNUMSEQ (4) |
| #define | rpCROWDANIMATIONMAXSTEPS (16) |
Typedefs | |
| typedef RwTexture | RpCrowdTexture |
Functions | |
| RwBool | RpCrowdPluginAttach (void) |
| RpCrowd * | RpCrowdCreate (RpCrowdParam *param) |
| RwBool | RpCrowdDestroy (RpCrowd *crowd) |
| const RpCrowdParam * | RpCrowdGetParam (const RpCrowd *crowd) |
| RpCrowd * | RpCrowdAddAnimTime (RpCrowd *crowd, RwReal time) |
| RpCrowd * | RpCrowdRender (RpCrowd *crowd) |
| RpCrowd * | RpCrowdSetCurrentTexture (RpCrowd *crowd, RwUInt32 index) |
| RwUInt32 | RpCrowdGetCurrentTexture (RpCrowd *crowd) |
| RpCrowd * | RpCrowdSetCurrentAnim (RpCrowd *crowd, RwUInt32 index) |
| RwUInt32 | RpCrowdGetCurrentAnim (RpCrowd *crowd) |
| RpCrowd * | RpCrowdSetCurrentAnimTime (RpCrowd *crowd, RwReal time) |
| RwReal | RpCrowdGetCurrentAnimTime (RpCrowd *crowd) |
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
RpCrowdGetCurrentTexture, RpCrowdGetCurrentAnim, RpCrowdGetCurrentAnimTime
Rendering
Use RpCrowdRender to render a crowd.
|
|
rpCROWDANIMATIONMAXSTEPS defines the maximum number of steps in an RpCrowdAnimation sequence. |
|
|
rpCROWDANIMATIONNUMSEQ defines the number of animation sequences in an RpCrowdAnimation. |
|
|
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.
|
|
||||||||||||
|
RpCrowdAddAnimTime increments the current time of a crowd animation. Once the time reaches the duration of the animation, it will automatically loop back to the start. The current time may be retrieved using RpCrowdGetCurrentAnimTime.
|
|
|
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.
|
|
|
RpCrowdDestroy destroys a crowd. This will also destroy any textures used by the crowd (assuming they are not referenced elsewhere).
|
|
|
RpCrowdGetCurrentAnim returns the index of the RpCrowdAnimation currently in use by an RpCrowd. The array of animations is registered during a call to RpCrowdCreate.
|
|
|
RpCrowdGetCurrentAnimTime returns the current position within an RpCrowdAnimation for the given RpCrowd. This is updated using RpCrowdAddAnimTime, or set explicitly using RpCrowdSetCurrentAnimTime.
|
|
|
RpCrowdGetCurrentTexture returns the index of the texture currently being used for displaying a crowd. The texture array is registered with RpCrowdCreate.
|
|
|
RpCrowdGetParam returns a pointer to the parameters giving the current state of the specified crowd (read only).
|
|
|
RpCrowdPluginAttach is used to attach the Crowd plugin to the RenderWare system. The plugin must be attached between initializing the system with RwEngineInit and opening it with RwEngineOpen.
|
|
|
RpCrowdRender renders a crowd.
|
|
||||||||||||
|
RpCrowdSetCurrentAnim sets the crowd animation to one of the set of animations registered during RpCrowdCreate, according to the given index. The animation may be switched at runtime to change crowd behavior, such as reactions to events. This may be combined with a change in texture as set by RpCrowdSetCurrentTexture.
|
|
||||||||||||
|
RpCrowdSetCurrentAnimTime sets the current time of the crowd animation. This should lie between zero and the duration of the RpCrowdAnimation.
|
|
||||||||||||
|
RpCrowdSetCurrentTexture sets the current crowd texture to one of the set of textures registered with RpCrowdCreate according to the specified index. This may be switched at runtime to model
|
© 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:47:00 2004.
Send Feedback