IDelegate Class Reference

Search for all occurrences

Detailed Description

An interface class to the delegate.

The class provides functions to directly query specific delegate information. It is mainly intended to be used by a crowd behavior plugin. This class can be returned by calling the method GetInterface() from a Delegate node. For Example:

 Sample Code, starting with an INode(node)

     Object *o = node->GetObjectRef();
     if ((o->ClassID() == DELEG_CLASS_ID)
     {

         // Get the Delegate Export Interface from the node 
         IDelegate *Iface = (IDelegate *) o->GetInterface(I_DELEGINTERFACE);

         // Get the delegate's average speed at time t
         float AverageSpeed = Iface->GetAverageSpeed(t);
     }
        
    // Release the interface. NOTE that this function is currently inactive under MAX.
    //o->ReleaseInterface(I_DELEGINTERFACE,Iface);

#include <delegexp.h>

Inheritance diagram for IDelegate:
Inheritance graph
[legend]

List of all members.

Public Member Functions

Delegate Parameter Query Functions

These functions query the delegate about the values of its parameters, all of which appear in the delegate�s modify panel interface.

virtual DELEGexport BOOL  IsConstrainedInZ ()
  Queries whether the delegate is constrained in the Z plane.
virtual DELEGexport float  GetAverageSpeed (TimeValue t)
  Gets the average speed of the delegate.
virtual DELEGexport float  GetMaxAccel (TimeValue t)
  Gets the maximum acceleration of the delegate.
virtual DELEGexport float  GetMaxHeadingVel (TimeValue t)
  Gets the maximum heading velocity of the delegate.
virtual DELEGexport float  GetMaxHeadingAccel (TimeValue t)
  Gets the maximum heading acceleration of the delegate.
virtual DELEGexport float  GetMaxPitchVel (TimeValue t)
  Gets the maximum pitch velocity of the delegate.
virtual DELEGexport float  GetMaxPitchAccel (TimeValue t)
  Gets the maximum pitch acceleration of the delegate.
virtual DELEGexport float  GetMaxIncline (TimeValue t)
  Gets the maximum incline angle of the delegate.
virtual DELEGexport float  GetMaxDecline (TimeValue t)
  Gets the maximum decline angle of the delegate.
virtual DELEGexport BOOL  OkToDisplayMyForces ()
  Queries if the the delegate should display the forces acting upon it during a simulation.
virtual DELEGexport BOOL  OkToDisplayMyVelocity ()
  Queries if the delegate should display its velocity during a simulation.
virtual DELEGexport BOOL  OkToDisplayMyCogStates ()
  Queries if the delegate should display its cognitive controller state during a simulation.
Position, Speed, Velocity, Transform Matrix during Simulation
virtual DELEGexport Matrix3  GetTM (INode *node, TimeValue t)
  This function should be used instead of calling GetNodeTM during a simulation loop.
virtual DELEGexport Point3  GetCurrentPosition ()
  Gets the position of the delegate.
virtual DELEGexport Point3  GetCurrentVelocity ()
  Gets the velocity of the delegate.
virtual DELEGexport Point3  GetPreviousVelocity ()
  Gets the previous velocity of the delegate.
virtual DELEGexport float  GetCurrentSpeed ()
  Gets the speed of the delegate.
virtual DELEGexport Point3  GetSimStartVelocity (INode *n, TimeValue StartTime)
  Gets the delegate's velocity at the start of a simulation.
Display Functions during Simulation

During a simulation, a behavior might want to display some information.

For instance, the Pathfollow behavior displays the target on the path. The IDelegate class has some functions for displaying simple primitives during the simulation. These should be called from within a behavior's Perform, Constrain, or Orient function, since those are called per frame per delegate during a simulation.

virtual DELEGexport void  LineDisplay (Point3 &pt1, Point3 &pt2, Color clr, BOOL scale)
  Draws a line segment while the simulation is running.
virtual DELEGexport void  BboxDisplay (Point3 &pt1, Point3 &pt2, Color clr)
  Draws a bounding box while the simulation is running.
virtual DELEGexport void  SphereDisplay (Point3 &pt1, float radius, Color clr)
  Draws a sphere while the simulation is running.
virtual DELEGexport void  TextDisplay (Point3 &pt1, Color clr, const MCHAR *str)
  Draws text while the simulation is running.
Miscellanious Functions
virtual DELEGexport BOOL  IsComputing ()
  Queries whether the delegate is currently active in a running crowd simulation.
virtual DELEGexport BOOL  IsAssignmentActive (int AssignIndex, TimeValue t)
  Queries whether a particular assignment is active at a particular time.
virtual DELEGexport int  GetIndex ()
  Get the delegate's identifier.
virtual DELEGexport int  GetRandId ()
  Gets a random id to generate varying behavior for different delegates performing the same behavior.
virtual DELEGexport BOOL  ComputingBiped ()
  Queries the whether the delegate is associated with a computing biped.
virtual DELEGexport BOOL  ReactToMe ()
  This function is used internally.
virtual DELEGexport void  ClearBacktracking ()
  This function is used internally.
virtual DELEGexport BOOL  NeedsBacktracking ()
  This function is used internally.
virtual DELEGexport void  SetBacktracking (int frame)
  This function is used internally.
virtual DELEGexport  ~IDelegate ()

Constructor & Destructor Documentation

virtual DELEGexport ~IDelegate ( ) [inline, virtual]
{}  

Member Function Documentation

virtual DELEGexport BOOL IsConstrainedInZ ( ) [inline, virtual]

Queries whether the delegate is constrained in the Z plane.

Returns:
true if the delegate is constrained to the z plane, false if not
{return FALSE;}
virtual DELEGexport float GetAverageSpeed ( TimeValue  t ) [inline, virtual]

Gets the average speed of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the average speed of the delegate
{return 1.0;}
virtual DELEGexport float GetMaxAccel ( TimeValue  t ) [inline, virtual]

Gets the maximum acceleration of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum acceleration of the delegate
{return 1.0;}
virtual DELEGexport float GetMaxHeadingVel ( TimeValue  t ) [inline, virtual]

Gets the maximum heading velocity of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum heading velocity of the delegate, in degrees. This is shown as the Max Turn Velocity in the delegate's interface.
{return 1.0;}
virtual DELEGexport float GetMaxHeadingAccel ( TimeValue  t ) [inline, virtual]

Gets the maximum heading acceleration of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum heading acceleration of the delegate, in degrees. This is shown as the Max Turn Accel in the delegate's interface.
{return 1.0;}
virtual DELEGexport float GetMaxPitchVel ( TimeValue  t ) [inline, virtual]

Gets the maximum pitch velocity of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum pitch velocity of the delegate, in degrees. This is shown as the Max Turn Velocity in the delegate's interface.
{return 1.0;}
virtual DELEGexport float GetMaxPitchAccel ( TimeValue  t ) [inline, virtual]

Gets the maximum pitch acceleration of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum pitch acceleration of the delegate, in degrees. This is shown as the Max Turn Accel in the delegate's interface.
{return 1.0;}
virtual DELEGexport float GetMaxIncline ( TimeValue  t ) [inline, virtual]

Gets the maximum incline angle of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum incline angle of the delegate, in degrees
{return 1.0;}
virtual DELEGexport float GetMaxDecline ( TimeValue  t ) [inline, virtual]

Gets the maximum decline angle of the delegate.

Parameters:
[in] t - the time to retrieve the value
Returns:
the maximum decline angle of the delegate, in degrees
{return 1.0;}
virtual DELEGexport BOOL OkToDisplayMyForces ( ) [inline, virtual]

Queries if the the delegate should display the forces acting upon it during a simulation.

If this returns true, and the behavior has a force to display, then the behavior plugin is expected to display its force during the Perform function, by calling the IDelegate's LineDisplay function.

Returns:
true if the delegate's Show Forces checkbox is checked, false if not.
{return 1;}
virtual DELEGexport BOOL OkToDisplayMyVelocity ( ) [inline, virtual]

Queries if the delegate should display its velocity during a simulation.

Returns:
true if the delegate's Show Velocity checkbox is checked, false if not. This is probably not needed by any behavior plugins, since velocity display is performed by the crowd system.
{return 1;}
virtual DELEGexport BOOL OkToDisplayMyCogStates ( ) [inline, virtual]

Queries if the delegate should display its cognitive controller state during a simulation.

Returns:
true if the delegate's Show Cog Control States checkbox is checked, false if not. This is probably not needed by any behavior plugins, since cog control states are displayed by the crowd system.
{return 1;}
virtual DELEGexport Matrix3 GetTM ( INode node,
TimeValue  t 
) [inline, virtual]

This function should be used instead of calling GetNodeTM during a simulation loop.

This function must be called to get the transform, because internally as an optimization, the Crowd system caches the delegate's positions and doesn't set the Node's MAX transform until after the simulation is done running. If for some reason (based on the active flag, backtracking, etc) this function determines that the delegate's values are not cached, it will then call GetNodeTM. So it is always best to use this function to get the delegate's TM, particularly during the Perform, Constrain, or Orient function of a behavior, which are only called during a Crowd simulation.

Parameters:
[in] node - The delegate's node.
[in] t - the time to retrieve the value.
Returns:
the transformation matrix of the delegate in world space at the current frame in the simulation.
{return Matrix3();}
virtual DELEGexport Point3 GetCurrentPosition ( ) [inline, virtual]

Gets the position of the delegate.

Returns:
the position of the delegate in world space at the current frame in the simulation
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport Point3 GetCurrentVelocity ( ) [inline, virtual]

Gets the velocity of the delegate.

Returns:
the velocity of the delegate at the current frame in the simulation. It may or may not be normalized. If not, it's length is equal to it's current speed.
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport Point3 GetPreviousVelocity ( ) [inline, virtual]

Gets the previous velocity of the delegate.

Returns:
the velocity of the delegate at the previous frame in the simulation.
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport float GetCurrentSpeed ( ) [inline, virtual]

Gets the speed of the delegate.

Returns:
the speed of the delegate at the current frame in the simulation
{return 1.0;}
virtual DELEGexport Point3 GetSimStartVelocity ( INode n,
TimeValue  StartTime 
) [inline, virtual]

Gets the delegate's velocity at the start of a simulation.

If the node is a delegate and the start time is the simulation start time, this will return the initial velocity of the delegate, exactly as the Crowd system computes it. This function is particularly useful to call from within a behavior's InitBeforeSim function, in order to make sure the behavior is perfectly repeatable.

Parameters:
[in] n - the node that the velocity is to be calculated for
[in] StartTime - the time to retrieve the value
Returns:
the velocity of the node at a given start time
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport void LineDisplay ( Point3 pt1,
Point3 pt2,
Color  clr,
BOOL  scale 
) [inline, virtual]

Draws a line segment while the simulation is running.

Parameters:
[in] pt1 - the start position of the line segment in world space
[in] pt2 - the end position of the line segment in world space
[in] clr - the color of the line
[in] scale - whether or not the line should be scaled by the Vector Scale value specified in the Crowd Solve rollout.
{}
virtual DELEGexport void BboxDisplay ( Point3 pt1,
Point3 pt2,
Color  clr 
) [inline, virtual]

Draws a bounding box while the simulation is running.

Parameters:
[in] pt1 - the minimum point of the bounding box in world space
[in] pt2 - the maximum point of the bounding box in world space
[in] clr - the color of the bounding box
{}
virtual DELEGexport void SphereDisplay ( Point3 pt1,
float  radius,
Color  clr 
) [inline, virtual]

Draws a sphere while the simulation is running.

Parameters:
[in] pt1 - the center point of the sphere in world space.
[in] radius - the radius of the sphere.
[in] clr - the color of the sphere.
{}
virtual DELEGexport void TextDisplay ( Point3 pt1,
Color  clr,
const MCHAR *  str 
) [inline, virtual]

Draws text while the simulation is running.

Parameters:
[in] pt1 - the world position of where the text will start
[in] clr - the color of the text
[in] str - the string of text that will be printed
{}
virtual DELEGexport BOOL IsComputing ( ) [inline, virtual]

Queries whether the delegate is currently active in a running crowd simulation.

Returns:
true if the delegate is currently active in a running crowd simulation, false if not
{return FALSE;}
virtual DELEGexport BOOL IsAssignmentActive ( int  AssignIndex,
TimeValue  t 
) [inline, virtual]

Queries whether a particular assignment is active at a particular time.

This is a way to ask the Crowd system whether or not a particular assignment is active at a particular frame. It is not really related to this particular delegate, but since internally the delegate has access to the crowd, it is used to get this information. Typically, this is called from within BaseBehavior::InitBeforeSim to see whether or not an assignment was active at a particular point in time during the simulation. !

Parameters:
[in] AssignIndex - an index into the list of behavior assignments in the Behavior Assignments dialog !
[in] t - the time to retrieve the value !
Returns:
true if the assignment is active at this time, false if not.
{return TRUE;}
virtual DELEGexport int GetIndex ( ) [inline, virtual]

Get the delegate's identifier.

Returns:
an integer > 0, that is an unique identifier for a delegate while a crowd simulation is running.
{return 0;}
virtual DELEGexport int GetRandId ( ) [inline, virtual]

Gets a random id to generate varying behavior for different delegates performing the same behavior.

Returns:
an integer value > 0 that specifies a number that can be used as part of a seed when calculating random numbers from within a behavior. For instance, this number is used by the pathfollow, speedvary, surfacearrive, and wander behaviors. For behaviors which use the RandId, two or more delegates that have the same RandId will exhibit the same random behavior. Unless the RandId has been specifically changed by the user, it will be unique for all delegates. The Crowd system assures this.
{return 0;}
virtual DELEGexport BOOL ComputingBiped ( ) [inline, virtual]

Queries the whether the delegate is associated with a computing biped.

Returns:
true if this delegate is associated with a biped whose crowd motion is currently being computed, false if not
{return FALSE;}
virtual DELEGexport BOOL ReactToMe ( ) [inline, virtual]

This function is used internally.

{return FALSE;} 
virtual DELEGexport void ClearBacktracking ( ) [inline, virtual]

This function is used internally.

{}
virtual DELEGexport BOOL NeedsBacktracking ( ) [inline, virtual]

This function is used internally.

{return FALSE;}
virtual DELEGexport void SetBacktracking ( int  frame ) [inline, virtual]

This function is used internally.

{}

IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate
IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate IDelegate