Reaction Controller: Appending Slaves to a State

Reaction Controller: Appending Slaves to a State

adnanmg
Advocate Advocate
242 Views
2 Replies
Message 1 of 3

Reaction Controller: Appending Slaves to a State

adnanmg
Advocate
Advocate
Hi,

I'm scripting some animation controls and ran across an issue I could not figure out with the Reaction Controller. I can do it via the interface, but am unsure how to Append a Slave to a State via maxscript. There seems to be nothing regarding this in the help file and a search on CGTalk forums and here seems to tell me that there are scripting limitations with this and this may be one.

Is there a way to script this? I will try a work around in the meantime. Perhaps I can create two states with the appropiate values to duplicate the functionality.

Thanks in advance.

Adnan
0 Likes
243 Views
2 Replies
Replies (2)
Message 2 of 3

adnanmg
Advocate
Advocate
Hmm. delving a bit deeper to me it seems scripting reaction controllers is a mess. The order of states gets changed as I add more. I even tried assigning the states' values backwards as SuperRune suggested on a post I read on CGTalk.

The values come up wrong. If I manually fix the float values in the Reaction Manager, it works perfectly, but so long as I do so via script it keeps changing and the values are wrong as I add more states and assign more values.

This seems consistent with user posts I read as I was researching this topic...so no luck in Max 2011 either? That's what I am using. Is there some workaround I have missed? This seems like a vital tool for rigging...

Thanks,

Adnan
0 Likes
Message 3 of 3

adnanmg
Advocate
Advocate
Ok, after working at it, I created the following function. Well, in fact I made a function out David Knight's (thanks for sharing!) maxscript:

http://www.scriptspot.com/3ds-max/scripts/connectmorphs

I have made it specifically for the pipeline I'm working on, but the code below can be adapted by others for their needs and that why I'm sharing it.

char_str string abbreviation for character name.
upnum Morph Target # for the Target used in Upward Motion
dnnum Morph Target # for the Target used in Downward Motion
lfnum Morph Target # for the Target used in Left Motion
rtnum Morph Target # for the Target used in Left Motion
ctrl_str My spline control objects are named char_str+"_fc_"+ctrl_str


-- made into function based of connectmorphs_for_fourway_slider_control.ms by David Knight
--http://www.scriptspot.com/3ds-max/scripts/connectmorphs

fn fc_reaction_setup char_str upnum dnnum lfnum rtnum ctrl_str=
(
if upnum!="" do execute("morph"+upnum+"=$"+char_str+"_body.morpher.controller=Float_Reactor()")
if dnnum!="" do execute("morph"+dnnum+"=$"+char_str+"_body.morpher.controller=Float_Reactor()")
if lfnum!="" do execute("morph"+lfnum+"=$"+char_str+"_body.morpher.controller=Float_Reactor()")
if rtnum!="" do execute("morph"+rtnum+"=$"+char_str+"_body.morpher.controller=Float_Reactor()")

upnum_st=0
dnnum_st=0
lfnum_st=0
rtnum_st=0

execute("master_obj=$"+char_str+"_fc_"+ctrl_str)
execute ("master_cont=$"+char_str+"_fc_"+ctrl_str+".pos.controller.controller")

p1 = master_obj.pos
p2 = master_obj.pos
p3 = master_obj.pos

if upnum!="" do execute("reactTo morph"+upnum+" master_cont;upnum_st+=1")
if upnum!="" do execute("setReactionState morph"+upnum+" upnum_st 0;")
if dnnum!="" do execute("reactTo morph"+dnnum+" master_cont;dnnum_st+=1")
if dnnum!="" do execute("setReactionState morph"+dnnum+" dnnum_st 0;")
if lfnum!="" do execute("reactTo morph"+lfnum+" master_cont; lfnum_st+=1")
if lfnum!="" do execute("setReactionState morph"+lfnum+" lfnum_st 0;")
if rtnum!="" do execute("reactTo morph"+rtnum+" master_cont; rtnum_st+=1")
if rtnum!="" do execute("setReactionState morph"+rtnum+" rtnum_st 0;")

-- up pos
master_obj.pos = ;
master_obj.pos =
if upnum!="" do execute("createReaction morph"+upnum+";upnum_st+=1")
if upnum!="" do execute("setReactionState morph"+upnum+" upnum_st 100;")
if dnnum!="" do execute("createReaction morph"+dnnum+";dnnum_st+=1")
if dnnum!="" do execute("setReactionState morph"+dnnum+" dnnum_st 0;")
if lfnum!="" do execute("createReaction morph"+lfnum+";lfnum_st+=1")
if lfnum!="" do execute("setReactionState morph"+lfnum+" lfnum_st 0;")
if rtnum!="" do execute("createReaction morph"+rtnum+";rtnum_st+=1")
if rtnum!="" do execute("setReactionState morph"+rtnum+" rtnum_st 0;")

-- dn pos
master_obj.pos = ;
master_obj.pos = ;

if upnum!="" do execute("createReaction morph"+upnum+";upnum_st+=1")
if upnum!="" do execute("setReactionState morph"+upnum+" upnum_st 0;")
if dnnum!="" do execute("createReaction morph"+dnnum+";dnnum_st+=1")
if dnnum!="" do execute("setReactionState morph"+dnnum+" dnnum_st 100;")
if lfnum!="" do execute("createReaction morph"+lfnum+";lfnum_st+=1")
if lfnum!="" do execute("setReactionState morph"+lfnum+" lfnum_st 0;")
if rtnum!="" do execute("createReaction morph"+rtnum+";rtnum_st+=1")
if rtnum!="" do execute("setReactionState morph"+rtnum+" rtnum_st 0;")

-- lf pos
master_obj.pos = ;
master_obj.pos = ;

if upnum!="" do execute("createReaction morph"+upnum+";upnum_st+=1")
if upnum!="" do execute("setReactionState morph"+upnum+" upnum_st 0;")
if dnnum!="" do execute("createReaction morph"+dnnum+";dnnum_st+=1")
if dnnum!="" do execute("setReactionState morph"+dnnum+" dnnum_st 0;")
if lfnum!="" do execute("createReaction morph"+lfnum+";lfnum_st+=1")
if lfnum!="" do execute("setReactionState morph"+lfnum+" lfnum_st 100;")
if rtnum!="" do execute("createReaction morph"+rtnum+";rtnum_st+=1")
if rtnum!="" do execute("setReactionState morph"+rtnum+" rtnum_st 0;")

-- rt pos
master_obj.pos = ;
master_obj.pos = ;

if upnum!="" do execute("createReaction morph"+upnum+";upnum_st+=1")
if upnum!="" do execute("setReactionState morph"+upnum+" upnum_st 0;")
if dnnum!="" do execute("createReaction morph"+dnnum+";dnnum_st+=1")
if dnnum!="" do execute("setReactionState morph"+dnnum+" dnnum_st 0;")
if lfnum!="" do execute("createReaction morph"+lfnum+";lfnum_st+=1")
if lfnum!="" do execute("setReactionState morph"+lfnum+" lfnum_st 0;")
if rtnum!="" do execute("createReaction morph"+rtnum+";rtnum_st+=1")
if rtnum!="" do execute("setReactionState morph"+rtnum+" rtnum_st 100;")

master_obj.pos = ;
)


-Adnan
http://www.madguru.net
0 Likes