Bone objects are considered children of Mesh objects; Bones cannot exist by themselves. As such, access to Bone information must take place through the parent Mesh object. Bone objects essentially become data members of the LScript Mesh object.
mesh = Mesh();// Create a Mesh Object.
bone = mesh.bone(); // Create a Bone Object from
// the parent Mesh Object.
Note: Remember that not all of the common Data Members and Methods apply to Bone Objects.
restlength contains a floating-point number that represents the rest length of the Bone in meters.
Type returns a value which indicates the bone's type, 1 for Joint, 2 for Z-axis
innerlimit contains a floating-point number that represents the inner limit radius of the Bone (valid only if flags[2] is 'true').
outerlimit contains a floating-point number that represents the outer limit radius of the Bone (valid only if flags[2] is 'true').
flags[] holds an array of two boolean values that represent the Bone's current options:
[1] == true if Bone is active, or false if not. [2] == true if Bone is limited, or false if unlimited.
restparam(state) returns an array of three numbers that represent the value of a particular Bone state. The state value can be one of POSITION, RIGHT, UP, FORWARD, ROTATION, SCALING, PIVOT, WPOSITION, WRIGHT, WUP, and WFORWARD constants.
Examples:
This example, given an object and bones in an object, will cycle through the bones and display some of their information.
@version 2.2
@warnings
@name boneObjectAgentTest
@script generic
generic
{
// set the frame variable for
frame: 0
currTime = 0;
// Create Mesh Object
Agent from first object.
mesh =
Mesh(); // Create Bone
Object Agent from first bone in
// from mesh Object Agent.
bone = mesh.bone();
// Cycle through all bones until a bone value == 'nil'.while(bone)
{
// Display some of the current
bone’s
// values on frame 0, by
accessing bone Object Agent.
info("Bone Name: ", bone);
//
default attribute.
info("Bone
Position: ", bone.getPosition(currTime));
info("Bone
Rotation: ", bone.getRotation(currTime));
//
Cycle to next bone. If no bone is available, bone // will equal ‘nil’.
bone
= bone.next();
}
}