Feedback

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

Tuesday, 13 September 2011

LScript - Master_AutoRefresh

LScript (Layout) to auto refreshes Layout while animating to keep many scripts uptodate in realtime. It is very useful and required by many scripts inorder for them to process correctly.

Compatible with Newtek LightWave 9.6 and above.

// LScript Master Class - www.StephenCulley.co.uk
//
// web   address: http://www.stephenculley.co.uk
// email address: email@stephenculley.co.uk

/* 
    LScript Master Class - Auto Refresh

    Master_AutoRefresh.ls

*/

@version 2.2
@warnings
@script master
@name *Auto Refresh

    // Title
    sTitle = "*Auto Refresh";

    // Version
    sVersion = "v1.0";

create
{
    setdesc(sTitle);
}

process: event, command
{
    if(event == COMMAND)
    Refresh();
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Master_MotionBaker


LScript (Layout) used to bake motion in many of my dynamic scripts such as used in Slider and Wheel & Axle.

Changes

  • Added "redraw" to preview calculations in realtime
  • Added Lock / Unlock
  • Added Bake Keys

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Master - Motion Baker

    Master_MotionBaker.ls

*/

@version 2.2
@warnings
@script master
@name *Motion Baker

    // Title
    sTitle = "*Motion Baker";

    // Version
    sVersion = "v1.0";

    bRedraw = false; // Redraw
    iParent = 0; // Parent

create
{
    setdesc(sTitle);

    // Comring
    comringattach("*MotionBaker","comring_motionbaker");
}

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

flags
{
    return(SCENE);
}

// COMRING

comring_motionbaker:event,data
{
    sMessage = comringdecode(@"s:200"@,data);

    if(strlower(sMessage) == "*parent") // Parent
        {
        if(iParent < event) iParent = event;
        }
}

process: event, command
{
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        bRedraw = io.read().asInt(); // Redraw
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        io.writeln(bRedraw); // Redraw
    }
}

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

    reqbegin(sTitle + " " + sVersion);

    reqsize(276,148);

    ctrl_0 = ctlbutton("Calculate",50,"button_calculate"); // Button Calculate
    ctrl_1 = ctlcheckbox("Redraw",bRedraw); // Redraw

    ctrl_2 = ctlbutton("Disable",50,"button_disable"); // Button Disable
    ctrl_3 = ctlbutton("Reset",50,"button_reset"); // Button Reset
    ctrl_4 = ctlbutton("Write",50,"button_write"); // Button Write
    ctrl_5 = ctlbutton("Read",50,"button_read"); // Button Read

    ctrl_6 = ctlsep();
    ctrl_7 = ctlbutton("Bake Keys",50,"button_bake"); // Button Bake
    ctrl_8 = ctlbutton("Lock All",50,"button_lock"); // Button Lock
    ctrl_9 = ctlbutton("Unlock All",50,"button_unlock"); // Button Unlock


    // Developer
    ctrl_dev0 = ctlsep();
    ctrl_dev1 = ctltext("","developer: Stephen Culley","http://www.stephenculley.co.uk");
    
    ctlposition(ctrl_0,10,10,90,20);
    ctlposition(ctrl_1,10,32,90,20);
    ctlposition(ctrl_2,114,10,75,20);
    ctlposition(ctrl_3,191,10,75,20);
    ctlposition(ctrl_4,114,32,75,20);
    ctlposition(ctrl_5,191,32,75,20);

    ctlposition(ctrl_6,0,60,276,4);
    ctlposition(ctrl_7,10,70,90,20);
    ctlposition(ctrl_8,114,70,75,20);
    ctlposition(ctrl_9,191,70,75,20);

    ctlposition(ctrl_dev0,0,98,276,4);
    ctlposition(ctrl_dev1,10,108,256,20);

    // Refresh
    ctlrefresh(ctrl_1,"refresh_c1"); // Redraw

    reqopen();
}

button_calculate // Calculate
{
    Scene = Scene();
    iFrame = (Scene.fps * Scene.currenttime).asInt(); // Current frame

    // Parent
    iParent = 0; // Parent
    sMessage = "parent";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    GoToFrame(Scene.previewstart);
    if(iParent <= 0)
        {
        GoToFrame(iFrame); // Restore current frame    
        return; // Exit if none available
        }

    // Reset
    sMessage = "reset";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);

    GoToFrame(Scene.previewstart);

    // Read
    sMessage = "read";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);

    for(f = Scene.previewstart;f <= Scene.previewend; f++)
        {

        for(p = 1; p <= iParent; p++)
            {
            // Write
            sMessage = "write";
            cMessage = comringencode(@"s:200"@,sMessage);
            comringmsg("*MotionBaker",p,cMessage);

            GoToFrame(f);

            // Read
            sMessage = "read";
            cMessage = comringencode(@"s:200"@,sMessage);
            comringmsg("*MotionBaker",p,cMessage);
            }

        if(bRedraw) RedrawNow(); // Redraw
        }

    GoToFrame(iFrame); // Restore current frame
    info("*Motion Baker calculated");
}

button_read // Read
{
    sMessage = "read";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker set to read");
}

button_reset // Reset
{
    sMessage = "reset";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker reset");
}

button_write // Write
{
    sMessage = "write";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker set to write");
}

button_disable // Disable
{
    sMessage = "disable";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker disabled");
}

button_bake // Bake
{
    sMessage = "bake";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker keys baked to channels");
}

button_lock // Lock
{
    sMessage = "lock";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker set to locked");
}

button_unlock // Unlock
{
    sMessage = "unlock";
    cMessage = comringencode(@"s:200"@,sMessage);
    comringmsg("*MotionBaker",0,cMessage);
    info("*Motion Baker set to unlocked");
}

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

Tuesday, 21 June 2011

LScript - Modeler_StitchWeldAverage

LScript (Modeler) works like average weld points but in selected pairs. This allows you to average weld multiple selected points in one go instead of needing to weld individually.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - Stitch Weld Average

    Modeler_StitchWeldAverage.ls

*/

@version 2.2
@warnings
@script modeler
@name *Stitch Weld Average

    // Title
    sTitle = "*Stitch Weld Average";

    // Version
    sVersion = "v1.0";

