Skip to main content
GameDev.net gamedev.net
🔒 Locked

problems with view matrix transformations

Started by psycoding Jan 19, 2008 at 9:18 AM 0 replies 850+ views
Original Post
psycoding
psycoding
I'm writing a little radiosity renderer and want to adjust the camera's direction using a vector to align the cam with the triangle normals. as far as i know the right way would be using a view matrix (I always worked without matrices) -translate vertices -multiply them with the view matrix (only used as rotation matrix): it only works if i rotate the cam around the y-Axis. now i post some code where the error may lie : //crossproduct, perhaps with error, there are many different out there with only one beeing right, so i don't know if that's the right one vertex *cross(vertex *a, vertex *b) { vertex *c = new vertex(); c->x = a->y * b->z - a->z * b->y; c->y = a->z * b->x - a->x * b->z; c->z = a->x * b->y - a->y * b->x; return c; } //calculate right and up vector right=cross(look,yaxis); up=cross(right,look); //translation, vertex / view matrix multiplication v->x= v->x + object->x - cam->x; v->y= v->y + object->y - cam->y; v->z= v->z + object->z - cam->z; new->x= v->x*right->x + v->y*right->y + v->z*right->z; new->y= v->x*up->x + v->y*up->y + v->z*up->z; new->z= v->x*look->x + v->y*look->y + v->z*look->z; v=new; I don't have any clue why this doesn't work for the x-Axis rotation. please help me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.