Game Development Reference
In-Depth Information
The preceding function initializes the vertex buffer objects for skinIndices and
skinWeights . It then loads the data in the GPU memory using the ESSL function,
gl.bufferData . The addBone function is defined as follows:
RiggedMesh.prototype.addBone = function( bone ) {
if ( bone === undefined ) {
bone = new Bone( this );
}
this.bones.push( bone );
return bone;
};
RiggedMesh.prototype.updateMatrixWorld = function () {
var offsetMatrix = mat4.create();
return function ( force ) {
this.matrixAutoUpdate && this.updateMatrix();
// update matrixWorld
if ( this.matrixWorldNeedsUpdate || force ) {
if ( this.parent ) {
mat4.mul( this.matrixWorld,this.parent.matrixWorld,
this.modelMatrix );
} else {
mat4.copy(this.matrixWorld,this.modelMatrix );
}
this.matrixWorldNeedsUpdate = false;
force = true;
}
// update children
for ( var i = 0, len = this.children.length; i < len; i ++ ) {
var child = this.children[ i ];
if ( child instanceof Bone ) {
child.update( this.identityMatrix, false );
} else {
child.updateMatrixWorld( true );
}
}
// make a snapshot of the bones' rest position
if ( this.boneInverses == undefined ) {
this.boneInverses = [];
for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
var inverse = mat4.create();
mat4.invert(inverse, this.bones[ b ].skinMatrix );
this.boneInverses.push( inverse );
}
}
 
Search WWH ::




Custom Search