main
{
    // Selection - Point (DIRECT)
    selmode(DIRECT);
    iPointCount = pointcount();
    if(iPointCount <= 1) error("None or not enough points selected.");

    if((iPointCount & 1) != 0) iPointCount--; // Check if odd

    editbegin();

        for(iCurrentPoint = 1; iCurrentPoint <= iPointCount; iCurrentPoint += 2)
          {
         vAverage = (pointinfo(points[iCurrentPoint]) + pointinfo(points[iCurrentPoint + 1])) * 0.5; // Average Vector
          pointmove(points[iCurrentPoint],vAverage); // Move point           
          pointmove(points[iCurrentPoint + 1],vAverage); // Move point           
          }

    editend();

    mergepoints(0.0); // Merge Points

    info(iPointCount," point(s) welded.");
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Modeler_StitchWeld

LScript (Modeler) to weld points but in selected pairs. This allows you to stitch multiple selected points in one go instead of needing to weld individually.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - Stitch Weld

    Modeler_StitchWeld.ls

*/

@version 2.2
@warnings
@script modeler
@name *Stitch Weld

    // Title
    sTitle = "*Stitch Weld";

    // Version
    sVersion = "v1.0";

main
{
    // Selection - Point (DIRECT)
    selmode(DIRECT);
    iPointCount = pointcount();
    if(iPointCount <= 1) error("None or not enough points selected.");

    if((iPointCount & 1) != 0) iPointCount--; // Check if odd

    editbegin();

        for(iCurrentPoint = 1; iCurrentPoint <= iPointCount; iCurrentPoint += 2)
          {
          pointmove(points[iCurrentPoint],pointinfo(points[iCurrentPoint + 1])); // Move point           
          }

    editend();

    mergepoints(0.0); // Merge Points

    info(iPointCount," point(s) welded.");
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Modeler_RestOnGround

LScript (Modeler) for a single click rest on ground which only translates selected points so that they rest on the Y plane.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - Rest On Ground

    Modeler_RestOnGround.ls

*/

@version 2.2
@warnings
@script modeler
@name *Rest On Ground

    // Title
    sTitle = "*Rest On Ground";

    // Version
    sVersion = "v1.0";

main
{
    // Selection - Point (DIRECT)
    selmode(DIRECT);
    iPointCount = pointcount();
    if(iPointCount < 1) error("No points selected.");

    editbegin();

    vOffset = pointinfo(points[1]);

    if(iPointCount > 1)
      {   
      for(iCurrentPoint = 2; iCurrentPoint <= iPointCount; iCurrentPoint++)
        {
        vPoint = pointinfo(points[iCurrentPoint]);
        if(vPoint.y < vOffset.y) vOffset = vPoint;  
        }
      }

    vOffset = <0.0,-vOffset.y,0.0>;

    for(iCurrentPoint = 1; iCurrentPoint <= iPointCount; iCurrentPoint++)
      {
      pointmove(points[iCurrentPoint],pointinfo(points[iCurrentPoint]) + vOffset); // Move point           
      }

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

Friday, 10 June 2011

LScript - Image_Shutter


LScript (Layout) adds a projector style flicker to an animation.

Compatible with Newtek LightWave 9.6 and above.

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

/* 
    LScript Image Filter - Shutter

    Image_Shutter.ls

*/

@version 2.5
@warnings
@script image
@name *Shutter

    // Title
    sTitle = "*Shutter";

    // Version
    sVersion = "v1.0";

    nAmount = 0.2;

create
{
    setdesc(sTitle + " : " + nAmount);
}

process: ifo
{
    iProgress = ifo.height;
    if(runningUnder() != SCREAMERNET) moninit(iProgress);
    nShutter = randu() * nAmount;
    for(i = 1;i <= ifo.height;++i)
      {
      for(j = 1;j <= ifo.width;++j)
        {
        ifo.red[j,i] = ifo.red[j,i] - nShutter;
        ifo.green[j,i] = ifo.green[j,i] - nShutter;
        ifo.blue[j,i] = ifo.blue[j,i] - nShutter;
        }    
      if(runningUnder() != SCREAMERNET) if(monstep()) return;
      }
}

load: what,io
{
    if(what == SCENEMODE)
    {
        nAmount = io.read().asNum();
        setdesc(sTitle + " : " + nAmount);
    }
}

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

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

    // Control
    ctrl_c0 = ctlnumber("Amount",nAmount);

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

    return if !reqpost();

    nAmount = getvalue(ctrl_c0);

    setdesc(sTitle + " : " + nAmount);

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

LScript - Image_Noise


LScript (Layout) applies random noise in three different modes, monochrome, color, exposure and fBm noise. Exposure adds noise only to darker areas as they appear in real life photos. fBm is a perlin based noise using Fractal Brownian Motion.

Compatible with Newtek LightWave 9.6 and above.

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

/* 
    LScript Image Filter - Noise

    Image_Noise.ls

*/

@version 2.5
@warnings
@script image
@name *Noise

    // Title
    sTitle = "*Noise";

    // Version
    sVersion = "v1.0";

    aType = @"*Monochrome Noise : ","*Color Noise : ","*Exposure Noise : ","*fBm Noise : "@;
    iInterpolation = 1;
    iOctaves = 3;
    iType = 1;  
    nAmount = 0.5;
    nPersistence = 0.25;
    nScale = 0.02;

create
{
    setdesc(aType[iType] + nAmount);
}

process: ifo
{    
    if(iType == 1) // Monochrome
      {
      if(runningUnder() != SCREAMERNET) moninit(ifo.height);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          nNoise = (randu() * 2 - 1) * nAmount;  
          ifo.red[j,i] = ifo.red[j,i] + nNoise;
          ifo.green[j,i] = ifo.green[j,i] + nNoise;
          ifo.blue[j,i] = ifo.blue[j,i] + nNoise;
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }
      }

    else if(iType == 2) // Colour
      {
      if(runningUnder() != SCREAMERNET) moninit(ifo.height);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          ifo.red[j,i] = ifo.red[j,i] + ((randu() * 2 - 1) * nAmount);
          ifo.green[j,i] = ifo.green[j,i] + ((randu() * 2 - 1) * nAmount);
          ifo.blue[j,i] = ifo.blue[j,i] + ((randu() * 2 - 1) * nAmount);
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }
      }

    else if(iType == 3) // Exposure
      {
      if(runningUnder() != SCREAMERNET) moninit(ifo.height);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          ifo.red[j,i] = ifo.red[j,i] + ((1 - ifo.red[j,i]) * ((randu() * 2 - 1) * nAmount));
          ifo.green[j,i] = ifo.green[j,i] + ((1 - ifo.green[j,i]) * ((randu() * 2 - 1) * nAmount));
          ifo.blue[j,i] = ifo.blue[j,i] + ((1 - ifo.blue[j,i]) * ((randu() * 2 - 1) * nAmount));
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }
      }

    else if((iType == 4) && (iInterpolation == 1)) // Linear fBm
      {
      if(runningUnder() != SCREAMERNET) moninit(ifo.height);
      noiseseed(ifo.frame); // Noise Seed
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          nNoise = linearfBmnoise2D( * nScale,
                                    iOctaves,
                                    nPersistence) * nAmount;
          ifo.red[j,i] = ifo.red[j,i] + nNoise;
          ifo.green[j,i] = ifo.green[j,i] + nNoise;
          ifo.blue[j,i] = ifo.blue[j,i] + nNoise;
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }
      }

    else if((iType == 4) && (iInterpolation == 2)) // Cosine fBm
      {
      if(runningUnder() != SCREAMERNET) moninit(ifo.height);
      noiseseed(ifo.frame); // Noise Seed
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          nNoise = cosinefBmnoise2D( * nScale,
                                    iOctaves,
                                    nPersistence) * nAmount;
          ifo.red[j,i] = ifo.red[j,i] + nNoise;
          ifo.green[j,i] = ifo.green[j,i] + nNoise;
          ifo.blue[j,i] = ifo.blue[j,i] + nNoise;
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }
      }
}

// INTERPOLATION

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);
}

// NOISE

_noiseseed = 1;
_noiseresolution = 512;
_noise = nil;
_noiseoffset = nil;
_noiseperm = nil;

noiseinit
{  
    randomseed(_noiseseed); // Random Seed
    for(iN = 1; iN <= _noiseresolution; iN++)
      {
      _noise[iN] = (random() * 2) - 1; // -1.0..1.0
      _noiseperm[iN] = wrap(1,_noiseresolution,floor(random() * _noiseresolution));
      }

    for(iO = 1; iO <= 64; iO++)
      {
      _noiseoffset[iO] = ;
      }
}

noiseseed: seed
{
    _noiseseed = seed;
    noiseinit(); // Init
}

noiseresolution: resolution
{
    _noiseresolution = resolution;
    noiseinit(); // Init 
}

noiseperm1D: n // i
{
// !   if(_noiseperm == nil){noiseinit();} // Init
    return(_noiseperm[wrap(1,_noiseresolution,floor(n))]);
}

noiseperm2D: v // n
{
    return(noiseperm1D(v.y + noiseperm1D(v.x)));
}

noise2D: v // n
{
// !   if(_noise == nil){noiseinit();} // Init
    return(_noise[noiseperm2D(v)]);
}

linearnoise2D: v // n
{
    v = wrap(1,_noiseresolution,v); 
    vFrac = frac(v);
    vInt = v - vFrac;
    n1 = noise2D();
    n2 = noise2D();
    n3 = noise2D();
    n4 = noise2D();
    return(linear1D(linear1D(n1,n2,vFrac.x),linear1D(n3,n4,vFrac.x),vFrac.y));
}

cosinenoise2D: v // n
{
    v = wrap(1,_noiseresolution,v); 
    vFrac = frac(v);
    vInt = v - vFrac;
    n1 = noise2D();
    n2 = noise2D();
    n3 = noise2D();
    n4 = noise2D();
    return(cosine1D(cosine1D(n1,n2,vFrac.x),cosine1D(n3,n4,vFrac.x),vFrac.y));
}

linearfBmnoise2D: v,octaves,persistence // octaves = i | persistence = n (0.25) // n
{
// !   if(_noiseoffset == nil){noiseinit();} // Init
    nNoise = 0.0;
    for(iO = 1; iO <= octaves; iO++)
      {
      nNoise += linearnoise2D(<(v.x + _noiseoffset[iO].x) * (2 * iO),(v.y + _noiseoffset[iO].y) * (2 * iO),0.0>) * (persistence / iO);
      }
    return(nNoise);
}

cosinefBmnoise2D: v,octaves,persistence // octaves = i | persistence = n (0.25) // n
{
// !   if(_noiseoffset == nil){noiseinit();} // Init
    nNoise = 0.0;
    for(iO = 1; iO <= octaves; iO++)
      {
      nNoise += cosinenoise2D(<(v.x + _noiseoffset[iO].x) * (2 * iO),(v.y + _noiseoffset[iO].y) * (2 * iO),0.0>) * (persistence / iO);
      }
    return(nNoise);
}

// RANDOM

_randomseed = 0; // n Seed

randomseed: seed
{
    _randomseed = seed;
}

random
{
    n = (_randomseed * 214013 + 2531011) % 2^^24;
    _randomseed = n;
    n /= 2^^24; // 0..1
    return(n);
}

gaussianrandom
{
    n1 = random();
    n2 = random();
    if(n1 == 0.0){n1 = 0.01;}
    return(sqrt(-2.0 * log(n1)) * cos(2.0 * 3.1415926535 * n2));
}

// WRAP

wrap: min,max,n
{
    n = n - floor((n - min) / (max - min)) * (max - min);
    if(n < 0) n = n + max - min; // error check
    return(n);
}

load: what,io
{
    if(what == SCENEMODE)
    {
        iInterpolation = io.read().asInt();
        iOctaves = io.read().asInt();
        iType = io.read().asInt();
        nAmount = io.read().asNum();
        nPersistence = io.read().asNum();
        nScale = io.read().asNum();

        setdesc(aType[iType] + nAmount);
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        io.writeln(iInterpolation);
        io.writeln(iOctaves);
        io.writeln(iType);
        io.writeln(nAmount);
        io.writeln(nPersistence);
        io.writeln(nScale);
    }
}

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

    // Control
    ctrl_c0 = ctlchoice("Type",iType,@"Monochrome","Color","Exposure","fBm"@); // Type
    ctrl_c1 = ctlnumber("Amount",nAmount); // Amount
    ctrl_c2 = ctlslider("Octaves (fBm)",iOctaves,1,64); // Octaves
    ctrl_c3 = ctlnumber("Persistence (fBm)",nPersistence); // Persistence
    ctrl_c4 = ctlnumber("Scale (fBm)",nScale); // Scale
    ctrl_c5 = ctlchoice("Interpolation (fBm)",iInterpolation,@"Linear","Cosine"@); // Interpolation

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

    return if !reqpost();

    iType = getvalue(ctrl_c0);
    nAmount = getvalue(ctrl_c1);
    iOctaves = getvalue(ctrl_c2);
    nPersistence = getvalue(ctrl_c3);
    nScale = getvalue(ctrl_c4);
    iInterpolation = getvalue(ctrl_c5);

    setdesc(aType[iType] + nAmount);

    reqend();
}


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

LScript - Image_Exposure


LScript (Layout) to simulates how over exposure on a photo bleeds to over expose areas of an image in to white.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Image Filter - Exposure

    Image_Exposure.ls

*/

@version 2.5
@warnings
@script image
@name *Exposure

    // Title
    sTitle = "*Exposure";

    // Version
    sVersion = "v1.0";

    nAmount = 0.5;

create
{
    setdesc(sTitle + " : " + nAmount);
}

process: ifo
{
    iProgress = ifo.height;
    if(runningUnder() != SCREAMERNET) moninit(iProgress);
    for(i = 1;i <= ifo.height;++i)
      {
      for(j = 1;j <= ifo.width;++j)
        {
        nExposure = 0.0; 
        if(ifo.red[j,i] > nAmount) nExposure += (ifo.red[j,i] - nAmount);
        if(ifo.green[j,i] > nAmount) nExposure += (ifo.green[j,i] - nAmount);
        if(ifo.blue[j,i] > nAmount) nExposure += (ifo.blue[j,i] - nAmount);
        nExposure *= 0.333;                      
        ifo.red[j,i] = clip(0.0,1.0,ifo.red[j,i] + nExposure);
        ifo.green[j,i] = clip(0.0,1.0,ifo.green[j,i] + nExposure);
        ifo.blue[j,i] = clip(0.0,1.0,ifo.blue[j,i] + nExposure);
        }
      if(runningUnder() != SCREAMERNET) if(monstep()) return;
      }
}

// CLIP

clip: min,max,n
{
    if(n < min) n = min;
    if(n > max) n = max;
    return(n);
}

load: what,io
{
    if(what == SCENEMODE)
    {
        nAmount = io.read().asNum();
        setdesc(sTitle + " : " + nAmount);
    }
}

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

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

    // Control
    ctrl_c0 = ctlnumber("Amount",nAmount);

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

    return if !reqpost();

    nAmount = getvalue(ctrl_c0);
    setdesc(sTitle + " : " + nAmount);

    reqend();
}


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

LScript - Image_Duo


LScript (Layout) to apply a two tone colour effect from two selected colours.

Compatible with Newtek LightWave 9.6 and above.

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

/* 
    LScript Image Filter - Duo

    Image_Duo.ls

*/

@version 2.5
@warnings
@script image
@name *Duo

    // Title
    sTitle = "*Duo";

    // Version
    sVersion = "v1.0";

    vColorA = <0,0,0>;
    vColorB = <255,255,255>;

create
{
    setdesc(sTitle);
}

process: ifo
{
    iProgress = ifo.height;
    if(runningUnder() != SCREAMERNET) moninit(iProgress);
    vColorA01 = vColorA * (1 / 255); 
    vColorB01 = vColorB * (1 / 255); 
    for(i = 1;i <= ifo.height;++i)
      {
      for(j = 1;j <= ifo.width;++j)
        {
 nAmount = clip(0,1,(ifo.red[j,i] + ifo.green[j,i] + ifo.blue[j,i]) * (1 / 3));
        ifo.red[j,i] = (vColorA01.x * (1 - nAmount)) + (vColorB01.x * nAmount);
        ifo.green[j,i] = (vColorA01.y * (1 - nAmount)) + (vColorB01.y * nAmount);
        ifo.blue[j,i] = (vColorA01.z * (1 - nAmount)) + (vColorB01.z * nAmount);
        }
      if(runningUnder() != SCREAMERNET) if(monstep()) return;
      }
}

// CLIP

clip: min,max,n
{
    if(n < min) n = min;
    if(n > max) n = max;
    return(n);
}

load: what,io
{
    if(what == SCENEMODE)
    {
        vColorA = io.read().asVec();
        vColorB = io.read().asVec();
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        io.writeln(vColorA);
        io.writeln(vColorB);
    }
}

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

    // Control
    ctrl_c0 = ctlcolor("Color A",vColorA);
    ctrl_c1 = ctlcolor("Color B",vColorB);

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

    return if !reqpost();

    vColorA = getvalue(ctrl_c0);
    vColorB = getvalue(ctrl_c1);

    reqend();
}


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

LScript - Image_Black&White


LScript (Layout) black & white image filter.

Compatible with Newtek LightWave 9.6 and above.

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

/* 
    LScript Image Filter - Black & White

    Image_Black&White.ls

*/

@version 2.5
@warnings
@script image
@name *Black & White

    // Title
    sTitle = "*Black & White";

    // Version
    sVersion = "v1.0";

create
{
    setdesc(sTitle);
}

process: ifo
{
    iProgress = ifo.height;
    if(runningUnder() != SCREAMERNET) moninit(iProgress);
    for(i = 1;i <= ifo.height;++i)
      {
      for(j = 1;j <= ifo.width;++j)
        {
        nAverage = (ifo.red[j,i] + ifo.green[j,i] + ifo.blue[j,i]) * (1 / 3);
         
        ifo.red[j,i] = nAverage;
        ifo.green[j,i] = nAverage;
        ifo.blue[j,i] = nAverage;
        }
      if(runningUnder() != SCREAMERNET) if(monstep()) return;
      }
}

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

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

    return if !reqpost();

    reqend();
}


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

LScript - Modeler_Snap


LScript (Modeler) to snaps points in different ways to other points. It can align points in linear, either side of currently selected points or by making points snap to there nearest neighbour a set distance away.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - Snap

    Modeler_Snap.ls

*/

@version 2.2
@warnings
@script modeler
@name *Snap

    // Title
    sTitle = "*Snap";

    // Version
    sVersion = "v1.0";

    ctrl_c0,ctrl_c1,ctrl_c2,ctrl_c3,ctrl_c4,ctrl_c5;

