3ds Max C++ API Reference
IDelegate Class Reference

An interface class to the delegate. More...

#include <delegexp.h>

+ Inheritance diagram for IDelegate:

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. More...
 
virtual DELEGexport float GetAverageSpeed (TimeValue t)
 Gets the average speed of the delegate. More...
 
virtual DELEGexport float GetMaxAccel (TimeValue t)
 Gets the maximum acceleration of the delegate. More...
 
virtual DELEGexport float GetMaxHeadingVel (TimeValue t)
 Gets the maximum heading velocity of the delegate. More...
 
virtual DELEGexport float GetMaxHeadingAccel (TimeValue t)
 Gets the maximum heading acceleration of the delegate. More...
 
virtual DELEGexport float GetMaxPitchVel (TimeValue t)
 Gets the maximum pitch velocity of the delegate. More...
 
virtual DELEGexport float GetMaxPitchAccel (TimeValue t)
 Gets the maximum pitch acceleration of the delegate. More...
 
virtual DELEGexport float GetMaxIncline (TimeValue t)
 Gets the maximum incline angle of the delegate. More...
 
virtual DELEGexport float GetMaxDecline (TimeValue t)
 Gets the maximum decline angle of the delegate. More...
 
virtual DELEGexport BOOL OkToDisplayMyForces ()
 Queries if the the delegate should display the forces acting upon it during a simulation
More...
 
virtual DELEGexport BOOL OkToDisplayMyVelocity ()
 Queries if the delegate should display its velocity during a simulation. More...
 
virtual DELEGexport BOOL OkToDisplayMyCogStates ()
 Queries if the delegate should display its cognitive controller state during a simulation. More...
 
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. More...
 
virtual DELEGexport Point3 GetCurrentPosition ()
 Gets the position of the delegate. More...
 
virtual DELEGexport Point3 GetCurrentVelocity ()
 Gets the velocity of the delegate. More...
 
virtual DELEGexport Point3 GetPreviousVelocity ()
 Gets the previous velocity of the delegate. More...
 
virtual DELEGexport float GetCurrentSpeed ()
 Gets the speed of the delegate. More...
 
virtual DELEGexport Point3 GetSimStartVelocity (INode *n, TimeValue StartTime)
 Gets the delegate's velocity at the start of a simulation
More...
 
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 (const Point3 &pt1, const Point3 &pt2, Color clr, BOOL scale)
 Draws a line segment while the simulation is running. More...
 
virtual DELEGexport void BboxDisplay (Point3 &pt1, Point3 &pt2, Color clr)
 Draws a bounding box while the simulation is running. More...
 
virtual DELEGexport void SphereDisplay (Point3 &pt1, float radius, Color clr)
 Draws a sphere while the simulation is running. More...
 
virtual DELEGexport void TextDisplay (Point3 &pt1, Color clr, const MCHAR *str)
 Draws text while the simulation is running. More...
 
Miscellanious Functions
virtual DELEGexport BOOL IsComputing ()
 Queries whether the delegate is currently active in a running crowd simulation. More...
 
virtual DELEGexport BOOL IsAssignmentActive (int AssignIndex, TimeValue t)
 Queries whether a particular assignment is active at a particular time. More...
 
virtual DELEGexport int GetIndex ()
 Get the delegate's identifier. More...
 
virtual DELEGexport int GetRandId ()
 Gets a random id to generate varying behavior for different delegates performing the same behavior. More...
 
virtual DELEGexport BOOL ComputingBiped ()
 Queries the whether the delegate is associated with a computing biped. More...
 
virtual DELEGexport BOOL ReactToMe ()
 This function is used internally. More...
 
virtual DELEGexport void ClearBacktracking ()
 This function is used internally. More...
 
virtual DELEGexport BOOL NeedsBacktracking ()
 This function is used internally. More...
 
virtual DELEGexport void SetBacktracking (int frame)
 This function is used internally. More...
 
virtual DELEGexport ~IDelegate ()
 Queries whether the delegate is currently active in a running crowd simulation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

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);
Definition: inode.h:55
The object class is the base class for all objects.
Definition: object.h:1428

Constructor & Destructor Documentation

◆ ~IDelegate()

virtual DELEGexport ~IDelegate ( )
inlinevirtual

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
269 {}

Member Function Documentation

◆ IsConstrainedInZ()

virtual DELEGexport BOOL IsConstrainedInZ ( )
inlinevirtual

Queries whether the delegate is constrained in the Z plane.

Returns
true if the delegate is constrained to the z plane, false if not
75 {return FALSE;}

◆ GetAverageSpeed()

virtual DELEGexport float GetAverageSpeed ( TimeValue  t)
inlinevirtual

Gets the average speed of the delegate.

Parameters
[in]t- the time to retrieve the value
Returns
the average speed of the delegate
82 {return 1.0;}

◆ GetMaxAccel()

virtual DELEGexport float GetMaxAccel ( TimeValue  t)
inlinevirtual

Gets the maximum acceleration of the delegate.

Parameters
[in]t- the time to retrieve the value
Returns
the maximum acceleration of the delegate
87 {return 1.0;}

◆ GetMaxHeadingVel()

