diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 169e6d806..8e090ef9f 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -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; +} diff --git a/Engine/source/T3D/tsStatic.h b/Engine/source/T3D/tsStatic.h index 03c74c651..835310c3d 100644 --- a/Engine/source/T3D/tsStatic.h +++ b/Engine/source/T3D/tsStatic.h @@ -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* usedAssetsList);