PDA

View Full Version : set morphmap



Svenart
10-01-2007, 12:08 PM
Hello everybody,

Im new to lscript, and now working on my veryfirst plugin. My problem is that I dont know how I can switch between (and activate) the morphmaps in layout/modeller using lscript. I already looked into the docu, but was not able to find an example. Does anybody here can help me with that?

Dodgy
10-01-2007, 02:34 PM
mymap=VMap(); //will return the first vmap in the system.

mymap=VMap(VMWEIGHT); reruns the first weightmap in the system. Have a look here for more script help:

http://dodgy.ghostoutpost.com/Lscript/Lscript%20Index.html

Svenart
10-01-2007, 03:50 PM
Thank you very much for the fast reply. I tried it and now I can get the name of the first morphmap, but I still dont know how to activate the morphmap. Can you help me with this, again?

I already know this link and Im glad its online again. Its much better than the other lscript docus. Unfortunately, I wasnt able to find a example there, maybe my english is just not good enough to find what Im looking for.

Dodgy
10-01-2007, 03:55 PM
What do you mean activate it? Do you mean create a new one?

Svenart
10-01-2007, 04:02 PM
My script is loading an object and cloning it on a plane. I have now a tree, for example with 3morphs (variations of the tree). Now i want to tell the script to load the model with one of the 3morphs randomly. So not every tree is looking like the others. But when I load a model into layout no morphmap is active, and I dont know how to activate a selected morph in Layout.

Svenart
10-01-2007, 04:04 PM
here a link to a first "official" render using the plugin: http://www.renderosity.com/mod/gallery/index.php?image_id=1530382&member

Dodgy
10-01-2007, 04:42 PM
Well first you'll need to add morph mixer to your object.

So:

SelectItem(yourobj.id);
ApplyServer(SERVER_DISPLACEMENT_H, "LW_MorphMixer");

Then you just need to add a key to the morph target's channel.

Svenart
10-01-2007, 04:59 PM
Great, thank you. Morphmixer will be added now to every object. I will try to find out now how to set the keys. Unfortunately, Lscommander is not showing everything you are doing in Lightwave:( Can you again give me a hint wich command I have to use for adding a key to the morphchannel?

Dodgy
10-01-2007, 05:10 PM
Look under channels in the lscript docs.

Svenart
10-01-2007, 05:21 PM
Thank you, I hope I found it now. Im not sure, my english is not soo good and Im not a professional coder. But It looks this here could help?

create: channel
{
light = Light();
c = light.firstChannel();
while(c)
{
last if c.name == "Position.X";
c = light.nextChannel();
}
// keep abreast of changes in this channel...
c.event("lightEvent");
}
process: ca, frame, time
{
ca.set(0.0);
}
lightEvent: channel,
// Channel Object Agent event
// event code
{
// something happened to Light's
//"Position.X" channel
info(event);
}

Dodgy
10-01-2007, 06:23 PM
Well you get the channel group of your item you wish to morph

mygroup=ChannelGroup(myobj.name);

Then you get the subchannel group Morph


newgroup=ChannelGroup(mygroup);
while(newgroup)
{
if(newgroup.name=="Morph")
{
mychan=newgroup.firstChannel();
while(mychan)
{
if (mychan.name==mymorph.name)
{
mychan.createKey(0,1.0);
}
mychannel=mygroup.nextChannel();
}
}
newgroup=ChannelGroup(mygroup,newgroup);
}

Should do it... From memory, so you should check it....

Svenart
10-01-2007, 06:59 PM
fantastic, no I can do it AND I have learned a lot for one day. You helped me a lot. Thank you very much!!