Public Group

# UVN camera system - basic help required please

This topic is 4978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am having major problems with a UVN camera system and I'm about to throw my computer and myself out the window. Heres what I'm doing. * create a cube 2x2x2 in OBJECT coords centered around origin * create camera UVN vector initially 1 up, 1 right 1 forward N=Vert_Sub(cam->position,cam->target); N=Normalise_Vector(N); U.x = sin(cam->roll_angle*(M_PI/180)); U.y = cos(cam->roll_angle*(M_PI/180)); U.z = 0; V=Cross_Product(U,N); V=Normalise_Vector(V); U=Cross_Product(N,V); U=Normalise_Vector(U); * apply transposed camera vector to cube OBJECT vertices like so poly.world_vertices.x=poly.vertices.x*U.x + poly.vertices.y*U.y + poly.vertices.z*U.z; poly.world_vertices.y=poly.vertices.x*V.x + poly.vertices.y*V.y + poly.vertices.z*V.z; poly.world_vertices.z=poly.vertices.x*N.x + poly.vertices.y*N.y + poly.vertices.z*N.z; * translate cube WORLD vertices by negative camera position * scale the cube WORLD VERTICES by 20 * project the cube like so (distance is screen width) poly.screen_vertices.x=(SCREEN_WIDTH/2)+(distance*poly.world_vertices.x)/(distance-poly.world_vertices.z); poly.screen_vertices.y=(SCREEN_HEIGHT/2)-(distance*poly.world_vertices.y)/(distance-poly.world_vertices.z); I then run a loop where i move the camera position in y direction by 0.5 each time, always looking at 0,0,0. Problem is the cube should be 20 in height but by the time the camera has got to 1 im looking at the cube rotated by over 45 degrees ??? The cube also moves down the screen but i should always be looking at the center of it ?? Also im checking if a surface should be drawn by checking if its normal vectors z element is positive and this also stops working properly (although as far i can figure it should still work). Im obviously missing something about how all this fits together. Any help would be greatly apprecited. If anyone could explain the basics of the system or tell me what im doing wrong I'd be eternally grateful. Even point me in the direction a book with a good clear explanation. I've lost count of how many tutorials I've read but they never clearly explain how everything fits together. I can send all the code I have if anyone can be bothered to look at it :) Thanks in advance,

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5

• 23
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631733
• Total Posts
3001928
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!