Skeleton.kl

Types

Skeleton (object)

The Skeleton object defines a skeleton hierarchy made up of an array of bones.

The Skeleton object defines a skeleton hierarchy made up of an array of bones. The bones arrays is assumed to be sorted in order of hierarchical traversal meaning that no bones parent can occur after it in the array.

参考

Bone, Character

/*
** Example: skeleton.kl
*/

require Characters;

operator entry(){

  //////////////////////////////////
  // Generate a chain of bones with a random shape.
  Bone bones[];
  bones.resize(5);
  Xfo parentXfo();
  for(Integer i=0; i<bones.size(); i++) {

    Bone bone;
    bone.name = "Bone"+i;
    bone.parentIndex = i-1;

    // compute the angles
    Scalar random = 0.5 - mathRandomScalar(12, i);
    Scalar xAngle = sin(random * 0.4 + Scalar(i) * 0.03) * 0.5;
    Scalar zAngle = cos(0.11 + Scalar(i) * 0.01) * 0.1;

    Scalar boneLength = 5.0;
    Xfo xfo;
    xfo.tr = Vec3(boneLength, 0.0, 0.0);
    xfo.ori.setFromEulerAngles(Vec3(xAngle, 0.0f, zAngle));
    bone.referencePose = parentXfo * xfo;
    bone.length = boneLength;
    bone.radius = 1.0;
    bone.setFlag(BONEFLAG_DEFORMER);
    bones[i] = bone;
    parentXfo = bone.referencePose;
  }

  Skeleton skeleton = Skeleton("MySkeleton", bones);
  report(skeleton.getDesc());
}

/*
** Output:

Skeleton { 
  name: MySkeleton 
  bones:[ 
    Bone { 
      name: Bone0
      length: +5.0
      radius: +1.0
      parent: -1
      childIndices: [1]
      mirrorBoneID: -1
      flags: 8
      color: {r:+1.0,g:+1.0,b:+0.0,a:+1.0}
      referencePose: {tr:{x:+5.0,y:+0.0,z:+0.0},ori:{v:{x:-2.880096e-2,y:+1.432657e-3,z:+0.049659},w:+0.998291},sc:{x:+1.0,y:+1.0,z:+1.0}}
    } 
    Bone { 
      name: Bone1
      length: +5.0
      radius: +1.0
      parent: 0
      childIndices: [2]
      mirrorBoneID: -1
      flags: 8
      color: {r:+1.0,g:+1.0,b:+0.0,a:+1.0}
      referencePose: {tr:{x:+9.974609,y:+0.495361,z:-2.860641e-2},ori:{v:{x:-0.040725,y:+2.859115e-3,z:+0.099121},w:+0.994262},sc:{x:+1.0,y:+1.0,z:+1.0}}
    } 
    Bone { 
      name: Bone2
      length: +5.0
      radius: +1.0
      parent: 1
      childIndices: [3]
      mirrorBoneID: -1
      flags: 8
      color: {r:+1.0,g:+1.0,b:+0.0,a:+1.0}
      referencePose: {tr:{x:+14.87695,y:+1.479736,z:-0.097396},ori:{v:{x:-1.088905e-2,y:+0.634861e-2,z:+0.148193},w:+0.988891},sc:{x:+1.0,y:+1.0,z:+1.0}}
    } 
    Bone { 
      name: Bone3
      length: +5.0
      radius: +1.0
      parent: 2
      childIndices: [4]
      mirrorBoneID: -1
      flags: 8
      color: {r:+1.0,g:+1.0,b:+0.0,a:+1.0}
      referencePose: {tr:{x:+19.65625,y:+2.944336,z:-0.17633},ori:{v:{x:+1.734161e-2,y:+0.965499e-2,z:+0.196716},w:+0.980224},sc:{x:+1.0,y:+1.0,z:+1.0}}
    } 
    Bone { 
      name: Bone4
      length: +5.0
      radius: +1.0
      parent: 3
      childIndices: []
      mirrorBoneID: -1
      flags: 8
      color: {r:+1.0,g:+1.0,b:+0.0,a:+1.0}
      referencePose: {tr:{x:+24.26953,y:+4.874023,z:-0.236846},ori:{v:{x:+0.055099,y:+1.436615e-2,z:+0.244323},w:+0.968017},sc:{x:+1.0,y:+1.0,z:+1.0}}
    } 
  ]
}

*/

Members

String name The name of the skeleton.
Bone[] bones The array of bones in the skeleton.
Xfo[] referenceLocalPoses A cache of the local reference poses for the skeleton. Solvers often use these values to compute offsets during animation.
UInt64 version /private.
Size[] deformerIndices a cache of the bone indices used as deformers.

Methods

  Skeleton ( in Skeleton other )
  Skeleton ( in String name )
  Skeleton ( in String name, in Bone bones[] )
  Skeleton ()
  addBone ! ( in Bone bone )
Skeleton clone ? ()
  computeSymmetry ! ()
Integer findBone ? ( in String boneName )
Integer findBone ? ( in String boneName, in Index startingPoint )
Bone[] getAllBones ? ()
Bone getBone ? ( in Index index )
Bone[] getBones ? ()
Size[] getDeformerIndices ? ()
Bone[] getDeformers ? ()
String getDesc ? ( in String indent, in Boolean includeBones )
String getDesc ? ()
String getName ? ()
Size getNumBones ? ()
Xfo getReferenceLocalPose ? ( in Index index )
Xfo getReferencePose ? ( in Index index )
UInt64 getVersion ? ()
  incrementVersion ! ()
  recomputeHierarchy ! ()

Functions

drawSkeleton

drawSkeleton ( in ISkeleton skeleton, io IPose pose, io InlineTransform rootTransform )

Generates a set of inline shapes nested under the provided rootTransform.