# UVN Camera System - basic help required please

This topic is 5040 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); V.x = sin(cam->roll_angle*(M_PI/180)); V.y = cos(cam->roll_angle*(M_PI/180)); V.z = 0; U=Cross_Product(V,N); U=Normalise_Vector(U); V=Cross_Product(N,U); V=Normalise_Vector(V); * 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, [Edited by - elephantman on November 30, 2004 1:14:05 PM]

##### Share on other sites
I had some problems w/ the same viewing system a while back, and worked through them...

Would you mind posting your code?

The best tutorial I found was here

Thanks!

[Edited by - jakem3s90 on November 30, 2004 12:20:13 PM]

##### Share on other sites
Hi,

Thanks for the reply. Although I couldn't find much about the actual UVN camera system there.

My problem is that I don't really understand how the system works as my background is not really in maths.

Maybe you can help me with some really basic questions about the system:

1) Do you rotate by transposed UVN matrix, then simply translate negatively by camera position ?

2) I'm not using matrices - I'm doing the rotate and translate sa two seperate steps (as you can see in the code above) - does this matter ??

I don't understand how this achieves the desired results (and in my code it doesn't).

I'll tidy up my code and post it.

##### Share on other sites
It probably doesn't help much, but
    V.x = -sin(cam->roll_angle*(M_PI/180))
It appears that you are doing the right steps in the wrong order. You must scale the cube (transforming it to world space) before translating and rotating it (transforming it to view space). Then, you must translate it (by the negative camera position) before rotating it (by the inverse of the camera orientation).

##### Share on other sites
check out gametutorials.com, there is a very good camera tutorial...

1. 1
2. 2
Rutin
23
3. 3
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007171

×