Feedback

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

Wednesday 31 July 2013

LScript - Channel_Filter


LScript (Layout) to filter envelopes to smooth it out based on time samples.

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

    Channel_Filter.ls

*/

@version 2.2
@warnings
@script channel
@name *Filter

    // Title
    sTitle = "*Filter";

    // Version
    sVersion = "v1.0";

    // Variable
    iFilter = 5;

    // Controls 
    ctrl_c0;

create: channel
{
    setdesc(sTitle + " - " + iFilter);
}

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

process: ca, frame, time
{
    fps = (1 / Scene().fps);
    iCount = 0;
    nValue = 0.0;
    for(iS = -iFilter; iS <= iFilter; iS++)
      {
      nValue += ca.get(time + (iS * fps));
      iCount++; 
      }
    if(iCount > 1){nValue = nValue * (1 / iCount);}

    // ca    
    ca.set(nValue);
}

load: what,io
{
    if(what == SCENEMODE)   // processing an ASCII scene file
    {
        if(io.read().asStr() == sTitle + " " + sVersion)
            {
            iFilter = io.read().asInt(); // Filter
            setdesc(sTitle + " - " + iFilter);
            }
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        // Header
        io.writeln(sTitle + " " + sVersion);
        io.writeln(iFilter); // Filter
    }
}

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

    reqbegin(sTitle + " " + sVersion);

    ctrl_c0 = ctlinteger("Filter",iFilter);   

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

    // Refresh
    ctlrefresh(ctrl_c0,"refresh_c0"); // Filter

    reqopen();
}

refresh_c0:value // Filter
{
    iFilter = min(max(0,value),100);
    setvalue(ctrl_c0,iFilter); 
    setdesc(sTitle + " - " + iFilter);
}
All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

No comments:

Post a Comment