Feedback

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

Sunday, 17 February 2013

Library - Interpolation

The Library is where code samples, building blocks of scripts will be shared.

linear1D: n1,n2,i // i = interpolation point (0-1)
{
    return(n1 * (1 - i) + n2 * i);     
}

cosine1D: n1,n2,i // i = interpolation point (0-1)
{
    i2 = (1 - cos(i * 3.1415926535)) * 0.5;
    return(n1 * (1 - i2) + n2 * i2);     
}

bicubic1D: n1,n2,n3,n4,i // i = interpolation point (0-1)
{
    i2 = i * i;
    n_01 = n4 - n3 - n1 + n2;
    n_02 = n1 - n2 - n_01;
    n_03 = n3 - n1;
    n_04 = n2;
    return(n_01 * i * i2 + n_02 * i2 + n_03 * i + n_04);
}

Friday, 15 February 2013

Crackle - Roughnecks: Starship Troopers Chronicles

Over at Crackle they are currently showing Roughnecks : Starship Chronicles. It was one of the first LightWave television series and is based on Starship Troopers.

For a bit of nostalgia visit http://www.crackle.com/c/roughnecksstarshiptrooperschroniclesfullepisodes 

Stephen

Monday, 11 February 2013

LightWave Plugin Database

Ken over at the LightWave Plugin Database has been hard at work improving his website that is a trove of resources for users and artists. Check out his site - http://www.lwplugindb.com

Stephen

Monday, 4 February 2013

LScript - Motion_VolumeTrick

LScript (Layout) for motion values based on position during motion blur used to fake volume effects.

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 - VolumeTrick

    Motion_VolumeTrick.ls

*/

@version 2.2
@warnings
@script motion
@name *Volume Trick

    // Title
    sTitle = "*Volume Trick";

    // Version
    sVersion = "v1.1";

    // Item
    Item;

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

create : id
{
    // Description
    setdesc(sTitle);
 
    // Info
    info("*Volume Trick - Motion blur must be enabled.");

    // Items
    Item = id; // Item
}

destroy
{
}

