|
@@ -2019,6 +2019,41 @@ Point3F ShapeBase::getAIRepairPoint()
|
|
}
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------
|
|
|
|
+void ShapeBase::getNodeTransform(const char* nodeName, MatrixF* outMat)
|
|
|
|
+{
|
|
|
|
+ S32 nodeIDx = mDataBlock->getShapeResource()->findNode(nodeName);
|
|
|
|
+ const MatrixF& xfm = isMounted() ? mMount.xfm : MatrixF::Identity;
|
|
|
|
+
|
|
|
|
+ MatrixF nodeTransform(xfm);
|
|
|
|
+ const Point3F& scale = getScale();
|
|
|
|
+ if (nodeIDx != -1)
|
|
|
|
+ {
|
|
|
|
+ nodeTransform = mShapeInstance->mNodeTransforms[nodeIDx];
|
|
|
|
+ nodeTransform.mul(xfm);
|
|
|
|
+ }
|
|
|
|
+ // The position of the mount point needs to be scaled.
|
|
|
|
+ Point3F position = nodeTransform.getPosition();
|
|
|
|
+ position.convolve(scale);
|
|
|
|
+ nodeTransform.setPosition(position);
|
|
|
|
+ // Also we would like the object to be scaled to the model.
|
|
|
|
+ outMat->mul(mObjToWorld, nodeTransform);
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ShapeBase::getNodeVector(const char* nodeName, VectorF* vec)
|
|
|
|
+{
|
|
|
|
+ MatrixF mat;
|
|
|
|
+ getNodeTransform(nodeName, &mat);
|
|
|
|
+
|
|
|
|
+ mat.getColumn(1, vec);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ShapeBase::getNodePoint(const char* nodeName, Point3F* pos)
|
|
|
|
+{
|
|
|
|
+ MatrixF mat;
|
|
|
|
+ getNodeTransform(nodeName, &mat);
|
|
|
|
+ mat.getColumn(3, pos);
|
|
|
|
+}
|
|
|
|
|
|
void ShapeBase::getEyeTransform(MatrixF* mat)
|
|
void ShapeBase::getEyeTransform(MatrixF* mat)
|
|
{
|
|
{
|
|
@@ -5352,3 +5387,37 @@ void ShapeBase::setSelectionFlags(U8 flags)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+DefineEngineMethod(ShapeBase, getNodeTransform, MatrixF, (const char* nodeName), ,
|
|
|
|
+ "@brief Get the node/bone transform.\n\n"
|
|
|
|
+
|
|
|
|
+ "@param node/bone name to query\n"
|
|
|
|
+ "@return the node position\n\n")
|
|
|
|
+{
|
|
|
|
+ MatrixF mat;
|
|
|
|
+ object->getNodeTransform(nodeName, &mat);
|
|
|
|
+ return mat;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+DefineEngineMethod(ShapeBase, getNodeVector, VectorF, (const char* nodeName), ,
|
|
|
|
+ "@brief Get the node/bone vector.\n\n"
|
|
|
|
+
|
|
|
|
+ "@param node/bone name to query\n"
|
|
|
|
+ "@return the node vector\n\n")
|
|
|
|
+{
|
|
|
|
+ VectorF vec(0, 1, 0);
|
|
|
|
+ object->getNodeVector(nodeName, &vec);
|
|
|
|
+
|
|
|
|
+ return vec;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+DefineEngineMethod(ShapeBase, getNodePoint, Point3F, (const char* nodeName), ,
|
|
|
|
+ "@brief Get the node/bone position.\n\n"
|
|
|
|
+
|
|
|
|
+ "@param node/bone name to query\n"
|
|
|
|
+ "@return the node position\n\n")
|
|
|
|
+{
|
|
|
|
+ Point3F pos(0, 0, 0);
|
|
|
|
+ object->getNodePoint(nodeName, &pos);
|
|
|
|
+
|
|
|
|
+ return pos;
|
|
|
|
+}
|