Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RpCrowd
[FXPack]


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)

Detailed Description

Crowd Plugin for RenderWare Graphics.

RpCrowd Plugin Overview

Requirements

Overview

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)
 

rpCROWDANIMATIONMAXSTEPS defines the maximum number of steps in an RpCrowdAnimation sequence.

#define rpCROWDANIMATIONNUMSEQ   (4)
 

rpCROWDANIMATIONNUMSEQ defines the number of animation sequences in an RpCrowdAnimation.


Typedef Documentation

typedef RwTexture RpCrowdTexture
 

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

RpCrowd* RpCrowdAddAnimTime RpCrowd   crowd,
RwReal    time
 

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.

Parameters:
crowd  A pointer to the crowd.
time  Time increment; this must be non-negative
Returns:
Returns a pointer to the crowd.
See also:
RpCrowdSetCurrentAnimTime , RpCrowdGetCurrentAnimTime , RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim , RpCrowd Plugin Overview
RpCrowd* RpCrowdCreate RpCrowdParam   param
 

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 RpCrowdDestroy RpCrowd   crowd
 

RpCrowdDestroy destroys a crowd. This will also destroy any textures used by the crowd (assuming they are not referenced elsewhere).

Parameters:
crowd  A pointer to the crowd to be destroyed.
Returns:
TRUE on success, FALSE otherwise
See also:
RpCrowdCreate , RpCrowdPluginAttach , RpCrowd Plugin Overview
RwUInt32 RpCrowdGetCurrentAnim RpCrowd   crowd
 

RpCrowdGetCurrentAnim returns the index of the RpCrowdAnimation currently in use by an RpCrowd. The array of animations is registered during a call to RpCrowdCreate.

Parameters:
crowd  A pointer to the crowd.
Returns:
Index of the animation currently in use.
See also:
RpCrowdSetCurrentAnim , RpCrowdSetCurrentAnimTime , RpCrowdGetCurrentAnimTime , RpCrowdSetCurrentTexture , RpCrowdGetCurrentTexture , RpCrowdGetParam , RpCrowdCreate , RpCrowd Plugin Overview
RwReal RpCrowdGetCurrentAnimTime RpCrowd   crowd
 

RpCrowdGetCurrentAnimTime returns the current position within an RpCrowdAnimation for the given RpCrowd. This is updated using RpCrowdAddAnimTime, or set explicitly using RpCrowdSetCurrentAnimTime.

Parameters:
crowd  A pointer to the crowd.
Returns:
Returns the time within the animation.
See also:
RpCrowdAddAnimTime , RpCrowdSetCurrentAnimTime , RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim , RpCrowd Plugin Overview
RwUInt32 RpCrowdGetCurrentTexture RpCrowd   crowd
 

RpCrowdGetCurrentTexture returns the index of the texture currently being used for displaying a crowd. The texture array is registered with RpCrowdCreate.

Parameters:
crowd  Pointer to the crowd.
Returns:
The index of the texture in use.
See also:
RpCrowdSetCurrentTexture , RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim , RpCrowdGetParam , RpCrowdCreate , RpCrowd Plugin Overview
const RpCrowdParam* RpCrowdGetParam const RpCrowd   crowd
 

RpCrowdGetParam returns a pointer to the parameters giving the current state of the specified crowd (read only).

Parameters:
crowd  A pointer to a crowd.
Returns:
Returns a pointer to the parameter for the crowd.
See also:
RpCrowdCreate , RpCrowdSetCurrentTexture , RpCrowdSetCurrentAnim , RpCrowdSetCurrentAnimTime , RpCrowdAddAnimTime , RpCrowdPluginAttach , RpCrowd Plugin Overview
RwBool RpCrowdPluginAttach void   
 

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.

Returns:
TRUE if successful, FALSE if an error occurs.
See also:
RpCrowdCreate , RpCrowd Plugin Overview
RpCrowd* RpCrowdRender RpCrowd   crowd
 

RpCrowdRender renders a crowd.

Parameters:
crowd  A pointer to the crowd.
Returns:
Returns a pointer to the crowd.
See also:
RpCrowdCreate , RpCrowd Plugin Overview
RpCrowd* RpCrowdSetCurrentAnim RpCrowd   crowd,
RwUInt32    index
 

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.

Parameters:
crowd  A pointer to the crowd.
index  Index of the new animation.
Returns:
Returns a pointer to the crowd.
See also:
RpCrowdGetCurrentAnim , RpCrowdSetCurrentAnimTime , RpCrowdGetCurrentAnimTime , RpCrowdSetCurrentTexture , RpCrowdGetCurrentTexture , RpCrowdGetParam , RpCrowdCreate , RpCrowd Plugin Overview
RpCrowd* RpCrowdSetCurrentAnimTime RpCrowd   crowd,
RwReal    time
 

RpCrowdSetCurrentAnimTime sets the current time of the crowd animation. This should lie between zero and the duration of the RpCrowdAnimation.

Parameters:
crowd  A pointer to the crowd.
time  Animation time.
Returns:
Returns a pointer to the crowd.
See also:
RpCrowdGetCurrentAnimTime , RpCrowdAddAnimTime , RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim , RpCrowdCreate , RpCrowd Plugin Overview
RpCrowd* RpCrowdSetCurrentTexture RpCrowd   crowd,
RwUInt32    index
 

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

  • crowd reactions to events
  • different clothes worn by supporters of different teams
It may be combined with a change in animation using RpCrowdSetCurrentAnim.
Parameters:
crowd  Pointer to the crowd.
index  Index of the new texture to use.
Returns:
Returns a pointer to the crowd.
See also:
RpCrowdGetCurrentTexture , RpCrowdSetCurrentAnim , RpCrowdGetCurrentAnim , RpCrowdGetParam , RpCrowdCreate , RpCrowd Plugin Overview

Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:24 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)