Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Aviary Class Reference

Class to store behavior for a group of boids. More...

#include <Aviary.h>

List of all members.

Public Methods

 Aviary (BoidType m_boidType, char *modelFileName, char *textureFile, char *renderStyleSet, float scale, float mass, float maxVelocity, float maxAcceleration, bool circleDirection)
 Constructor to set up an Aviary. More...

virtual ~Aviary ()
void Behave (HOBJECT hObject, float fFrameTime)
 Call this function on each frame from each boid. More...

LTRESULT GenBoid (LTVector3f startPoint)
 Generate a boid in this aviary. More...

LTRESULT KillBoid ()
 Remove a boid from this aviary. More...

LTRESULT KillBoid (CBoidModel *pBoid)
 Remove a specified boid from this aviary. More...

void setSeekPoint (const LTVector3f &dest)
void getSeekPoint (LTVector3f *dest)
void setSeekPoint (BoidDestination which, LTVector3f &dest)
 Sets the vector associated with the specified destination. More...

void getSeekPoint (BoidDestination which, LTVector3f *dest)
LTVector3f getSeekPoint (BoidDestination which)
 Returns the vector associated with the specified destination. More...

void setSeekPointWeight (BoidDestination which, float weight)
 Sets the current weight associated with the specified destination. More...

float getSeekPointWeight (BoidDestination which)
 Returns the current weight associated with the specified destination. More...

void setRadius (float rad)
 Defines the radius of a boid in this aviary. More...

float getRadius ()
 Returns the defined radius of a boid in this aviary. More...

int getNumBoids ()
 Returns number of boids presently in this aviary. More...

void setMaxSpeed (const float &x)
void setMaxForce (const float &x)
float getMaxSpeed ()
float getMaxForce ()
void populateDefaultAviary ()
 Generates a prototype aviary with reasonable values. More...


Protected Methods

void issueNewSeekPoint (LTVector3f *dest)
 Copy the next seekpoint into *dest. More...

BoidDestination selectNewSeekPoint ()
 Returns a new BoidDestination based on internal weights. More...

void initInternalOCS (BoidType m_boidType, char *modelFileName, char *textureFile, char *renderStyleSet, float scale, float mass, float maxVelocity, float maxAcceleration)
void BirdHasReachedPoint (CBoidModel *pBoid)
 Updates the state machine for a boid's destination and behavior. More...


Protected Attributes

BoidBehavior m_style
 Current behavior pursued by all boids in this aviary. More...

LTVector3f m_seekPoints [AV_NUMSEEKPOINTS]
 An internal array of all possible destinations this aviary is concerned with. More...

float m_seekPointWeights [AV_NUMSEEKPOINTS]
 Weights used for the random selection of next seekpoint. More...

float m_maxSpeed
float m_maxForce
float m_birdRadius
bool m_bCircleDirection
BoidType m_boidType
vector< CBoidModel * > m_boids
ObjectCreateStruct m_ocs
 Object creation structure for all boids generated by this aviary. More...

float m_weight


Detailed Description

Class to store behavior for a group of boids.

For reasons of efficiency we prefer to store all the behavior state for a group of boids that behave identically in one place. This includes current destination and the list of objects to be avoided. This means we can change current destinations without having to iterate over all the boids in the engine.

Author:
Ruskin, Parise, and Palmer


Constructor & Destructor Documentation

Aviary::Aviary BoidType    m_boidType,
char *    modelFileName,
char *    textureFile,
char *    renderStyleSet,
float    scale,
float    mass,
float    maxVelocity,
float    maxAcceleration,
bool    circleDirection
 

Constructor to set up an Aviary.

This is the full constructor used to create an aviary which may then spawn boids. Each aviary defines one style of boid and boid behavior, and remembers the modeltype associated with each type of boid so that new ones may be instantiated properly.

Parameters:
m_boidType  See BoidType enum
modelFileName  Pointer to a string containing the filename of the .ltb corresponding to this boid
textureFile  Pointer to a string containing the skin's filename
renderStyleSet  Not presently used
scale  Scaling factor for the .ltb model upon load
mass  Used in collision detection (?)
maxVelocity  Maximum velocity for this kind of boid
maxAcceleration  Maximum acceleration per frame for this kind of boid
circleDirection  Direction in which boids will circle (true == clockwise)

Aviary::~Aviary   [virtual]
 


Member Function Documentation

Aviary::Behave HOBJECT    hObject,
float    fFrameTime
 

Call this function on each frame from each boid.

This function alters the current velocity and orientation of a boid according to the appropriate logic and state.

Parameters:
hObject  Handle the the boid object
fFrameTime  delta-t used for accumulation of velocity
Todo:
Optimize algorithm for SeparationSeek

