Converting world-space coordinates

Started by paulscode, December 10, 2008, 03:33:42 AM

Previous topic - Next topic

paulscode

What would be a good way to convert a SimpleVector in world-space into one in camera-space (i.e. the look-direction +z axis, up-direction -y axis, etc)?

paulscode

Oh, never mind, I forgot that you can apply a rotation matrix to a SimpleVector (oops :-[)  Something like this should work:

public SimpleVector toCameraSpace( SimpleVector v, Camera c )
{
    SimpleVector dest = v.calcSub( c.getPosition() );
    dest.matMul( c.getBack() );
    return dest;
}