Feedback

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

Wednesday, 18 December 2013

LScript - Motion_TimeReference


LScript (Layout) to quickly add motion to a channel based on time.

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 - Time Reference

    Motion_TimeReference.ls

*/

@version 2.2
@warnings
@script motion
@name *Time Reference

    // Title
    sTitle = "*Time Reference";

    // Version
    sVersion = "v1.0";

    // Variable
    aChannel = @"X","Y","Z","H","P","B","SX","SY","SZ"@; 
    iChannel = 1;
    nAmount = 1.0;

create
{
  _setdesc(); // setdesc();
}

destroy
{
}

_setdesc
{
  if(iChannel >= 1 && iChannel <= 3){setdesc(sTitle + " - Channel " + aChannel[iChannel] + " @ " + nAmount + "m/s");}
  if(iChannel >= 4 && iChannel <= 6){setdesc(sTitle + " - Channel " + aChannel[iChannel] + " @ " + nAmount + " degrees");}
  if(iChannel >= 7 && iChannel <= 9){setdesc(sTitle + " - Channel " + aChannel[iChannel] + " @ " + nAmount + "m/s");}
}

process: ma, frame, time
{   
 if(nAmount <> 0.0)
   {
    if(iChannel == 1) // X
      {
       vPosition = ma.get(POSITION,time) + ;
       // ma
       ma.set(POSITION,vPosition);
      }
    if(iChannel == 2) // Y
      {
       vPosition = ma.get(POSITION,time) + <0.0,nAmount * time,0.0>;
       // ma
       ma.set(POSITION,vPosition);
      }
    if(iChannel == 3) // Z
      {
       vPosition = ma.get(POSITION,time) + <0.0,0.0,nAmount * time>;
       // ma
       ma.set(POSITION,vPosition);
      }
    if(iChannel == 4) // H
      {
       vRotation = ma.get(ROTATION,time) + ;
       // ma
       ma.set(ROTATION,vRotation);
      }
    if(iChannel == 5) // P
      {
       vRotation = ma.get(ROTATION,time) + <0.0,nAmount * time,0.0>;
       // ma
       ma.set(ROTATION,vRotation);
      }
    if(iChannel == 6) // B
      {
       vRotation = ma.get(ROTATION,time) + <0.0,0.0,nAmount * time>;
       // ma
       ma.set(ROTATION,vRotation);
      }
    if(iChannel == 7) // SX
      {
       vScaling = ma.get(SCALING,time) + ;
       // ma
       ma.set(SCALING,vScaling);
      }
    if(iChannel == 8) // SY
      {
       vScaling = ma.get(SCALING,time) + <0.0,nAmount * time,0.0>;
       // ma
       ma.set(SCALING,vScaling);
      }
    if(iChannel == 9) // SZ
      {
       vScaling = ma.get(SCALING,time) + <0.0,0.0,nAmount * time>;
       // ma
       ma.set(SCALING,vScaling);
      }

    }
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        iChannel = io.read().asInt();
        nAmount = io.read().asNum();
        _setdesc(); // setdesc();
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        io.writeln(iChannel);
        io.writeln(nAmount);
    }
}

options
{
    reqbegin(sTitle + " " + sVersion);

    ctrl_c0 = ctlchoice("Channel",iChannel,@"X","Y","Z","H","P","B","SX","SY","SZ"@);
    ctrl_c1 = ctlnumber("Amount",nAmount);

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

    return if !reqpost();

    iChannel = getvalue(ctrl_c0);
    nAmount = getvalue(ctrl_c1);
    _setdesc(); // setdesc();

    reqend();
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

No comments:

Post a comment