Steve_Yorkshire Posted September 24, 2018 Share Posted September 24, 2018 Need to find the position of the Eye node? No problem! GetEyePoint()!Need to find the position of any other node or bone in the player model? Errr ... Introducing getNodePoint! (original from Tim-MGT but I updated it just now to work engineDefines).In shapeBase.h near getEyeTransform in the "public" section add: virtual void getNodeTransform(const char* nodeName, MatrixF* mat); virtual void getNodeVector(const char* nodeName, VectorF* vec); void getNodePoint(const char* nodeName, Point3F* pos); In shapeBase.cpp //yorks for node transforms void ShapeBase::getNodeTransform(const char* nodeName, MatrixF* mat) { S32 node = getShape()->findNode(nodeName); MatrixF pmat; pmat.identity(); F32 *dp = pmat; if (node != -1) { F32* sp; sp = mShapeInstance->mNodeTransforms[node]; const Point3F& scale = getScale(); dp[3] = sp[3] * scale.x; dp[7] = sp[7] * scale.y; dp[11] = sp[11] * scale.z; } mat->mul(getTransform(), pmat); } 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); } //yorks end And then down at the bottom expose it to glorious Torquescript. 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; } Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted September 25, 2018 Author Share Posted September 25, 2018 Just to point out that %obj.getBoneVector(%bone); returns the current transform/vector of that bone/node alone and not inherited vectors from other bones. So if the bone is not moved during an animation it will return "0 1 0" and will not return the change from it's original position in the restPose. Quote Link to comment Share on other sites More sharing options...
Jason Campbell Posted September 28, 2018 Share Posted September 28, 2018 That is cool. This come up in a project your working on? If so, what required its use? Also, is there anything stopping this from working with a vehicle? Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted October 9, 2018 Author Share Posted October 9, 2018 I had it for "reasons" ... can't actually remember why. Nothing stopping it from working with any object type/class. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.