mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
tsstatic aug cleanups
1- adds a hasNode method to see if a named node exists 2- cleans up getNodeTransform nomenclature and notes, and adds safeties
This commit is contained in:
parent
0a1fd3c278
commit
a75c64fef3
1 changed files with 26 additions and 9 deletions
|
|
@ -1865,28 +1865,45 @@ void TSStatic::setSelectionFlags(U8 flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TSStatic::hasNode(const char* nodeName)
|
||||||
|
{
|
||||||
|
|
||||||
|
S32 nodeIDx = getShapeResource()->findNode(nodeName);
|
||||||
|
return nodeIDx >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
void TSStatic::getNodeTransform(const char *nodeName, const MatrixF &xfm, MatrixF *outMat)
|
void TSStatic::getNodeTransform(const char *nodeName, const MatrixF &xfm, MatrixF *outMat)
|
||||||
{
|
{
|
||||||
|
|
||||||
S32 nodeIDx = getShapeResource()->findNode(nodeName);
|
S32 nodeIDx = getShapeResource()->findNode(nodeName);
|
||||||
|
|
||||||
MatrixF mountTransform = mShapeInstance->mNodeTransforms[nodeIDx];
|
MatrixF nodeTransform(xfm);
|
||||||
mountTransform.mul(xfm);
|
const Point3F& scale = getScale();
|
||||||
const Point3F &scale = getScale();
|
if (nodeIDx != -1)
|
||||||
|
{
|
||||||
|
nodeTransform = mShapeInstance->mNodeTransforms[nodeIDx];
|
||||||
|
nodeTransform.mul(xfm);
|
||||||
|
}
|
||||||
// The position of the mount point needs to be scaled.
|
// The position of the mount point needs to be scaled.
|
||||||
Point3F position = mountTransform.getPosition();
|
Point3F position = nodeTransform.getPosition();
|
||||||
position.convolve(scale);
|
position.convolve(scale);
|
||||||
mountTransform.setPosition(position);
|
nodeTransform.setPosition(position);
|
||||||
// Also we would like the object to be scaled to the model.
|
// Also we would like the object to be scaled to the model.
|
||||||
outMat->mul(mObjToWorld, mountTransform);
|
outMat->mul(mObjToWorld, nodeTransform);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DefineEngineMethod(TSStatic, getNodeTransform, TransformF, (const char *nodeName), ,
|
DefineEngineMethod(TSStatic, hasNode, bool, (const char* nodeName), ,
|
||||||
"@brief Get the world transform of the specified mount slot.\n\n"
|
"@brief Get if this model has this node name.\n\n")
|
||||||
|
{
|
||||||
|
return object->hasNode(nodeName);
|
||||||
|
}
|
||||||
|
|
||||||
"@param slot Image slot to query\n"
|
DefineEngineMethod(TSStatic, getNodeTransform, TransformF, (const char *nodeName), ,
|
||||||
|
"@brief Get the world transform of the specified node name.\n\n"
|
||||||
|
|
||||||
|
"@param node name query\n"
|
||||||
"@return the mount transform\n\n")
|
"@return the mount transform\n\n")
|
||||||
{
|
{
|
||||||
MatrixF xf(true);
|
MatrixF xf(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue