Crowds - Methods

The Crowds structure provides the following methods affecting the character studio Crowd feature:

crowds.solve <crowd_node>

Equivalent to clicking Solve in the crowd’s Solve rollout. .solve starts the solving, based on all other current crowd parameter settings.

crowds.genclones <crowd_node>

Equivalent to clicking Generate Clones in the Scatter Objects dialog, Clone tab, displayed by clicking the Scatter Objects icon. Generates clones based on all other current crowd parameter settings.

crowds.genlocations <crowd_node>

Equivalent to clicking Generate Locations in the Scatter Objects dialog, Position tab, displayed by clicking the Scatter Objects icon. Generates locations based on all other current crowd parameter settings.

crowds.genrotations <crowd_node>

Equivalent to clicking Generate Orientations in the Scatter Objects dialog, Rotation tab, displayed by clicking the Scatter Objects icon. Generates rotations based on all other current crowd parameter settings.

crowds.genscales <crowd_node>

Equivalent to clicking Generate Scales in the Scatter Objects dialog, Scale tab, displayed by clicking the Scatter Objects icon. Generates scales based on all other current crowd parameter settings.

crowds.scatterall <crowd_node>

Equivalent to clicking Scatter button in the Scatter Objects dialog, All Ops tab. Scatters objects based on all other current crowd parameter settings.

crowds.alignObjects <crowd_node>

Equivalent to clicking Align Objects with Delegates in the Object / Delegates dialog displayed by clicking the Associate Objects with Delegates icon. Aligns objects based on all other current crowd parameter settings.

crowds.linkObjects <crowd_node>

Equivalent to clicking Link Objects to Delegates in the Object / Delegates dialog displayed by clicking the Associate Objects with Delegates icon. Links objects based on all other current crowd parameter settings.

crowds.assignControllers <crowd_node>

Equivalent to clicking Assign Delegate Controllers to Objects in the Object / Delegates dialog displayed by clicking the Associate Objects with Delegates icon. Assigns controllers based on all other current crowd parameter settings.

crowds.smooth <crowd_node>

Equivalent to clicking OK in the Smoothing dialog displayed by clicking the Smooth Paths button in the Solve rollout. Smooths objects motions based on all other current crowd parameter settings.

crowds.assignGridProximityPriorities <crowd_node>

Equivalent to clicking Proximity to a Grid / Assign in the Priority rollout. Assigns priorities to the delegates specified in <Crowd.priority>.delegates based on their distance from the grid specified in <Crowd.priority>.grid.

crowds.assignObjectProximityPriorities <crowd_node>

Equivalent to clicking Proximity to an Object / Assign in the Priority rollout. Assigns priorities to the delegates specified in <Crowd.priority>.delegates based on their distance from the object specified in <Crowd.priority>.object.

crowds.assignRandomPriorities <crowd_node>

Equivalent to clicking Assign Random Priorities in the Priority rollout. Assigns random priorities to the delegates specified in <Crowd.priority>.delegates.

crowds.assignUniquePriorities <crowd_node>

Equivalent to clicking Make Priorities Unique in the Priority rollout. Ensures that the priorities of the delegates specified in <Crowd.priority>.delegates are unique. If two delegates share the same priority, one of them will be given a new priority.

crowds.incrementPriorities <crowd_node>

Equivalent to clicking Increment Priorities in the Priority rollout. Increments the priorities of the delegates specified in <Crowd.priority>.delegates by the value in <Crowd.priority>.increment.

Notes - MAXScript Group

The MAXScript group of the Solve Rollout has a feature to control the execution of a MAXScript script at each frame.

Use MAXScript: When on, a user-specified script is executed at each frame during the solution. Default=off.

Function Name: The name of the function to be executed. This name must be identical to the one specified in the script.

Edit MAXScript: Click this button to open a MAXScript window for displaying and modifying the script.

The crowd function needs two parameters defined. The 1st parameter passed in is the current crowd and the 2nd parameter passed in is the solve frame.

Here is a simple example:

fn g_PerFrameFn current_crowd the_frame_time =

(

if the_frame_time == 1f then

(_g_mydebugwindow = newScript()

format "% %\n" current_crowd the_frame_time to:_g_mydebugwindow

)

)

Notes

You can perform the following MAXScript operations

deleteitem <array> <itemnumber>

<array> = #(item,item...)

<array> = append <array> <item>

on all of the properties containing an ArrayParamater of objects listed below. You can also undo/redo these operations.

<Crowd>.behaviors -- array of Behavior objects

 

<Crowd>.teams -- array of CrowdTeam objects

 

<Crowd>.assignments -- array of Assignment objects

 

<Crowd>.cogcontrols -- array of CognotiveController objects

 

<Crowd.scatter>.ObjectsToScatter -- node array

 

<Crowd.objAssoc>.objects -- node array

 

<Crowd.objAssoc>.delegates -- node array

 

<Crowd.smooth>.objects -- node array

 

If you delete a team or a cognitive controller via MAXScript deleteitem $crowd01.teams[1] 1 or deleteitem $crowd01.cogcontrols[1] 1, it may still be referenced by some assignments. Nothing will go wrong, but it's a strange thing to do and one probably should not do it.

The following MAXScript operations will cause Crowd to fail, either right away or later:

NEVER set a Crowd ArrayParameter element to undefined.

NEVER set a Crowd ArrayParameter element to to anything other than an object of the appropriate type.

 

See also

MAXScript Extensions in character studio