class M_Skeleton

The M_Skeleton class represents the actual skeleton structure that is encapsulated by a bone layer.

Member Functions

int CountBones()

Returns the number of bones in the skeleton.

Return value (int): number of bones

M_Bone Bone(id)

Access a particular bone in the skeleton.

Return value (M_Bone): a bone object
id (int): bone identifier

int BoneID(bone)

Given a bone object, this function returns the identifier value for that bone in the skeleton.

Return value (int): bone identifier
bone (M_Bone): a bone in the skeleton

int SelectedBoneID()

Returns the identifier of the currently selected bone.

Return value (int): bone identifier

void UpdateBoneMatrix(id)

Updates the transformation matrices for the given bone. Use this after changing a bone's position or rotation.

Return value: none
id (int): bone identifier

M_Bone AddBone(frame)

Create a new bone and add it to the skeleton.

Return value (M_Bone): the newly-created bone
frame (int): frame number

void DeleteBone(id, recursion=0)

Delete a bone from the skeleton.

Return value: none
id (int): bone identifier
recursion (int): ignore this argument - leave it set to 0

int CountBoneChildren(id)

Returns the number of child bones attached to the given bone.

Return value (int): number of children bones
id (int): bone identifier

int GetFirstChildBone(id)

Return the first child of the given bone.

Return value (int): bone identifier
id (int): bone identifier

bool IsBoneChild(boneID, childID)

Test whether one bone is a decendant of another.

Return value (bool): true if the childID bone is decended from boneID, otherwise false
boneID (int): bone identifier
childID (int): bone identifier

bool IsBoneParent(boneID, parentID)

Test whether one bone is an ancestor of another.

Return value (bool): true if parentID is an ancestor of boneID, otherwise false
boneID (int): bone identifier
parentID (int): bone identifier

int NearestBone(vec)

Returns the closest bone to a 2D vector position.

Return value (int): bone identifier
vec (LM_Vector2): a 2D position in the bone layer

void LockBone(id, frame)

Locks the given bone at a specified time.

Return value: none
id (int): bone identifier
frame (int): frame number

void UnlockBone(id, frame)

Unlocks the given bone at a specified time.

Return value: none
id (int): bone identifier
frame (int): frame number

void IKAngleSolver(boneID, target, iterMultiplier=1)

Runs the inverse kinematics solver in order to move a chain of bones to reach a specified target point. The specified bone will move as necessary in order for its tip to touch the given target.

Return value: none
boneID (int): bone identifier
target (const LM_Vector2): target location
iterMultiplier (int): the default setting of 1 should be fine, but increase this number for a more accurate IK solution

Member Variables

fBindingMode (int)

Which automatic binding mode should be used for this skeleton. See the binding mode constants.

class M_Skeleton {
  int32 GetNumBones @ CountBones();
  M_Bone *GetBone @ Bone(int32 id);
  M_Bone *GetBone @ BoneByName(const char *name);
  int32 GetBoneID @ BoneID(M_Bone *bone);
  int32 SelectedBoneID();
 
  void SelectNone();
  void SelectAll();
  void SelectInverse();
  void SelectConnected();
 
  void UpdateBoneMatrix(int32 id = -1);
 
  M_Bone *AddBone(int32 frame);
  void DeleteBone(int32 id, int32 recursion = 0);
  int32 CountBoneChildren(int32 id, bool ignoreControlledBones = false);
  int32 GetFirstChildBone(int32 id, bool ignoreControlledBones = false);
  bool IsBoneChild(int32 boneID, int32 childID);
  bool IsBoneParent(int32 boneID, int32 parentID);
  bool IsAncestorSelected(int32 id);
 
  int32 NearestBone(LM_Vector2 vec);
 
  void LockBone(int32 id, int32 frame);
  void UnlockBone(int32 id, int32 frame);
 
  void IKAngleSolver(int32 boneID, const LM_Vector2 &target, int32 iterMultiplier = 1);
 
  int32  fBindingMode;
};