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>
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 () |
virtual DELEGexport ~IDelegate | ( | ) | [inline, virtual] |
{}
virtual DELEGexport BOOL IsConstrainedInZ | ( | ) | [inline, virtual] |
Queries whether the delegate is constrained in the Z plane.
{return FALSE;}
virtual DELEGexport float GetAverageSpeed | ( | TimeValue | t | ) | [inline, virtual] |
Gets the average speed of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxAccel | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum acceleration of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxHeadingVel | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum heading velocity of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxHeadingAccel | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum heading acceleration of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxPitchVel | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum pitch velocity of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxPitchAccel | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum pitch acceleration of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxIncline | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum incline angle of the delegate.
[in] | t | - the time to retrieve the value |
{return 1.0;}
virtual DELEGexport float GetMaxDecline | ( | TimeValue | t | ) | [inline, virtual] |
Gets the maximum decline angle of the delegate.
[in] | t | - the time to retrieve the value |
{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.
{return 1;}
virtual DELEGexport BOOL OkToDisplayMyVelocity | ( | ) | [inline, virtual] |
Queries if the delegate should display its velocity during a simulation.
{return 1;}
virtual DELEGexport BOOL OkToDisplayMyCogStates | ( | ) | [inline, virtual] |
Queries if the delegate should display its cognitive controller state during a simulation.
{return 1;}
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.
[in] | node | - The delegate's node. |
[in] | t | - the time to retrieve the value. |
{return Matrix3();}
virtual DELEGexport Point3 GetCurrentPosition | ( | ) | [inline, virtual] |
Gets the position of the delegate.
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport Point3 GetCurrentVelocity | ( | ) | [inline, virtual] |
Gets the velocity of the delegate.
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport Point3 GetPreviousVelocity | ( | ) | [inline, virtual] |
Gets the previous velocity of the delegate.
{return Point3(0.0,0.0,0.0);}
virtual DELEGexport float GetCurrentSpeed | ( | ) | [inline, virtual] |
Gets the speed of the delegate.
{return 1.0;}
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.
[in] | n | - the node that the velocity is to be calculated for |
[in] | StartTime | - the time to retrieve the value |
{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.
[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. |
{}
Draws a bounding box while the simulation is running.
[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 |
{}
Draws a sphere while the simulation is running.
[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.
[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.
{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. !
[in] | AssignIndex | - an index into the list of behavior assignments in the Behavior Assignments dialog ! |
[in] | t | - the time to retrieve the value ! |
{return TRUE;}
virtual DELEGexport int GetIndex | ( | ) | [inline, virtual] |
Get the delegate's identifier.
{return 0;}
virtual DELEGexport int GetRandId | ( | ) | [inline, virtual] |
Gets a random id to generate varying behavior for different delegates performing the same behavior.
{return 0;}
virtual DELEGexport BOOL ComputingBiped | ( | ) | [inline, virtual] |
Queries the whether the delegate is associated with a computing biped.
{return FALSE;}
virtual DELEGexport BOOL ReactToMe | ( | ) | [inline, virtual] |
virtual DELEGexport void ClearBacktracking | ( | ) | [inline, virtual] |
virtual DELEGexport BOOL NeedsBacktracking | ( | ) | [inline, virtual] |
virtual DELEGexport void SetBacktracking | ( | int | frame | ) | [inline, virtual] |