deformation Class Reference

The deformation JavaScript global object. Provide deformation node parent matrix transformations. More...

Public Slots

bool isDeformationShown (String node)
 
Matrix4x4lastDeformMatrix (String &node, int frame)
 
Matrix4x4nextDeformMatrix (String &node, int frame)
 
Matrix4x4lastRestMatrix (String &node)
 
Matrix4x4nextRestMatrix (String &node)
 

Detailed Description

The deformation JavaScript global object. Provide deformation node parent matrix transformations.

Node interface specific to deformation networks.

function correctBoneMatrixFromPrevBone(prevBone, startMatrix, prevMatrix)
{
var correctedMatrix = bones[prevBone];
if(correctedMatrix)
{
// override startMatrix and prevMatrix with prevbone correction
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);
lengthOffset = scene.toOGL(lengthOffset);
// redo matrix
endMatrix.clear();
endMatrix.multiplyEq(startMatrix);
endMatrix.rotateDegrees(restOrientation, new Vector3d(0,0,1));
endMatrix.translate(lengthOffset.x, lengthOffset.y, 0.0);
bones[nodeName] = new Matrix4x4().multiply(endMatrix);
}
}
function correctDeformBone(prevBone, nodeName, nextBone, startMatrix, endMatrix, prevMatrix, i)
{
if(prevBone != "")
{
var nodeNameKey = nodeName+i.toString();
var prevBoneKey = prevBone+i.toString();
var length = Number(node.getTextAttr( nodeName, i, "length" ));
var radius = Number(node.getTextAttr( nodeName, i, "radius" ));
var orientation = Number(node.getTextAttr( nodeName, i, "orientation" ));
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);
}
}
startMatrix = deformation.lastDeformMatrix( nodeName, 0 );
endMatrix = deformation.nextDeformMatrix( nodeName, 0 );
prevMatrix = ( prevBone != "" ) ? deformation.nextDeformMatrix( prevBone, 0 ) : (new Matrix4x4());
correctDeformBone(prevBone, nodeName, nextBone, startMatrix, endMatrix, prevMatrix, i);

Member Function Documentation

◆ isDeformationShown

bool deformation::isDeformationShown ( String  node)
slot

◆ lastDeformMatrix

Matrix4x4* deformation::lastDeformMatrix ( String &  node,
int  frame 
)
slot

◆ lastRestMatrix

Matrix4x4* deformation::lastRestMatrix ( String &  node)
slot

◆ nextDeformMatrix

Matrix4x4* deformation::nextDeformMatrix ( String &  node,
int  frame 
)
slot

◆ nextRestMatrix

Matrix4x4* deformation::nextRestMatrix ( String &  node)
slot