virtual DELEGexport float GetMaxHeadingVel ( TimeValue  t)
inlinevirtual

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.
93 {return 1.0;}

◆ GetMaxHeadingAccel()

virtual DELEGexport float GetMaxHeadingAccel ( TimeValue  t)
inlinevirtual

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.
99 {return 1.0;}

◆ GetMaxPitchVel()

virtual DELEGexport float GetMaxPitchVel ( TimeValue  t)
inlinevirtual

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.
105 {return 1.0;}

◆ GetMaxPitchAccel()

virtual DELEGexport float GetMaxPitchAccel ( TimeValue  t)
inlinevirtual

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.
111 {return 1.0;}

◆ GetMaxIncline()

virtual DELEGexport float GetMaxIncline ( TimeValue  t)
inlinevirtual

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
116 {return 1.0;}

◆ GetMaxDecline()

virtual DELEGexport float GetMaxDecline ( TimeValue  t)
inlinevirtual

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
121 {return 1.0;}

◆ OkToDisplayMyForces()

virtual DELEGexport BOOL OkToDisplayMyForces ( )
inlinevirtual

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.
128 {return 1;}

◆ OkToDisplayMyVelocity()

virtual DELEGexport BOOL OkToDisplayMyVelocity ( )
inlinevirtual

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.
133 {return 1;}

◆ OkToDisplayMyCogStates()

virtual DELEGexport BOOL OkToDisplayMyCogStates ( )
inlinevirtual

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.
138 {return 1;}

◆ GetTM()

virtual DELEGexport Matrix3 GetTM ( INode node,
TimeValue  t 
)
inlinevirtual

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.
155 {return Matrix3();}
Definition: matrix3.h:98

◆ GetCurrentPosition()

virtual DELEGexport Point3 GetCurrentPosition ( )
inlinevirtual

Gets the position of the delegate.

Returns
the position of the delegate in world space at the current frame in the simulation
159 {return Point3(0.0,0.0,0.0);}
Definition: point3.h:56

◆ GetCurrentVelocity()

virtual DELEGexport Point3 GetCurrentVelocity ( )
inlinevirtual

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.
164 {return Point3(0.0,0.0,0.0);}

◆ GetPreviousVelocity()

virtual DELEGexport Point3 GetPreviousVelocity ( )
inlinevirtual

Gets the previous velocity of the delegate.

Returns
the velocity of the delegate at the previous frame in the simulation.
168 {return Point3(0.0,0.0,0.0);}

◆ GetCurrentSpeed()

virtual DELEGexport float GetCurrentSpeed ( )
inlinevirtual

Gets the speed of the delegate.

Returns
the speed of the delegate at the current frame in the simulation
172 {return 1.0;}

◆ GetSimStartVelocity()

virtual DELEGexport Point3 GetSimStartVelocity ( INode n,
TimeValue  StartTime 
)
inlinevirtual

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
183 {return Point3(0.0,0.0,0.0);}

◆ LineDisplay()

virtual DELEGexport void LineDisplay ( const Point3 pt1,
const Point3 pt2,
Color  clr,
BOOL  scale 
)
inlinevirtual

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.
199 {}

◆ BboxDisplay()

virtual DELEGexport void BboxDisplay ( Point3 pt1,
Point3 pt2,
Color  clr 
)
inlinevirtual

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
205 {}

◆ SphereDisplay()

virtual DELEGexport void SphereDisplay ( Point3 pt1,
float  radius,
Color  clr 
)
inlinevirtual

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.
211 {}

◆ TextDisplay()

virtual DELEGexport void TextDisplay ( Point3 pt1,
Color  clr,
const MCHAR str 
)
inlinevirtual

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
217 {}

◆ IsComputing()

virtual DELEGexport BOOL IsComputing ( )
inlinevirtual

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
224 {return FALSE;}

◆ IsAssignmentActive()

virtual DELEGexport BOOL IsAssignmentActive ( int  AssignIndex,
TimeValue  t 
)
inlinevirtual

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.
237 {return TRUE;}

◆ GetIndex()

virtual DELEGexport int GetIndex ( )
inlinevirtual

Get the delegate's identifier.

Returns
an integer > 0, that is an unique identifier for a delegate while a crowd simulation is running.
241 {return 0;}

◆ GetRandId()

virtual DELEGexport int GetRandId ( )
inlinevirtual

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.
250 {return 0;}

◆ ComputingBiped()

virtual DELEGexport BOOL ComputingBiped ( )
inlinevirtual

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
255 {return FALSE;}

◆ ReactToMe()

virtual DELEGexport BOOL ReactToMe ( )
inlinevirtual

This function is used internally.

258 {return FALSE;}

◆ ClearBacktracking()

virtual DELEGexport void ClearBacktracking ( )
inlinevirtual

This function is used internally.

261 {}

◆ NeedsBacktracking()

virtual DELEGexport BOOL NeedsBacktracking ( )
inlinevirtual

This function is used internally.

264 {return FALSE;}

◆ SetBacktracking()

virtual DELEGexport void SetBacktracking ( int  frame)
inlinevirtual

This function is used internally.

267 {}