8

1060 Chapter 14: Character Studio
State Transition Dialog
Create panel > Helpers > Object Type rollout > Crowd
> Setup rollout > Cognitive Controllers > Right-click a
transition line.
Select a Crowd object. > Mod ify panel > Setup rollout >
Cognitive Controllers > Right-c lick a transition line.
These settings control how the software effects a
transition from one state to another when using
a
cognitive controller (page 2–1057)
.Formore
detailed information, see
To s e t u p an d u s e a
cognitive controller (page 2–1022)
.
The Tr ansition Script
Themostimportantelementofthetransitionis
the MAXScript conditional script. This is a script
associated with the controller that is executed once
per frame, and can test any aspect or aspects of the
sceneandcauseatransitionornot,dependingon
whether the result of the test is successful (true, or
1) or unsuccessful (fa lse, or 0).
Thesoftwareexecutesscriptsonceperframeper
assigned delegate, so objects and effects can be
animated and still let delegates react with accuracy.
All scripts used in transitions use the following
structure:
fn [FunctionName] delt=(
[MAXScript code]
if [MAXScript conditional]
then 1
else 0 )
The opening section contains "fn" (function)
followed by the function name, which also must
appear in the State Transition dialog, and then
the input parameters "del t", a nd lastly "= (".
Following this there can be any MAXScript code,
or none.
The closing sec tion contains a necessary
MAXScript conditional, and then "then 1 else
0". This means: If the result of the conditional is
true,thenreturn1(thatis,thetransitionistotake
place), or if the result of the conditional is false,
then return 0 (that is, the transition is not to take
place). You could reverse the order of the numbers
1and0("then0else1")sothattheconditional
beingtruewouldcausenotransitiontotakeplace,
and vice-versa. Lastly, the function must end with
a close parenthesis: ")".
Following are some examples of scripts that can
be used in cognitive controllers, along with brief
explanations. These are presented for you to
modify and use in your own scenes.
Note: See this topic in the online
User Reference
forsamplecodetotestanobjectposition,testthe
distance between two objects, and test a modifier
parameter.
Testing a Pa rticle System Parameter
This sample script tests the number of particles
emitted by particle system Spray01, and returns
positive if the number equals 100.
fn TestParticles delt=(
if (particleCount $Spray01) == 100
then 1 else 0 )
Testing an Atmospheric Property
This sample script tests the Density parameter of a
fog effect, and returns positive if it equals 50.
fn TestAtmos delt=(
atmos_fog = getAtmospheric 1
print atmos_fog.density -- to:debug
if (atmos_fog.density == 50)
then 1 else 0 )
Note the second line, which assigns the fog
atmospheric to a variable named "atmos_fog".
This is necessary only for atmospheric effects; with
most standard objects, you simply use the object
name preceded by a $, as in the two previous
examples. The "1" follow ing the getAtmospheric
command refers to the atmospheric’s position in
theRenderingEffectsdialog>Effectslist.