Character (object)¶
An object defining a high level character.
The Character object defining a characters by combining a skeleton, pose and a set of geometries to be deformed.
/*
** Example: character.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("", bones);
Character character('Clip');
character.setSkeleton(skeleton);
report(character.getDesc());
LocalBoundingVolume bvol = character.getBoundingVolume();
report(bvol);
}
/*
** Output:
Character:{
name: Clip
skeleton: Skeleton {
name:
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}}
}
]
}
pose: Pose {
xfos:[
{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}}
{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}}
{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}}
{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}}
{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}}
]
}
num geometries:0
geometries:[
]
}
{type:1,pt1:{x:+0.0,y:+0.0,z:+0.0},pt2:{x:+0.0,y:+0.0,z:+0.0},sc1:-1.0,sc2:+0.0,sc3:+0.0,sc4:+0.0}
*/
Members¶
String | name | The name of the character. |
Geometry[] | geometries | The array fo geometries that make up the character |
Mat44[] | bindShapeTransforms | |
Mat44[] | skinningMatrices | |
Skeleton | skeleton | The Skeleton defining the hierarchy of bones of the character. |
IPose | pose | The pose of the character. |
Xfo | globalXfo | The global transform of the character. |
Geometry[] | deformedGeometries | The cache of deformed geometries that make up the character. When deforming on the CPU, we cache the cloned meshes here. |
LocalBoundingVolume | localBVol | The bounding volume of the deformed character. |
Methods¶
Character ( in Character other ) | |
Character ( in Character other, in String nameSuffix ) | |
Character ( in String name ) | |
Character () | |
Character | clone ? () |
Mat44 | getBindShapeTransform ? ( in Index index ) |
LocalBoundingVolume | getBoundingVolume ? () |
Geometry | getDeformedGeometry ! ( in Index index ) |
PolygonMesh | getDeformedMesh ! ( in Index index ) |
String | getDesc ? ( in String indent, in Boolean includeGeometries ) |
String | getDesc ? () |
Geometry | getGeometry ? ( in Index index ) |
Xfo | getGlobalXfo ? () |
PolygonMesh | getMesh ? ( in Index index ) |
String | getName ? () |
Size | getNumGeometries ? () |
IPose | getPose ? () |
ISkeleton | getSkeleton ? () |
Mat44[] | getSkinningMatrices ? () |
UInt64 | getVersion ? () |
incrementVersion ! () | |
setClipPoseTime ! ( in Float32 time ) | |
setGlobalXfo ! ( in Xfo globalXfo ) | |
setPose ! ( in IPose pose ) | |
setSkeleton ! ( in Skeleton skeleton ) |
Methods in detail¶
Character ( in Character other )
copy constructor
Character ( in Character other, in String nameSuffix )
This constructor is useful for creating instances of characters based on an existing instance. The constructed instance shares most of the data with the original instance, but maintains a unique pose(if it is a ClipPose) This enables the pose to be evaluated at different times to generate unique motion.
other | The source character to use in the clone. |
nameSuffix | The suffix to add to the name of the new character |
Standard constructor taking a name
name | The initial name of the character |
Character ()
default constructor
clone method
Mat44 Character.getBindShapeTransform? ( in Index index )
Returns the bind shape transform for the given geometry.
the | index of the geometry to return the bind shape transform for. |
LocalBoundingVolume Character.getBoundingVolume? ()
Returns the current bounding volume of the character.
Geometry Character.getDeformedGeometry! ( in Index index )
Returns a deformed copy of one of the geometries stored in the character.
PolygonMesh Character.getDeformedMesh! ( in Index index )
Returns a deformed copy of one of the meshes stored in the character.
String Character.getDesc? ( in String indent, in Boolean includeGeometries )
Generates a Description string of this character.
indent | The indentation to use when generating the string. |
includeGeometries | An option to include the descs of the goemeties in the returned string. |
Generates a Description string of this character.
Geometry Character.getGeometry? ( in Index index )
Returns a geometry with the given index.
index | The index of the geometry to return. |
Xfo Character.getGlobalXfo? ()
Returns the global Xfo of the character. The Global Xfo is used to globally position the character. It is applied as an offset to the computed pose.
PolygonMesh Character.getMesh? ( in Index index )
Returns a mesh with the given index.
index | The index of the mesh to return. |
Returns the name of the character.
Size Character.getNumGeometries? ()
Returns the number of geometries this character is made up of
Returns the pose object for this character.
ISkeleton Character.getSkeleton? ()
Returns the Skeleton of this character.
Mat44[] Character.getSkinningMatrices? ()
Returns the skinning matrices for the character based on the current pose. The skinning matrices combine the reference pose stored in the skeleton, the transforms in the pose structure, and the global Xfo of character.
UInt64 Character.getVersion? ()
Returns the internal version counter.
Character.incrementVersion! ()
Increments the internal version counter.
Character.setClipPoseTime! ( in Float32 time )
changes the time on the clip pose
Character.setGlobalXfo! ( in Xfo globalXfo )
Sets the global Xfo of the character. The Global Xfo is used to globally position the character. It is applied as an offset to the computed pose.
Character.setPose! ( in IPose pose )
Sets a the pose object for this character.
Character.setSkeleton! ( in Skeleton skeleton )
Sets a new skeleton to be used for this character.
注釈
The Pose of the character will be reset when this method is called.