www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: paulscode on December 10, 2008, 03:33:42 AM

Title: Converting world-space coordinates
Post by: paulscode on December 10, 2008, 03:33:42 AM
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)?
Title: Re: Converting world-space coordinates
Post by: paulscode on December 10, 2008, 03:59:01 AM
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;
}