main
{

    // Store
    bAxisX = recall("bAxisX",true);
    bAxisY = recall("bAxisY",true);
    bAxisZ = recall("bAxisZ",true);
    nSeperation = recall("nSeperation",0.1);
    iType = recall("iType",1);
    bTwoPointPolygon = recall("bTwoPointPolygon",false);

    reqbegin(sTitle + " " + sVersion);

    // Reset
    ctrl_res0 = ctlbutton("Reset",50,"button_reset"); // Button Reset
    ctlsep();

    // Control
    ctrl_c0 = ctlcheckbox("X", bAxisX);
    ctrl_c1 = ctlcheckbox("Y", bAxisY);
    ctrl_c2 = ctlcheckbox("Z", bAxisZ);
    ctrl_c3 = ctldistance("Seperation",nSeperation);
    ctrl_c4 = ctlchoice("Type",iType,@"Linear","+/-","Nearest"@);
    ctrl_c5 = ctlcheckbox("Make Two Point Polygons", bTwoPointPolygon);

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

    return if !reqpost();

    bAxisX = getvalue(ctrl_c0); // X
    bAxisY = getvalue(ctrl_c1); // Y
    bAxisZ = getvalue(ctrl_c2); // Z
    nSeperation = getvalue(ctrl_c3);
    iType = getvalue(ctrl_c4);
    bTwoPointPolygon = getvalue(ctrl_c5);

    // Store
    store("bAxisX",bAxisX);
    store("bAxisY",bAxisY);
    store("bAxisZ",bAxisZ);
    store("nSeperation",nSeperation);
    store("iType",iType);
    store("bTwoPointPolygon",bTwoPointPolygon);

    // Selection - Point (GLOBAL)
    selmode(GLOBAL);
    iPointCountBefore = pointcount();

    // Selection - Point (DIRECT)
    selmode(DIRECT);
    iPointCount = pointcount();
    if(iPointCount <= 1) error("None or not enough points selected.");

    undogroupbegin(); // Undo

    moninit(iPointCount,"Processing...");  // Progress Monitor

    if(iType == 1) // Linear
    {
    editbegin();

        vSnapPoint = pointinfo(points[1]);
        vTempPoint = vSnapPoint;
        for(iCurrentPoint = 2; iCurrentPoint <= iPointCount; iCurrentPoint++)
          {
          if(bAxisX) vSnapPoint.x += nSeperation; // X
          if(bAxisY) vSnapPoint.y += nSeperation; // Y
          if(bAxisZ) vSnapPoint.z += nSeperation; // Z
          pointmove(points[iCurrentPoint],vSnapPoint); // Move point           

          // Two Point Polygon
          if(bTwoPointPolygon)
            {
            point[1] = addpoint(vTempPoint);
            point[2] = addpoint(vSnapPoint);
            addpolygon(point);
            }

          vTempPoint = vSnapPoint;

          monstep(); // Progress Monitor
          }

    editend();
    }

    if(iType == 2) // +/-
    {
    editbegin();

        vSnapPoint = pointinfo(points[1]);
        for(iCurrentPoint = 2; iCurrentPoint <= iPointCount; iCurrentPoint++)
          {
          vPoint = pointinfo(points[iCurrentPoint]);
          vTempPoint = vSnapPoint;
          if(bAxisX) vTempPoint.x = snap(vPoint.x,vSnapPoint.x,nSeperation); // X
          if(bAxisY) vTempPoint.y = snap(vPoint.y,vSnapPoint.y,nSeperation); // Y
          if(bAxisZ) vTempPoint.z = snap(vPoint.z,vSnapPoint.z,nSeperation); // Z
          pointmove(points[iCurrentPoint],vTempPoint); // Move point           

          // Two Point Polygon
          if(bTwoPointPolygon)
            {
            point[1] = addpoint(vTempPoint);
            point[2] = addpoint(vSnapPoint);
            addpolygon(point);
            }

          vSnapPoint = vTempPoint;

          monstep(); // Progress Monitor
          }

    editend();
    }

    if(iType == 3) // Nearest
    {
    editbegin();

        aPoints[1] = pointinfo(points[1]); // Add point to array
        for(iCurrentPoint = 2; iCurrentPoint <= iPointCount; iCurrentPoint++)
          {
          vPoint = pointinfo(points[iCurrentPoint]);
          vSnapPoint = aPoints[1];
          Distance = distance3D(vPoint,vSnapPoint);
          for(iCurrentPoint = 1; iCurrentPoint <= aPoints.size(); iCurrentPoint++)
            {
            DistanceNew = distance3D(vPoint,aPoints[iCurrentPoint]);
            if(DistanceNew < Distance)
              {
              vSnapPoint = aPoints[iCurrentPoint];
              Distance = DistanceNew;            
              }
            }
          vTempPoint = vSnapPoint;
          if(bAxisX) vTempPoint.x = snap(vPoint.x,vSnapPoint.x,nSeperation); // X
          if(bAxisY) vTempPoint.y = snap(vPoint.y,vSnapPoint.y,nSeperation); // Y
          if(bAxisZ) vTempPoint.z = snap(vPoint.z,vSnapPoint.z,nSeperation); // Z
          pointmove(points[iCurrentPoint],vTempPoint); // Move point

          // Two Point Polygon
          if(bTwoPointPolygon)
            {
            point[1] = addpoint(vTempPoint);
            point[2] = addpoint(vSnapPoint);
            addpolygon(point);
            }
           
          aPoints[iCurrentPoint] = vTempPoint; // Add to array

          monstep(); // Progress Monitor
          }

    editend();

    monend(); // Progress Monitor
    }

    // Selection - Point (GLOBAL)
    selmode(GLOBAL);
    iPointCountAfter = pointcount();
    if((iPointCountAfter - iPointCountBefore) > 0)
      {
      for(s = 1; s <= (iPointCountAfter - iPointCountBefore) ; s++){aSelection[s] = s + iPointCountBefore;}
      selmode(USER);
      selpoint(SET, POINTNDX, aSelection);

      mergepoints(0.0); // Merge Points
      }

    undogroupend(); // Undo

}

button_reset
{
    setvalue(ctrl_c0,true); // X
    setvalue(ctrl_c1,true); // Y
    setvalue(ctrl_c2,true); // Z
    setvalue(ctrl_c3,0.1); // Seperation
    setvalue(ctrl_c4,1); // Type
    setvalue(ctrl_c5,false); // Two Point Polygon
}

