PDA

View Full Version : Viewing Matrix



doofus
04-04-2004, 08:23 AM
I'm having a bit of a problem with creating a viewing matrix and i reckon I've done it so terribly wrong. I create my U V and N as follows:



N->x=(position->x-direction->x);
N->y=(position->x-direction->y);
N->z=(position->z-direction->z);

U=CrossProd_Vector3(upVector, N);
V=CrossProd_Vector3(N, U);

CU=DotProd_Vector3(position, U);
CV=DotProd_Vector3(position, V);
CN=DotProd_Vector3(position, N);
all my functions for the dot products and cross products are working. If i set the position to (0, 0, 0) it does actually work but anything else it all just disapears. upvector is (0, 1, 0) and direction is (0, 0, -1).

If anyone could help i would be most grateful.

Cheers,

capn_midnight
04-04-2004, 09:49 AM
to begin, N should be direction - position, not the other way around. Remember, always final minus initial.