PDA

View Full Version : Controlling Morph Mixer



Katherine001
09-14-2009, 06:58 PM
I'd like to write a script that controls the endomorphs of several objects.

So far I've managed to stumble upon the following line:
CommandInput("EditServer DisplacementHandler LW_MorphMixer");

This opens the MorphMixer panel.

So, the next step is how to add keyframes.

Can anyone direct me to a tutorial or programming sample that would do this... add keyframes in morphmixer?

Thanks

evenflcw
09-14-2009, 08:48 PM
Strictly speaking LW Layout has no native support for morphs. What it has is a displacement plugin (Morph Mixer) that creates one envelope/channel for every endomorph in the mesh. Morph Mixer functions is not directly accessible to 3rd party developers, but the channels it generates are. So add the Morph Mixer as you have, to create the envelopes/channels, then use channel object agents to edit the envelopes (ie keyframes). You'll have to traverse through the hierarchy of channels to get at them using Channel and ChannelGroup objects. I dunno of any specific tutorial, but the lscript manuals should be enough.

Katherine001
09-20-2009, 06:22 PM
I want to write a script that keyframes channels. So, I have the following script.
@version 2.2
@warnings
@script channel

// global values go here
value=.1;

create: channel
{

setdesc("changevalue"); // one-time initialization takes place here
}

destroy
{
// take care of final clean-up activities here
}

process: ca, frame, time
{
// 'ca' is the Channel Filter Object Agent
ca.set(value);


}
This changes the value of the currently selected channel to which you are adding the Lscript as a Modifier.
I don't really understand the syntax. I would like to now keyframe this and move on to another frame.
If anyone would like to have mercy on me and tell me how to do it, I would be grateful.

Katherine

evenflcw
09-20-2009, 06:55 PM
Strictly speaking, channel filters/modifiers aren't meant to edit keyframes, but instead dynamically alter the channel value (the output), using the keyframed value as input.

So, to keep things simpler, start with a generic script (an executable script that executes from top to bottom, has a definite start- and endpoint; filters/modifiers in contrast are persistent and calls the process() function over and over until you remove or disable the script). Get the wanted Channel object agent (OA) by calling the Item OA functions firstChannel() and nextChannel().


@script generic

generic {
item = Scene().firstSelect();
chan[1] = item.firstChannel(); //position.x Channel OA
chan[2] = item.nextChannel(); //position.y
chan[3] = item.nextChannel(); //position.z

chan[2].createKey(3, 4); //creates a key in y channel, 3 seconds in with value 4.0.
}

PS. "Strictly speaking" seems to be my word du jour.
Just out of curiosity, how long have you worked with LW (using it, rather than developing for it)?

PS2. Later on, when you got all the basics down, you might want to create a master plugin or abuse a persistent script type to create a more dynamic script that is non-modal (generic scripts are modal).

PS3. Oh yeah... to get to the morph channels you will naturally have to add the Morph Mixer to the object and use Channel Groups OA to find the morphs in the channel hierarchy. You should be able to figure it out from chapter on them (channel groups) in the LScript Reference Manual. Checkout the channel tree view in the Graph Editor (bottom left) to understand how the hierarchy is set up and where the morph channels are placed.

Katherine001
10-07-2009, 04:46 PM
Thanks so much for you help. That was great.
So here's a script that adds a morphmixer panel and adds two keyframes.
@version 2.2
@warnings
@script generic


generic
{
item = Scene().firstSelect();
CommandInput("ApplyServer DisplacementHandler LW_MorphMixer");
group = ChannelGroup("MorphGroup");
chan[1]= group.firstChannel();
chan[1].createKey(1,1); //one second or frame 30 and 10 per cent
chan[1].createKey(2,.1);
}

Now, suppose you add a MorphMixer to another object and then want to add additional keyframes to the morphmixer of the first object.
How do you re-open the MorphMixer panel.
I've tried EditServer and EnableServer, but those don't work.

Does anyone know how to RE-OPEN a plug-in panel?

evenflcw
10-08-2009, 11:55 AM
EditServer should do it. But how are you calling it? Since it's a plugin assigned to a specific item you also have to select that item first (a downside of LWs commandbased architecture). It also does not take the name of a plugin as it's last argument but an index. The index corresponds to its (the plugin/server instance) position in the list of applied plugins (of that type). So you will have to iterate through all applied plugins if that type to look for one(s) with the name "MorphMixer" (or whatever the internal name is). Just search through the docs for "server" to find the proper functions.