void Aviary::BirdHasReachedPoint CBoidModel   pBoid [protected]
 

Updates the state machine for a boid's destination and behavior.

This function basically handles the state-machine gobbledygook of what happens when a boid gets to where it's going. It should only be called from inside Aviary::Behave

Parameters:
pBoid  Pointer to the operable boid model

LTRESULT Aviary::GenBoid LTVector3f    startPoint
 

Generate a boid in this aviary.

Creates a new boid within this aviary, with the same behaviour and model as all the other boids in this aviary.

Parameters:
startPoint  Point in space at which boid is instantiated.

float Aviary::getMaxForce   [inline]
 

float Aviary::getMaxSpeed   [inline]
 

int Aviary::getNumBoids   [inline]
 

Returns number of boids presently in this aviary.

float Aviary::getRadius   [inline]
 

Returns the defined radius of a boid in this aviary.

LTVector3f Aviary::getSeekPoint BoidDestination    which [inline]
 

Returns the vector associated with the specified destination.

void Aviary::getSeekPoint BoidDestination    which,
LTVector3f *    dest
[inline]
 

Retrieves the vector associated with the specified destination

Parameters:
which  Destination to be written into *dest
dest  Overwritten with the requested BoidDestination

void Aviary::getSeekPoint LTVector3f *    dest [inline]
 

Retrieves the first destination in the aviary

Deprecated:
use getSeekPoint(BoidDestination which,LTVector3f *dest)

float Aviary::getSeekPointWeight BoidDestination    which [inline]
 

Returns the current weight associated with the specified destination.

void Aviary::initInternalOCS BoidType    m_boidType,
char *    modelFileName,
char *    textureFile,
char *    renderStyleSet,
float    scale,
float    mass,
float    maxVelocity,
float    maxAcceleration
[protected]
 

Populates the internal ObjectCreateStruct

Be extremely careful with this one. It's meant to be used by the constructor to set up the internal data structure that's used to generate all the boids that come from this aviary.

void Aviary::issueNewSeekPoint LTVector3f *    dest [protected]
 

Copy the next seekpoint into *dest.

Deprecated:
Use selectNewSeekPoint() instead.

LTRESULT Aviary::KillBoid CBoidModel   pBoid
 

Remove a specified boid from this aviary.

Parameters:
pBoid  pointer to the bird you want to go away

LTRESULT Aviary::KillBoid  
 

Remove a boid from this aviary.

Removes an existing boid from this aviary. At the moment, the last boid that was created is the one that is removed.

void Aviary::populateDefaultAviary  
 

Generates a prototype aviary with reasonable values.

BoidDestination Aviary::selectNewSeekPoint   [protected]
 

Returns a new BoidDestination based on internal weights.

Intended to be called from within the Aviary, this function returns a random BoidDestination based on the internal probability weightings (which are presumably derived from the player ratings). This function does not have side effects; it simply rolls a die and returns an enum.

Returns:
A suggested BoidDestination.

void Aviary::setMaxForce const float &    x [inline]
 

void Aviary::setMaxSpeed const float &    x [inline]
 

void Aviary::setRadius float    rad [inline]
 

Defines the radius of a boid in this aviary.

void Aviary::setSeekPoint BoidDestination    which,
LTVector3f &    dest
[inline]
 

Sets the vector associated with the specified destination.

void Aviary::setSeekPoint const LTVector3f &    dest [inline]
 

Sets the first destination in the aviary

Deprecated:
use setSeekPoint(BoidDestination which,LTVector3f &dest)

void Aviary::setSeekPointWeight BoidDestination    which,
float    weight
[inline]
 

Sets the current weight associated with the specified destination.


Member Data Documentation

bool Aviary::m_bCircleDirection [protected]
 

float Aviary::m_birdRadius [protected]
 

vector<CBoidModel *> Aviary::m_boids [protected]
 

BoidType Aviary::m_boidType [protected]
 

float Aviary::m_maxForce [protected]
 

float Aviary::m_maxSpeed [protected]
 

ObjectCreateStruct Aviary::m_ocs [protected]
 

Object creation structure for all boids generated by this aviary.

LTVector3f Aviary::m_seekPoints[AV_NUMSEEKPOINTS] [protected]
 

An internal array of all possible destinations this aviary is concerned with.

float Aviary::m_seekPointWeights[AV_NUMSEEKPOINTS] [protected]
 

Weights used for the random selection of next seekpoint.

BoidBehavior Aviary::m_style [protected]
 

Current behavior pursued by all boids in this aviary.

float Aviary::m_weight [protected]
 


The documentation for this class was generated from the following files:
Generated on Mon Mar 4 08:42:25 2002 for Aria by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002