new method tsstatic.getNodeTransform

used to look up a given node's transform by explicit name in a tsstatic object
This commit is contained in:
AzaezelX 2021-11-03 21:15:00 -05:00
parent e372545cc6
commit 19e4643707
2 changed files with 30 additions and 0 deletions

View file

@ -54,6 +54,7 @@
#include "materials/materialFeatureTypes.h"
#include "console/engineAPI.h"
#include "T3D/accumulationVolume.h"
#include "math/mTransform.h"
#include "gui/editor/inspector/group.h"
#include "console/typeValidators.h"
@ -1863,3 +1864,31 @@ void TSStatic::setSelectionFlags(U8 flags)
}
}
void TSStatic::getNodeTransform(const char *nodeName, const MatrixF &xfm, MatrixF *outMat)
{
S32 nodeIDx = getShapeResource()->findNode(nodeName);
MatrixF mountTransform = mShapeInstance->mNodeTransforms[nodeIDx];
mountTransform.mul(xfm);
const Point3F &scale = getScale();
// The position of the mount point needs to be scaled.
Point3F position = mountTransform.getPosition();
position.convolve(scale);
mountTransform.setPosition(position);
// Also we would like the object to be scaled to the model.
outMat->mul(mObjToWorld, mountTransform);
return;
}
DefineEngineMethod(TSStatic, getNodeTransform, TransformF, (const char *nodeName), ,
"@brief Get the world transform of the specified mount slot.\n\n"
"@param slot Image slot to query\n"
"@return the mount transform\n\n")
{
MatrixF xf(true);
object->getNodeTransform(nodeName, MatrixF::Identity, &xf);
return xf;
}

View file

@ -276,6 +276,7 @@ public:
void updateMaterials();
bool isAnimated() { return mPlayAmbient; }
void getNodeTransform(const char *nodeName, const MatrixF &xfm, MatrixF *outMat);
virtual void getUtilizedAssets(Vector<StringTableEntry>* usedAssetsList);