// SNAP

snap: n1,n2,n
{
    if(n1 < n2){return(n2 - n);}
  else
    {return(n2 + n);}
}

// VECTOR

distance3D: v1, v2 // n
{
    // Vector
    return(sqrt(((v2.x - v1.x) * (v2.x - v1.x)) +
                ((v2.y - v1.y) * (v2.y - v1.y)) + 
                ((v2.z - v1.z) * (v2.z - v1.z))));
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Modeler_2PointPolyChain


LScript (Modeler) to produces a 2 point polychain between two selected points.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - 2PointPolyChain

    Modeler_2PointPolyChain.ls

*/

@version 2.2
@warnings
@script modeler
@name *2 Point Poly Chain

    // Title
    sTitle = "*2 Point Poly Chain";

    // Version
    sVersion = "v1.0";

    ctrl_c0;

main
{

    // Recall
    iNumber = recall("iNumber",10);

    reqbegin(sTitle + " " + sVersion);

    // Reset
    ctrl_res0 = ctlbutton("Reset",50,"button_reset"); // Button Reset
    ctlsep();

    // Control
    ctrl_c0 = ctlinteger("Number",iNumber);

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

    return if !reqpost();

    iNumber = getvalue(ctrl_c0);

    // Store
    store("iNumber",iNumber);

    // Selection - Point (GLOBAL)
    selmode(GLOBAL);
    iPointCountBefore = pointcount();

    // Selection - Point (DIRECT)
    selmode(DIRECT);
    iPointCount = pointcount();
    if(iPointCount <= 1) error("Select two points.");
    if(iPointCount > 2) error("Select two points.");

    moninit(iNumber,"Processing...");  // Progress Monitor

        editbegin();

            vStart = pointinfo(points[1]);
            vEnd = pointinfo(points[2]);

            nDistance = distance3D(vStart,vEnd);
            if(iNumber <> 0.0){vOffset = (vEnd - vStart) / iNumber;}else{vOffset = <0.0,0.0,0.0>;}
           
            for(n = 1; n <= iNumber; n++)
              {
              aPoints[1] = addpoint(vStart + (vOffset * (n - 1)));
              aPoints[2] = addpoint(vStart + (vOffset * n));
              addpolygon(aPoints);

              monstep(); // Progress Monitor
              } 

        editend();

    monend(); // Progress Monitor

    // Selection - Point (GLOBAL)
    selmode(GLOBAL);
    iPointCountAfter = pointcount();
    if((iPointCountAfter - iPointCountBefore) > 0)
      {
      for(s = 1; s <= (iPointCountAfter - iPointCountBefore) ; s++){aSelection[s] = s + iPointCountBefore;}
      selmode(USER);
      selpoint(SET, POINTNDX, aSelection);

      mergepoints(0.0); // Merge Points
      }
}

button_reset
{
    setvalue(ctrl_c0,10); // Number
}

// VECTOR 3D

distance3D: v1, v2 // n
{
    // Vector
    return(sqrt(((v2.x - v1.x) * (v2.x - v1.x)) +
                ((v2.y - v1.y) * (v2.y - v1.y)) + 
                ((v2.z - v1.z) * (v2.z - v1.z))));
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Modeler_2PointPoly


LScript (Modeler) to produce standalone 2 point polys for use with "VOLT" and some other of my lscripts. It produces 2 point poly's that are unconnected and all located at <0.0,0.0,0.0> that can then be displaced inside of layout.

Compatible with Newtek LightWave 9.6 and above.

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

/*  
    LScript Modeler - 2 Point Poly

    Modeler_2PointPoly.ls

*/

@version 2.2
@warnings
@script modeler
@name *2 Point Poly

    // Title
    sTitle = "*2 Point Poly";

    // Version
    sVersion = "v1.0";

    ctrl_c0;

main
{

    // Recall
    iNumber = recall("iNumber",1024);

    reqbegin(sTitle + " " + sVersion);

    // Reset
    ctrl_res0 = ctlbutton("Reset",50,"button_reset"); // Button Reset
    ctlsep();

    // Control
    ctrl_c0 = ctlinteger("Number",iNumber);

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

    return if !reqpost();

    iNumber = getvalue(ctrl_c0);

    // Store
    store("iNumber",iNumber);

    moninit(iNumber,"Processing...");  // Progress Monitor

        editbegin();
            
            for(n = 1; n <= iNumber; n++)
              {
              aPoints[1] = addpoint(0.0,0.0,0.0);
              aPoints[2] = addpoint(0.0,0.0,0.0);
              addpolygon(aPoints);
            
              monstep(); // Progress Monitor
              } 

        editend();

    monend(); // Progress Monitor
}

button_reset
{
    setvalue(ctrl_c0,1024); // Number
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

LScript - Motion_Shift


LScript (Layout) to shift channels by another objects or parent motion. It is a easier way to setup offsets for shifted pivot setups where an object parented to another can shift its pivot back to place to allow its parent pivot to move freely.

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

    Motion_Shift.ls

*/

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

    // Title
    sTitle = "*Shift";

    // Version
    sVersion = "v1.0";

    // Item
    ControlItem = nil;
    ControlItemName = "nil";

    // Variable
    nMultiplierX = 0.0;
    nMultiplierY = 0.0;
    nMultiplierZ = 0.0;
    nMultiplierH = 0.0;
    nMultiplierP = 0.0;
    nMultiplierB = 0.0;
    nMultiplierSX = 0.0;
    nMultiplierSY = 0.0;
    nMultiplierSZ = 0.0;

create
{
    setdesc(sTitle + " - Parent");

    info("Shift - Parent used unless Item is selected");
}

destroy
{
}

process: ma, frame, time
{     
    // Variables

    vPosition = ma.get(POSITION,time);
    vRotation = ma.get(ROTATION,time);
    vScale = ma.get(SCALING,time);
    vControlItemPosition = <0,0,0>;
    vControlItemRotation = <0,0,0>;
    vControlItemScale = <0,0,0>;

    if(ControlItemName != "nil") {ControlItem = Mesh(ControlItemName); ControlItemName = "nil";}
    if(ControlItem)
        {
        setdesc(sTitle + " - " + ControlItem.name); 
        vControlItemPosition = ControlItem.getPosition(time);
        vControlItemRotation = ControlItem.getRotation(time);
        vControlItemScale = ControlItem.getScaling(time);
        }
    else
        {
        Item = ma.objID;
        ItemParent = Item.parent;
        if(ItemParent)
            {
            setdesc(sTitle + " - Parent");
            vControlItemPosition = ItemParent.getPosition(time);
            vControlItemRotation = ItemParent.getRotation(time);
            vControlItemScale = ItemParent.getScaling(time);
            }
        }
       
    // Position / Rotation / Scale
    vPosition.x += (vControlItemPosition.x * nMultiplierX);
    vPosition.y += (vControlItemPosition.y * nMultiplierY);
    vPosition.z += (vControlItemPosition.z * nMultiplierZ);
    vRotation.x += (vControlItemRotation.x * nMultiplierH);
    vRotation.y += (vControlItemRotation.y * nMultiplierP);
    vRotation.z += (vControlItemRotation.z * nMultiplierB);
    vScale.x += (vControlItemScale.x * nMultiplierSX);
    vScale.y += (vControlItemScale.y * nMultiplierSY);
    vScale.z += (vControlItemScale.z * nMultiplierSZ);

// ma

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

}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        ControlItemName = io.read().asStr();
        nMultiplierX = io.read().asNum();
        nMultiplierY = io.read().asNum();
        nMultiplierZ = io.read().asNum();
        nMultiplierH = io.read().asNum();
        nMultiplierP = io.read().asNum();
        nMultiplierB = io.read().asNum();
        nMultiplierSX = io.read().asNum();
        nMultiplierSY = io.read().asNum();
        nMultiplierSZ = io.read().asNum();

    }
}

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

        io.writeln(nMultiplierX);
        io.writeln(nMultiplierY);
        io.writeln(nMultiplierZ);
        io.writeln(nMultiplierH);
        io.writeln(nMultiplierP);
        io.writeln(nMultiplierB);
        io.writeln(nMultiplierSX);
        io.writeln(nMultiplierSY);
        io.writeln(nMultiplierSZ);
    }
}

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

    ctrl_c0 = ctlmeshitems("Control Item",ControlItem);
    ctrl_c1 = ctlnumber("Position Multiplier X",nMultiplierX);
    ctrl_c2 = ctlnumber("Position Multiplier Y",nMultiplierY);
    ctrl_c3 = ctlnumber("Position Multiplier Z",nMultiplierZ);
    ctrl_c4 = ctlnumber("Rotation Multiplier H",nMultiplierH);
    ctrl_c5 = ctlnumber("Rotation Multiplier P",nMultiplierP);
    ctrl_c6 = ctlnumber("Rotation Multiplier B",nMultiplierB);
    ctrl_c7 = ctlnumber("Scale Multiplier X",nMultiplierSX);
    ctrl_c8 = ctlnumber("Scale Multiplier Y",nMultiplierSY);
    ctrl_c9 = ctlnumber("Scale Multiplier Z",nMultiplierSZ);

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

    return if !reqpost();

    ControlItem = getvalue(ctrl_c0);
    nMultiplierX = getvalue(ctrl_c1);
    nMultiplierY = getvalue(ctrl_c2);
    nMultiplierZ = getvalue(ctrl_c3);
    nMultiplierH = getvalue(ctrl_c4);
    nMultiplierP = getvalue(ctrl_c5);
    nMultiplierB = getvalue(ctrl_c6);
    nMultiplierSX = getvalue(ctrl_c7);
    nMultiplierSY = getvalue(ctrl_c8);
    nMultiplierSZ = getvalue(ctrl_c9);

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

