2
0
Эх сурвалжийг харах

Merge pull request #660 from Azaezel/alpha40/tsStaticNodeLookup

new method tsstatic.getNodeTransform
Brian Roberts 3 жил өмнө
parent
commit
e53012a938

+ 29 - 0
Engine/source/T3D/tsStatic.cpp

@@ -54,6 +54,7 @@
 #include "materials/materialFeatureTypes.h"
 #include "materials/materialFeatureTypes.h"
 #include "console/engineAPI.h"
 #include "console/engineAPI.h"
 #include "T3D/accumulationVolume.h"
 #include "T3D/accumulationVolume.h"
+#include "math/mTransform.h"
 
 
 #include "gui/editor/inspector/group.h"
 #include "gui/editor/inspector/group.h"
 #include "console/typeValidators.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;
+}

+ 1 - 0
Engine/source/T3D/tsStatic.h

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