Node interface specific to deformation networks.
function correctBoneMatrixFromPrevBone(prevBone, startMatrix, prevMatrix)
{
var correctedMatrix = bones[prevBone];
if(correctedMatrix)
{
startMatrix.clear();
prevMatrix.clear();
startMatrix.multiplyEq(correctedMatrix);
prevMatrix.multiplyEq(correctedMatrix);
}
}
function correctBoneLength(nodeName, restLength, restOrientation, minLength, startMatrix, endMatrix)
{
if(restLength < minLength)
{
var lengthOffset =
new Vector2d(minLength, 0);
endMatrix.clear();
endMatrix.multiplyEq(startMatrix);
endMatrix.rotateDegrees(restOrientation,
new Vector3d(0,0,1));
endMatrix.translate(lengthOffset.x, lengthOffset.y, 0.0);
}
}
function correctDeformBone(prevBone, nodeName, nextBone, startMatrix, endMatrix, prevMatrix, i)
{
if(prevBone != "")
{
var nodeNameKey = nodeName+i.toString();
var prevBoneKey = prevBone+i.toString();
var nextBoneRadius = nextBone !=
"" ? Number(
node.
getTextAttr( nextBone, i,
"radius" )) : 0.0;
var minLength = radius + nextBoneRadius + 1/32;
correctBoneMatrixFromPrevBone(prevBoneKey, startMatrix, prevMatrix);
correctBoneLength(nodeNameKey, length, orientation, minLength, startMatrix, endMatrix);
}
}
correctDeformBone(prevBone, nodeName, nextBone, startMatrix, endMatrix, prevMatrix, i);