LScript - Motion_Limit


LScript (Layout) to min/max a selected channel which can be applied after any motion plugin or script.

Changes

  • Channels - X,Y,Z,H,P,B,SX.SY,SZ
  • Minimum value
  • Maximum value

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

    Motion_Limit.ls

*/

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

    // Title
    sTitle = "*Limit";

    // Version
    sVersion = "v1.0";

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

create
{
    setdesc(sTitle + " - Channel " + aChannel[iChannel] + " Min " + nMin + " Max " + nMax);
}

destroy
{
}

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

    // Channel
    if(iChannel == 1)vPosition.x = clip(nMin,nMax,vPosition.x);
    if(iChannel == 2)vPosition.y = clip(nMin,nMax,vPosition.y);
    if(iChannel == 3)vPosition.z = clip(nMin,nMax,vPosition.z);
    if(iChannel == 4)vRotation.x = clip(nMin,nMax,vRotation.x);
    if(iChannel == 5)vRotation.y = clip(nMin,nMax,vRotation.y);
    if(iChannel == 6)vRotation.z = clip(nMin,nMax,vRotation.z);
    if(iChannel == 7)vScaling.x = clip(nMin,nMax,vScaling.x);
    if(iChannel == 8)vScaling.y = clip(nMin,nMax,vScaling.y);
    if(iChannel == 9)vScaling.z = clip(nMin,nMax,vScaling.z);

// ma

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

}

// CLIP

clip: min,max,n
{
    if(n < min) n = min;
    if(n > max) n = max;
    return(n);
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        iChannel = io.read().asInt();
        nMin = io.read().asNum();
        nMax = io.read().asNum();
        setdesc(sTitle + " - Channel " + aChannel[iChannel] + " Min " + nMin + " Max " + nMax);
    }
}

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

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

    ctrl_c0 = ctlchoice("Channel",iChannel,@"X","Y","Z","H","P","B","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");

    return if !reqpost();

    iChannel = getvalue(ctrl_c0);
    nMin = getvalue(ctrl_c1);
    nMax = getvalue(ctrl_c2);
    setdesc(sTitle + " - Channel " + aChannel[iChannel] + " Min " + nMin + " Max " + nMax);

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

LScript - Motion_Channel


LScript (Layout) to make one selected channel drive another selected channel.
Changes

  • Input Channels - X,Y,Z,H,P,B,SX.SY,SZ
  • Output Channels - X,Y,Z,H,P,B,SX.SY,SZ
  • Operators - -,+,Abs
  • Channel "multiplier" added

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

    Motion_Channel.ls

