Translate XNA code to Torque3D
by Robert Pinter · in Torque 3D Professional · 10/01/2012 (7:08 pm) · 5 replies
Hi,
Can somebody translat it from XNA to Torque3D please?
I did already, but I think I do something wrong.
XNA Code
My translation
Thanks
Can somebody translat it from XNA to Torque3D please?
I did already, but I think I do something wrong.
XNA Code
Vector3 s;
Quaternion r;
Vector3 t;
if (!worldTransform.Decompose(out s, out r, out t))
return;
var currentPos = positionResolver(currentJointID);
var nextPos = positionResolver(nextJointID);
var shoulderToElbowDir = Vector3.Normalize(nextPos - currentPos);
var angle = (float)Math.Acos(Vector3.Dot(Vector3.Right, shoulderToElbowDir));
var axis = Vector3.Normalize(Vector3.Cross(Vector3.Right, shoulderToElbowDir));
worldTransform = Matrix.CreateScale(s) * Matrix.CreateFromAxisAngle(axis, angle) * Matrix.CreateTranslation(t);My translation
MatrixF mScale(true);
mScale.scale(WorldTransform->getScale());
MatrixF mPosition(true);
mPosition.setPosition(WorldTransform->getPosition());
//Calculate Joint Direction
Point3F shoulderToElbowDir = mNormalize(NextPos - CurrentPos);
Point3F RightVec = MatrixF(true).getRightVector();
//Calculate Angle
F32 angle = acos(mDot(RightVec, shoulderToElbowDir));
//Calculate Axis
Point3F axis = mNormalize(mCross(RightVec, shoulderToElbowDir));
//Create AngAxis rotation
AngAxisF aa(axis,angle);
MatrixF RotMat;
aa.setMatrix(&RotMat);
WorldTransform = &(mScale * RotMat * mPosition);Thanks
About the author
Some of my old programming stuff. [URL] http://www.youtube.com/user/satanka102/videos [/URL]
#2
10/23/2012 (8:35 pm)
nobody :((, Any suggestion?? It seems the forum extinct. :)
#3
03/06/2013 (10:08 pm)
Hello????? Anybody???
#4
just a thought... not an statement.
Best regards
Kaj
03/06/2013 (10:15 pm)
Not extinct but maybe xna knowledge no so common? just a thought... not an statement.
Best regards
Kaj
#5
Yes I know it is not ordinary, but I though the logic is similar so I just need to understand the equivalent of the angle and axis math.
Thanks
03/06/2013 (10:22 pm)
Thanks Kaj,Yes I know it is not ordinary, but I though the logic is similar so I just need to understand the equivalent of the angle and axis math.
Thanks
Robert Pinter
Default Studio Name