Game Development Community

Local coordinate system?

by Hoshiko · in Torque Game Engine · 01/28/2006 (12:42 pm) · 1 replies

I need to have an object move relative to some local set of coordinates. The local origin might be translated as well as rotated from the world origin, and the object needs to move in all ways relative to this new origin (including rigid-body forces, etc.). In addition, the local origin may move and rotate over time.

For example, say the local origin is at (100,100,100) in world coordinates, and is rotated Pi/2 radians in the xy-plane from the world origin. Then if my object has local coordinates of (10,20,30) and is pointing along the (local) y-axis, in world coordinates it would be at (110,120,130) and be pointing along the x-axis. If the local origin then moves to (200,200,200), the local coordinates would still be (10,20,30), but the world coordinates would become (210,220,230).

I first thought to modify getPosition and setPosition in SceneObject to accomplish this, but this proved far too simplistic. Is there any way to do this without having to totally rewrite the object transformation code?

Mike

#1
01/29/2006 (6:24 am)
This resource might help you. It implements exactly what you want, but I haven't tested it myself.