Tuesday, 13 September 2011

LScript - Master_MotionBaker

Master - MotionBaker - download

compatible with Newtek LightWave 9.6 and above.

use with Motion_Wheel&Axle, Motion_Slider, Motion_Dangle, Motion_OceanBuoyancy

This is the master script used by all of my *Motion Baker capable scripts.

It allows all scripts in Layout that have a custom built in motion baker capability to be calculated at the same time with use of a simple interface. It can override settings such as Read, Writre and Disable.

Calculate : This processes all keys in time line between start frame and end frame and sets all compatible scripts to "Read" on completion. Redraw is used to enable preview during calculation.

Read : Sets all compatible scripts to read baker data from either array or enveloped depending on implementation.

Write : Sets all compatible scripts to write data to either array or envelope depending on implemention.

Disable : Sets all compatible scripts to disable use of *Motion Baker.

Implementation

If you wish to use the same interface on your own scripts, you may use the code below. This code is the variables and basic connection to the ComRing to set state. You need to implement some way to store and read back data. Read tells your script that it should read baked data. Write tells your script that it should process and then save its data. Reset is there for scripts that require a starting variable to be reset prior to being processed. Disable simply disables Motion Baker being used.

    // Motion Baker
    bMotionBakerParent; // Parent
    iMotionBakerState; // State

            // 1 = Disabled
            // 2 = Reset
            // 3 = Write
            // 4 = Read
create :
{
    // Motion Baker
    bMotionBakerParent = false; // Parent
    iMotionBakerState = 2; // Reset
     // Comring
    comringattach("*MotionBaker","comring_motionbaker"); // Comring *MotionBaker
}

destroy
{
    // Comring
    comringdetach("*MotionBaker"); // Comring *MotionBaker
}

// COMRING

comring_motionbaker: event,data
{

    // Parent
    ParentItem = Item.parent;
    iParent = 1;
    while(ParentItem != nil)
        {
        iParent++;
        ParentItem = ParentItem.parent;
        }

    if(event != 0 && event != iParent)
        {
        return;
        }

    sMessage = comringdecode(@"s:200"@,data);
    if(strlower(sMessage) == "disable") // Disable
        {
        iMotionBakerState = 1;
        }
    if(strlower(sMessage) == "reset")
        {
        iMotionBakerState = 2; // Reset      
        }
    if(strlower(sMessage) == "write")
        {
        iMotionBakerState = 3; // Write      
        }
    if(strlower(sMessage) == "read")
        {
        iMotionBakerState = 4; // Read
        }
    if(strlower(sMessage) == "parent") // Parent
        {
        bMotionBakerParent = true;
        }

    // Requester
    if(reqisopen())
        {
        bRequesterUpdate = true; // Update
        setvalue(ctrl_mb,iMotionBakerState); // Motion Baker
        bRequesterUpdate = false; // Update
        }
}

0 comments:

Post a Comment