Feedback

Please leave feedback and comments. I am always interested to hear how people get on using these LScripts!

Friday, 6 March 2015

LScript - Motion_Steadicam


LScript (Layout) smooth camera motions and position camera based upon motion of another object.

Compatible with Newtek LightWave 9.6 and above.

// LScript Item Animation - www.StephenCulley.co.uk
//
// web   address: http://www.stephenculley.co.uk
// email address: email@stephenculley.co.uk

/*  
    LScript Item Animation - Steadicam

    Motion_Steadicam.ls

*/

@version 2.2
@warnings
@script motion
@name *Steadicam

    // Title
    sTitle = "*Steadicam";

    // Version
    sVersion = "v1.0";

    // Item
    Item = nil;
    ItemName = "nil";

    iSamples = 3;
    iOffset = 0;
    nBias = 1.0;

create
{
    setdesc(sTitle);
}

destroy
{
}

process: ma, frame, time
{
    nStep = (1 / Scene().fps) * nBias;
    nOffset = (1 / Scene().fps) * iOffset;
    vPosition = <0.0,0.0,0.0>;

    if(ItemName != "nil") {Item = Mesh(ItemName); ItemName = "nil";}
    if(Item)
      {

      iCount = 0;
      for(iS = -iSamples; iS <= iSamples; iS++)
        {
        vPosition += Item.getWorldPosition(time + (iS * nStep) + nOffset);
        iCount++; 
        }
      if(iCount > 1){vPosition = vPosition * (1 / iCount);}

      }
     
// ma

  ma.set(POSITION,vPosition);

}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        ItemName = io.read().asStr();
        iSamples = io.read().asInt();
        iOffset = io.read().asInt();
        nBias = io.read().asNum();
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        if(Item != nil)
            {
            io.writeln(string(Item.name));
            }
        else
            {
            io.writeln("nil");
            } 

        io.writeln(iSamples);
        io.writeln(iOffset);
        io.writeln(nBias);
    }
}

options
{

    if(reqisopen())
      {
      reqend();
      return;
      }

    reqbegin(sTitle + " " + sVersion);

    ctrl_c0 = ctlallitems("Item",Item);
    ctrl_c1 = ctlslider("Samples",iSamples,0,100);
    ctrl_c2 = ctlslider("Offset",iOffset,-100,100);
    ctrl_c3 = ctlpercent("Bias",nBias);

    // Developer
    ctlsep();
    ctrl_dev0 = ctltext("","developer: Stephen Culley","http://www.stephenculley.co.uk");

    // Refresh
    ctlrefresh(ctrl_c0,"refresh_c0"); // Item
    ctlrefresh(ctrl_c1,"refresh_c1"); // Samples
    ctlrefresh(ctrl_c2,"refresh_c2"); // Offset
    ctlrefresh(ctrl_c3,"refresh_c3"); // Bias

    reqopen();
}

refresh_c0:value // Item
{
    Item = value;
}

refresh_c1:value // Samples
{
    iSamples = value;
}

refresh_c2:value // Offset
{
    iOffset = value;
}

refresh_c3:value // Bias
{
    nBias = value;
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs