[Closed] Copying Morph channel values
Hey there everyone !
I’m pretty new to MaxScripts but i’ve managed to create a few simple tools to help me with different repetitive tasks.
The next tool i am trying to create is one that will help me have two characters with the Morpher modifier talk or sing at the same time without having to animate them both (without resulting to Wires).
I’ve been searching all over for a command to copy the values from one morph channel (throughout the entire timeline) on one model to the same morph channel on another model. Anyone here has ever done that ? I’m looking for something really simple and straightforward (along the same lines as $Box01.pos.controller = $Sphere01.pos.controller [size=2]when you want to copy the position of one object to another.) [/size]
[size=2][/size]
[size=2]I got everything else in my little tool to work exempt that (CRUCIAL) part [/size]
When it’s done and working with your help, i can post it all here for others to use.
[size=2][/size]
[size=2]Any help ?[/size]
[size=2]Thanks ![/size]
[size=2]Marc
[/size]
This was quite a challenge, I’ve never done this before (well I have but not with a morpher)…
Okay, so here’s what we need to know…
- We need a list of keys for the current object and morpher channel.This is relativly easy, but it took me some time to get my head around it, as it is Saturday morning. Bascially, the morpher keeps the keys for each channel in a list of subanim controllers.
These can be accessed in a number of ways, but for this purspose, the easiest is via a simple index (representing each channel…I hope)
$.morpher[1]
Will give use access to the first channel. This will need to some experimentation, but it works for me (but I only have one channel)
2. We need to get the current value for the current channel at the specified timeWow, that was a mouth full. Basically, getting the value of the channel is relativley easy
wm3_mc_getValue $.morpher 1
Will return the value of channel 1 at the current time
So now we armed with enough information to be dangerous…
(
local oMaster = $box01 -- The source object
local oSlave = $box03 -- The target object
local lstKeys = oMaster.morpher[1].keys -- Get a list of keys for the master objects morpher modifier
-- Turn the animation on so we can record what we are doing
animate on (
-- Loop through the key list
for kTime in lstKeys do (
-- Set the current time context to the key's time value
at time kTime.time (
-- Get the channel's value
-- Note, we are only dealing with channel 1
-- You could look through the sub-anims until you reach undefined
-- or simply use the channel you want...
local value = wm3_mc_getvalue oMaster.morpher 1
-- Set the value of the target to match
wm3_mc_setValue oSlave.morpher 1 value
)
)
)
)
That’s about it. I hope that helps…
Shane
Hey there Rustyknight!
Thanks for all the efforts you’ve put into his problem of mine (especially on a saturday morning!). This does help me a lot in getting in the direction that i want it to go, but this script doesn’t do exactly what i need it to do. It would be great if i were animating all the different characters in the scene at the same time, but the reason i need it is to be able to copy an existing morpher value TRACK (the entire timeline) from one animated character to another that doesn’t have any animation yet. The script you sent me works, but only on the active frame. And i wouldn’t want to have a keyframe per frame, only a copy of the values on the frames that are actually KEYED…
That way, i could have one character’s facial animations done for an entire song let’s say, and then bring in another character and just “copy/paste” the values on it for the entire sequence.
Wooo. That’s starting to ge complicated
Thanks for the help so far though!
Marc
Let’s say you have two objects with Morpher modifiers applied; $MorphA and $MorphB. Both have a target assigned to it’s first slot, and $MorphA has been animated. You can now copy the controller from $MorphA to $MorphB, just as you would using the trackview:
$MorphB.morpher[1].track = copy $MorphA.morpher[1].track
Leaving out the “copy” keyword will make it an instance instead of a copy.
Hope this helps,
Martijn