*/

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

    // Title
    sTitle = "*Channel";

    // Version
    sVersion = "v1.0";

    ChannelItem = nil;
    ChannelItemName = "nil";

    iInputChannel = 1;
    iOutputChannel = 1;
    iOperator = 1;
    nMultiplier = 1.0;

create
{
    setdesc("*Channel - Select Item");

    info("Channel - Select Item");
}

destroy
{
}

process: ma, frame, time
{     
    // Variables

    vPosition = ma.get(POSITION,time);
    vRotation = ma.get(ROTATION,time);
    vScaling = ma.get(SCALING,time);

    nInput = 0.0;

    if(ChannelItemName != "nil") {ChannelItem = Mesh(ChannelItemName); ChannelItemName = "nil";}
    if(ChannelItem)
        {
        setdesc(sTitle + " - " + ChannelItem.name); 
        vChannelPosition = ChannelItem.getPosition(time);
        vChannelRotation = ChannelItem.getRotation(time);
        vChannelScaling = ChannelItem.getScaling(time);
        }
    else
        {
        setdesc(sTitle + " - Select Item");
        vChannelPosition = <0,0,0>;
        vChannelRotation = <0,0,0>;
        vChannelScaling = <0,0,0>;
        }
       

    // Input Channel
    if(iInputChannel == 1)
      nInput = vChannelPosition.x;
    else if(iInputChannel == 2)
      nInput = vChannelPosition.y;
    else if(iInputChannel == 3)
      nInput = vChannelPosition.z;
    else if(iInputChannel == 4)
      nInput = vChannelRotation.x;
    else if(iInputChannel == 5)
      nInput = vChannelRotation.y;
    else if(iInputChannel == 6)
      nInput = vChannelRotation.z;
    else if(iInputChannel == 7)
      nInput = vChannelScaling.x;
    else if(iInputChannel == 8)
      nInput = vChannelScaling.y;
    else if(iInputChannel == 9)
      nInput = vChannelScaling.z;

    // Multiplier
    nInput *= nMultiplier;

    // Output

    // +
    if(iOperator == 1)
        {
        if(iOutputChannel == 1)
          vPosition.x += nInput;
        else if(iOutputChannel == 2)
          vPosition.y += nInput;
        else if(iOutputChannel == 3)
          vPosition.z += nInput;
        else if(iOutputChannel == 4)
          vRotation.x += nInput;
        else if(iOutputChannel == 5)
          vRotation.y += nInput;
        else if(iOutputChannel == 6)
          vRotation.z += nInput;
        else if(iOutputChannel == 7)
          vScaling.x += nInput;
        else if(iOutputChannel == 8)
          vScaling.y += nInput;
        else if(iOutputChannel == 9)
          vScaling.z += nInput;
        }

    // -
    else if(Operator == 2)
        {
        if(iOutputChannel == 1)
          vPosition.x -= nInput;
        else if(iOutputChannel == 2)
          vPosition.y -= nInput;
        else if(iOutputChannel == 3)
          vPosition.z -= nInput;
        else if(iOutputChannel == 4)
          vRotation.x -= nInput;
        else if(iOutputChannel == 5)
          vRotation.y -= nInput;
        else if(iOutputChannel == 6)
          vRotation.z -= nInput;
        else if(iOutputChannel == 7)
          vScaling.x -= nInput;
        else if(iOutputChannel == 8)
          vScaling.y -= nInput;
        else if(iOutputChannel == 9)
          vScaling.z -= nInput;
        }

    // Abs
    else if(iOperator == 3)
        if(nMultiplier >= 0)
            {
            if(iOutputChannel == 1)
              vPosition.x += abs(nInput);
            else if(iOutputChannel == 2)
              vPosition.y += abs(nInput);
            else if(iOutputChannel == 3)
              vPosition.z += abs(nInput);
            else if(iOutputChannel == 4)
              vRotation.x += abs(nInput);
            else if(iOutputChannel == 5)
              vRotation.y += abs(nInput);
            else if(iOutputChannel == 6)
              vRotation.z += abs(nInput);
            else if(iOutputChannel == 7)
              vScaling.x += abs(nInput);
            else if(iOutputChannel == 8)
              vScaling.y += abs(nInput);
            else if(iOutputChannel == 9)
              vScaling.z += abs(nInput);
            }
        else
            {
            if(iOutputChannel == 1)
              vPosition.x -= abs(nInput);
            else if(iOutputChannel == 2)
              vPosition.y -= abs(nInput);
            else if(iOutputChannel == 3)
              vPosition.z -= abs(nInput);
            else if(iOutputChannel == 4)
              vRotation.x -= abs(nInput);
            else if(iOutputChannel == 5)
              vRotation.y -= abs(nInput);
            else if(iOutputChannel == 6)
              vRotation.z -= abs(nInput);
            else if(iOutputChannel == 7)
              vScaling.x -= abs(nInput);
            else if(iOutputChannel == 8)
              vScaling.y -= abs(nInput);
            else if(iOutputChannel == 9)
              vScaling.z -= abs(nInput);
            }

// ma

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

}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        ChannelItemName = io.read().asStr();
        iInputChannel = io.read().asInt();
        iOutputChannel = io.read().asInt();
        iOperator = io.read().asInt();
        nMultiplier = io.read().asNum();
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {

        if(ChannelItem != nil)
            {
            io.writeln(string(ChannelItem.name));
            }
        else
            {
            io.writeln("nil");
            }    

        io.writeln(iInputChannel);
        io.writeln(iOutputChannel);
        io.writeln(iOperator);
        io.writeln(nMultiplier);

    }
}

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

    ctrl_c0 = ctlmeshitems("Channel Item",ChannelItem);
    ctrl_c1 = ctlchoice("Input Channel",iInputChannel,@"X","Y","Z","H","P","B","SX","SY","SZ"@);
    ctrl_c2 = ctlchoice("Output Channel",iOutputChannel,@"X","Y","Z","H","P","B","SX","SY","SZ"@);
    ctrl_c3 = ctlchoice("Operator",iOperator,@"+","-","Abs"@);
    ctrl_c4 = ctlnumber("Multiplier",nMultiplier);

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

    return if !reqpost();

    ChannelItem = getvalue(ctrl_c0);    
    iInputChannel = getvalue(ctrl_c1);
    iOutputChannel = getvalue(ctrl_c2);
    iOperator = getvalue(ctrl_c3);
    nMultiplier = getvalue(ctrl_c4);

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