The Channel Object Agent provides a structured interface to individual channel functionality. The methods firstChannel() and nextChannel() return a Channel Object type. In some cases, a Channel Object Agent will be provided to a UDF (as in the case of the create() UDF for the Channel Filter LScript).
Your script does not directly use keyframe identifiers, and returns them as integer data types. Keyframe identifiers serve only as arguments to methods that require them.
name is the name of the channel as it appears in the Layout interface. (e.g., Graph Editor).
id is the integer id of the channel.
type is the type of the channel. This can be one of the following:
CHAN_NUMBER, CHAN_DISTANCE, CHAN_PERCENT, or CHAN_ANGLE.
parent(only works from LW9.31 onwards)
parent contains the LightWave Object Agent to whom the channel belongs.
keyCount returns the number of keys in the envelope associated with the channel.
keys is a linear array that holds the keyframe identifiers for all the keys in the envelope. It will always be 'keyCount' in length.
preBehavior holds the type of pre-behavior associated with the envelope. It will be one of: CHAN_RESET, CHAN_CONSTANT, CHAN_REPEAT, CHAN_OSCILLATE, CHAN_OFFSET, CHAN_LINEAR.
The string values: ‘reset,’, ‘constant,’ ‘repeat,’ ‘oscillate,’ ‘offset,’ or ‘linear’ can also be used.
Unlike most data members, this data member is NOT read-only. Assigning one of the above constants to it will actually alter the prebehavior of the associated envelope.
postBehavior holds the type of the post-behavior associated with the envelope. Except for its name, this data member functions identically to the 'preBehavior' data member. It returns or alters the post-behavioral setting for the envelope.
The value(time) method causes the channel to be evaluated at the specified time. The return values are floating-point numbers that should be interpreted based on the channel's type.
The event(UDF) method activates a callback function that is invoked whenever an event occurs on the channel. Such events could be creating or deleting keyframes in the envelope, or a changing the keyframe's value.
keyExists(<time>) returns either 'nil' if no key exists at the specified time index, or the identifier of the keyframe if it does.
setKeyValue(<key>,<value>) sets the value of the provided keyframe to the provided value. <value> is always a floating-point number.
setKeyCurve(<key>,<shape> sets the type of interpolation that evaluates the keyframe. This can be one of: CHAN_TCB, CHAN_HERMITE, CHAN_BEZIER, CHAN_LINEAR, CHAN_STEPPED.
Also, the strings: ‘TCB,’ ‘Hermite,’ ‘Bezier,’ ‘Linear,’ and ‘Stepped’ are acceptable.
setKeyHermite(<key>,<parm1>,<parm2>,<parm3>,<parm 4> allows you to set the four Hermite Spline coefficients. If you do not understand their use, you probably will not be using this method anyway.
setKeyTension(<key>,<value>) sets the tension value for the specified keyframe.
setKeyContinuity(<key>,<value>) sets the continuity value for the specified keyframe.
setKeyBias(<key>,<value>) sets the bias value for the specified keyframe.
getKeyValue(<key>) returns the floating-point value associated with the specified keyframe.
getKeyTime(<key>) returns the time index for the specified keyframe.
getKeyCurve(<key>) returns the curve type for the specified keyframe. See the entry for setKeyCurve() for a list of the constant values that are returned.
getKeyHermite(<key>) returns the four Hermite Spline coefficients that are currently in use for the specified keyframe. If get KeyCurve() does not return CHAN_HERMITE, then you probably do not want to call this method.
getKeyTension(<key>) returns the current tension setting for the keyframe.
getKeyContinuity(<key>) returns the current continuity setting for the keyframe.
getKeyBias(<key>) returns the current bias setting for the keyframe.
The createKey(<time>,<value>) method creates a new keyframe at the specified time index with the provided initial value. If the key is created successfully, the keyframe identifier is returned, otherwise 'nil' is returned. This method will cause the 'keyCount' and 'keys' data members to instantly update.
Keyframes can be deleted from the channel's envelope with the deleteKey(<key>) method. Because this method also causes the 'keyCount' and 'keys' data members to update in real time, you need to be very careful when using it within loops that are based on these data members.
The following Channel Filter script illustrates the use of the Channel Object Agent:
light = Light();
c = light.firstChannel();
last if c.name == "Position.X";
c = light.nextChannel();
// keep abreast of changes in this channel...
process: ca, frame, time
// Channel Object Agent event
// event code
// something happened to Light's
Expressions can be added and attached to channels by using the Graph editor CommandImput commands, found in the SDK. All expression names/ names of items referenced should be unique, or this could cause a crash in LW. Also, expression names and expressions should for safety be enclosed in quote marks as this will stop spaces or other odd characters crashing LW.Example
com = string("GE_CreateExpression ",exp_name," ",exp);
com = string("GE_AttachExpression ","Camera.Position.X"," ",exp_name);
myexp="\"Value * (1 -["+drivername+"]*["+myvisible+"]*["+myalpha+"])\""; // \" will give you a quote mark within a quote
mycom="GE_CreateExpression "+myexpname+" "+myexp;
Added graph editor commands to allow detaching of expressions, and clearing of unused expressions.
GE_DetachExpression schannelname sexpressionname [nclear]
GE_DetachExpressionID xchannelid sexpressionname [nclear]
Detached an expression from the channel identified either by name or by channel ID. If the optional clear argument is set to 1, then the expression will be cleared if it is no longer used by any channel.
GE_DetachExpressions schannelname [nclear]
GE_DetachExpressionsID xchannelid [nclear]
Detached all expressions from the channel identified either by name or by channel ID. If the optional clear argument is set to 1, then any expression detached will be cleared if it is no longer used by any channel.
Clears an expression, or all expressions, that are not in use by any channel.