process: ma, frame, time
{     
    // Variables
    vPosition = ma.get(POSITION,time);
    vRotation = ma.get(ROTATION,time);
    vScaling = ma.get(SCALING,time);

    if(Camera().blurLength(time) <> 0.0)
      {
      // Map Range
      n01 = maprange01(frame * (1 / Scene().fps),(frame + 1) * (1 / Scene().fps),time);

        switch(iChannel)
        {

          case 1: // X
                  vPosition.x = linear1D(vPosition.x + nMin,vPosition.x + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;
  
          case 2: // Y
                  vPosition.y = linear1D(vPosition.y + nMin,vPosition.y + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 3: // Y
                  vPosition.z = linear1D(vPosition.z + nMin,vPosition.z + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 4: // H
                  vRotation.x = linear1D(vRotation.x + nMin,vRotation.x + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 5: // P
                  vRotation.y = linear1D(vRotation.y + nMin,vRotation.y + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 6: // B
                  vRotation.z = linear1D(vRotation.z + nMin,vRotation.z + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 7: // S
                  vScaling.x = linear1D(vScaling.x + nMin,vScaling.x + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  vScaling.y = linear1D(vScaling.y + nMin,vScaling.y + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  vScaling.z = linear1D(vScaling.z + nMin,vScaling.z + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 8: // SX
                  vScaling.x = linear1D(vScaling.x + nMin,vScaling.x + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

          case 9: // SY
                  vScaling.y = linear1D(vScaling.y + nMin,vScaling.y + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;

         case 10: // SZ
                  vScaling.z = linear1D(vScaling.z + nMin,vScaling.z + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
                  break;
      

        }      


      } 

// ma

  ma.set(POSITION,vPosition);
  ma.set(ROTATION,vRotation);
  ma.set(SCALING,vScaling);

}

// INTERPOLATION

linear1D: n1,n2,i // i = interpolation point (0-1)
{
    return(n1 * (1 - i) + n2 * i);     
}

// MAP RANGE

maprange01: n1,n2,i

{    
    if(n2-n1 == 0.0){return(0.0);}
  else
    {return((1/(n2-n1)) * (i-n1));}
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        sHeader = io.read().asStr();

        if(sHeader == sTitle + " " + sVersion)
            {
            iChannel = io.read().asInt();
            nMin = io.read().asNum(); // Min
            nMax = io.read().asNum(); // Max
            break;
            }

        if(sHeader == sTitle + " " + sVersion) // v1.0 Compatibility
            {
            iChannel = io.read().asInt();
            nMin := 0.0; // Min
            nMax = io.read().asNum(); // Max          
            break;
            }
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        // Header
        io.writeln(sTitle + " " + sVersion);
        io.writeln(iChannel);
        io.writeln(nMin); // Min
        io.writeln(nMax); // Max
    }
}

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

    reqbegin(sTitle + " " + sVersion);

    ctrl_c0 = ctlchoice("Channel",iChannel,@"X","Y","Z","H","P","B","S","SX","SY","SZ"@);
    ctrl_c1 = ctlnumber("Min",nMin);   
    ctrl_c2 = ctlnumber("Max",nMax);   

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

    // Refresh
    ctlrefresh(ctrl_c0,"refresh_c0"); // Channel
    ctlrefresh(ctrl_c1,"refresh_c1"); // Min
    ctlrefresh(ctrl_c2,"refresh_c2"); // Max

    reqopen();
}

refresh_c0:value // Channel
{
    iChannel = value;
}

refresh_c1:value // Min
{
    nMin = value;
}

refresh_c2:value // Max
{
    nMax = value;
}


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

LScript - Channel_VolumeTrick

LScript (Layout) to shift channel values based on motion position during motion blur used to fake volume effects.

Compatible with Newtek LightWave 9.6 and above.

// LScript Channel Filter - www.StephenCulley.co.uk
//
// web   address: http://www.stephenculley.co.uk
// email address: email@stephenculley.co.uk

/* 
    LScript Channel Filter - Volume Trick

    Channel_VolumeTrick.ls

*/

@version 2.2
@warnings
@script channel
@name *Volume Trick

    // Title
    sTitle = "*Volume Trick";

    // Version
    sVersion = "v1.1";

    // Variable
    nMin = 0.0;
    nMax = 1.0;

create: channel
{
    setdesc(sTitle);

    // Info
    info("*Volume Trick - Motion blur must be enabled.");
}

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

process: ca, frame, time
{
    nValue = ca.get(time);

    if(Camera().blurLength(time) <> 0.0)
      {
      // Map Range
      n01 = maprange01(frame * (1 / Scene().fps),(frame + 1) * (1 / Scene().fps),time);
      nValue = linear1D(nValue + nMin,nValue + (nMax * (1 / Camera().blurLength(time))) - nMin,n01);
      }

    // ca    
    ca.set(nValue);
}

// INTERPOLATION

linear1D: n1,n2,i // i = interpolation point (0-1)
{
    return(n1 * (1 - i) + n2 * i);     
}

// MAP RANGE

maprange01: n1,n2,i

{    
    if(n2-n1 == 0.0){return(0.0);}
  else
    {return((1/(n2-n1)) * (i-n1));}
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        if(io.read().asStr() == sTitle + " " + sVersion)
            {
            nMin = io.read().asNum(); // Min
            nMax = io.read().asNum(); // Max
            }
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        // Header
        io.writeln(sTitle + " " + sVersion);
        io.writeln(nMin); // Min
        io.writeln(nMax); // Max
    }
}


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

    reqbegin(sTitle + " " + sVersion);

    ctrl_c0 = ctlnumber("Min",nMin);   
    ctrl_c1 = ctlnumber("Max",nMax);   

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

    // Refresh
    ctlrefresh(ctrl_c0,"refresh_c0"); // Min
    ctlrefresh(ctrl_c1,"refresh_c1"); // Max

    reqopen();
}

refresh_c0:value // Min
{
    nMin = value;
}

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