Game Development Community

Object to world coordinates - need a dummy guide

by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 03/28/2004 (11:25 am) · 2 replies

My last attempt at understanding matrix math was at university 13-14 years ago, and I am now faced with a challenge of re-learning lost knowledge as well as understanding Torque.

I hope some fantastic helpiful person out there can take pity on me and guide me through this problem. Once done it will stick and I can work from there on my own.

What I need is a small dumb example of how to convert from object space to world coordinates using Torque.

Problem:
My player sits in 0,0,0 and is facing in direction 0,1,0 in object space
I want to place a camera object in 0,-2,2 (behind and up) from the player, facing in the same direction

The rotation/direction part is trivial. In object space its also trivial to get the coordinates for the camera.

But how do I practically use Torque to convert my 0,-2,2 position into world space?

If I remember correctly from old times @ uni, I need some transformation matrix that I multiply (how? is there an easy method for this?) with my position and it spits out my world coordinates. Right?

Please help, and I'll send you virtual beers!!

#1
03/28/2004 (11:48 am)
Use the mObjToWorld transform or mWorldToObj transform depending on which direction you want to go. SceneObject automatically keeps them up to date. The MatrixF type has multipliers to deal with transforming points and other things.
#2
03/28/2004 (12:47 pm)
Thanks Ben - also for the Yahoo help.

For others in the same situation here is how you do it:
Each object has their own coordinate system. In my example I got the 0,-2,2 point that I want to translate into world space for the player object.

So I do (non-compiling/complete code)
Point3f cameraPosObject(0,-2,2);
Point3F cameraPosWorld;
MatrixF objToWorld = playerObj->getRenderTransform();
objToWorld.mulP(cameraPosObject, &cameraPosWorld);