Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Viewing Camera Problem

Started by Yperloxas 4 replies 850+ views
Original Post
Yperloxas
Yperloxas
Hi,i want to program a moving/rotating camera for 3d viewing of scenery. The problem is that i want to use x,y coordinates for surface axis and z for height.Opengl uses by default x for strafe axis z for forward axis and y for height.I want to use x for forward y for strafe and z for height. Is there any clever idea to do that? I won't use gluLookAt but only transform and rotation. By now i calculate the speed vector per axis ( ux forward uy strafe), and i multiply with delta time to calculate the delta s (movement) vector. This vector i add it to the camera position. The correct transformation to find where vector points is to rotate the s vector around y axis with the classical graphics transformations ?
Bucket_Head
Bucket_Head
No, don't do what Anonymous says, heh.

Here's the deal. You start with x increasing to the right, y increasing upwards, and z increasing out of the screen, towards you -- right? Normally, you might come to interpret this as saying that x is right, y is up, and z is forward/backward -- and increasing backwards, which seems strange.

This is not the only way to interpret x, y, and z. Take a step back and remember -- they're just axes. The directions they refer to can be whatever you want them to be. All you have to do is just say that x increases eastward, y increases northward, and z increases upward (which I think is what you want) and bam! You start by looking down on the scene from above, instead of starting by looking forward. In this you achieved your goals, just be redefining what x, y, and z mean for you.

From there, all you need to is render all of your geometry with this reference frame in mind. You'll probably want to lift your camera upwards (in the +z direction) to get a better view of your scene, and you may decide to rotate (pitch backwards by rotating about x) to look forward instead of downward, but that's your business.

I hope this helps. Good luck!
Hai, watashi no chichi no kuruma ga oishikatta desu!...or, in other words, "Yes, my dad's car was delicious!"
Yperloxas
Yperloxas
I want to work with the (x,y,z) coordinate system regarding the camera physics,movement but i want to render with the (z,x,y) opengl coordinate for rendering.

It is like going from having points defined in one coordinate system and calculating the points coords in another coordinate system.I have to transform
the one coordinate system to the other by transforimg the axis.

I know it must the rotations with glRotate that achieve that effect but i don't
which exactly are them.It is like rotating all axis like PI/2.

I want to use the angle around z ( y in the default opengl) as the turn(left-right) of the camera and the angle around y ( x in the opengl default) as the look (up-down).

If anyone has programmed a quake bsp viewer it will probably be aware of this problem because quake uses the target coordinate system for my camera.

Yperloxas
Yperloxas
With some trial and error i found that if i translate and rotate the camera according to the gl coordinate system (z,x,y) and i use the transform glRotatef(-90,1.0,0.0,0.0) the scene looks normal even if it defined in the (x,y,z) cartesian coordinate system.With this transformation as you might guess
i convert the -z to be y.I raise(rotating)the z axis to stand in the position
of the y gl axis.The x axis isn't affected by the rotation.So i still have to change pos between the y(forward) axis and x(strafe) axis.So i need to rotate around the y( now z after the transform )opengl axis.

So a glRotatef(90,0.0,0.0,1.0) might solve the problem.

If anyone has an opposition to my thinking please post your opinion.

I know it's somewhat complicated but that's the fun of graphics :).



Topic Locked

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

Sign in to reply to this topic.