Reactor Controller

Topic: version 4 MAXScript New Features/Reactors

The Reactor controller is a procedural controller that reacts to changes in any other controller within the software. Reactor comes in five different forms: Position Reactor, Rotation Reactor, Point3 Reactor, Scale Reactor, and Float Reactor. Any animatable parameter in the software can react to changes in any other animatable parameter. Reactor is not based on time, but is based on other variables in your scene.

Example:

-- Setup a scene

ball = sphere name:"ball" pos:[-40,0,50] radius:10

ball.pos.controller = position_XYZ()

-- create some keys

key = addNewKey ball.pos.Zposition.controller 0

key.outTangentType = #slow

key.value = 50

key = addNewKey ball.pos.Xposition.controller 0

key.value = -40

key = addNewKey ball.pos.Zposition.controller 25

key.InTangentType = #fast

key.outTangentType = #fast

key.value = 4

key = addNewKey ball.pos.Xposition.controller 25

key.value = -10

key = addNewKey ball.pos.Zposition.controller 50

key.InTangentType = #slow

key.value = 50

key = addNewKey ball.pos.Xposition.controller 50

key.value = 20

ball.showtrajectory = true

-- assign a reactor controller to the scale of the ball

reactor = Scale_Reactor()

ball.scale.controller = reactor

-- Pick the react to object, and create reactions

reactor.reactions.reactTo ball.pos.ZPosition.controller 0

reactor.reactions.setName 0 "UnSquashed"

reactor.reactions.setVectorState 0 [1,1,1]

reactor.reactions.create "squashed" 25

reactor.reactions.setVectorState 1 [2.5,2.5,.4]

reactor.reactions.setValueAsFloat 0 10

reactor.reactions.setInfluence 0 6

reactor.reactions.setInfluence 1 5.5

reactor.reactions.setStrength 1 1.5

reactor.reactions.setFalloff 0 1.75

ss = StringStream ""

reactor.reactions.getType()

ct = reactor.reactions.getCount()

format "Reactor Statistics: \n------------------------------\n \n" to:ss

format "Count : %\n" ct to:ss

format  "\n" to:ss

for i  = 0 to ct-1 do

(

format "Reaction #: % \n------------------------------------------------

Name : %

State : %

Value : %

Strength : %

Influence : %

Falloff : % \n\n" (i) (reactor.reactions.getName i)

(getReactionState reactor (i+1)) (getReactionValue reactor (i+1))

(reactor.reactions.getStrength i) (reactor.reactions.getInfluence i )

(reactor.reactions.getFalloff i ) to:ss

)

print ss

See also