Game Development Reference
In-Depth Information
We iterate over the bones array and store the offsetMatrices values of each bone
in a single flat array, boneMatrices(this.flattenToArrayOffset(offsetMatrix,
this.boneMatrices, b * 16 )) . The flat array would look like:
boneMatrices[]=[bone11, bone12, bone13, bone14, bone21, bone22,
bone23,
bone24, bone31, bone32, bon33, bone34, bone41, bone42, bone43,
bone44,
bone111, bone112, bone113, bone114, bone121, bone122, bone123,
bone124, bone131, bone132, bone133, bone134, bone141, bone142,
bone143, bone144, bone211, bone212, bone213, bone214, bone221,
bone222, bone223, bone224, bone331, bone332, bone333, bone334,
bone341, bone342, bone343, bone344,
...
boneN11, boneN12, boneN13, boneN14, boneN21, boneN22, boneN23,
boneN24,
boneN31, boneN32, boneN33, boneN34, boneN41, boneN42, boneN43,
boneN44,]
The flattenToArrayOffset function takes offsetMatrix of each bone and
the boneMatrices array and copies offsetMatrix at the location b*16 . The
flattenToArrayOffset function is defined as follows:
RiggedMesh.prototype.flattenToArrayOffset=function(mat, flat, offset )
{
var te = mat;
flat[ offset ] = te[0];
flat[ offset + 1 ] = te[1];
flat[ offset + 2 ] = te[2];
flat[ offset + 3 ] = te[3];
flat[ offset + 4 ] = te[4];
flat[ offset + 5 ] = te[5];
flat[ offset + 6 ] = te[6];
flat[ offset + 7 ] = te[7];
flat[ offset + 8 ] = te[8];
flat[ offset + 9 ] = te[9];
flat[ offset + 10 ] = te[10];
flat[ offset + 11 ] = te[11];
flat[ offset + 12 ] = te[12];
flat[ offset + 13 ] = te[13];
flat[ offset + 14 ] = te[14];
flat[ offset + 15 ] = te[15];
return flat;
}
RiggedMesh.prototype.pose = function () {
this.updateMatrixWorld( true );
this.normalizeSkinWeights();
};
 
Search WWH ::




Custom Search