PDA

View Full Version : OGL camera hell



Junkstyle
07-22-2002, 02:30 PM
This is the most frustrating thing I've encountered with OpenGL. Camera control in OGL is totally unintuitive. "Camera is always at 0,0,0 looking down negative Z-axis" Who thought up that?

If anyone has a short demo with source about moving/rotating the "camera" around could you link me? I'm getting really disenchanted with OGL's camera system. I've looked at dozens of code samples and most people wimp out and use gluLookAt().

Everytime I try to rotate the camera around I get just the world rotating at the distinct axis X, Y, or Z.

What I would LOVE to be able to do is take a quaternion as my orientation and set the camera too it. I've tried taking a quaternion and inverting it, but that didn't get the right rotations.

If I can't get that I would love to be able to specify an Right, Up, Forward set of vectors that represent the camera.

This is unbelievably frustrating. I can make all my models rotate PERFECTLY, dance, and sing--via quaternion rotations, but when it comes to moving the camera around its like trying to orient a drunken sumo.

I'd really love any help, thanks!

Miguel_dup1
07-22-2002, 06:06 PM
Drunken Sumo... LMAO @ JunkStyle...

What is so wrong with gluLookAt();
I use it and it works well so far...
I rotate it and move forward and backwards, I could add a line of code to strafe, but I am not interested in doing it right now...

I just uploaded an example on frustum culling that implements a camera with 6 degrees of freedom with quaternions...
It is the third link on the right side... http://141.217.220.20/miguel/

I hope it helps... http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by mancha (edited 07-25-2002).]

Junkstyle
07-22-2002, 07:32 PM
Thanks Manchu, I saw your terrain demo...pretty smooth, about 200+ fps here.

That other demo got me going for my problem. I was actually doing the right thing but lack of confidence and stupid errors were screwing with my head....2 days down the drain.

He had:
GLvoid CAMERA::Apply()
{
Matrix.QuatToMatrix(Orientation);
Matrix.MatrixInverse();
glLoadMatrixf(Matrix.Element);
glTranslatef(-Position.x,-Position.y,-Position.z);
}

I do pretty much the same thing but slightly different:

1) invert my quaternion (easy since its a unit quaternion)

2) make rotation matrix with inverted quaternion and multiply it in with the stack

3) do translation -x, -y, -z


She's dancing like a ballerina now.

Miguel_dup1
07-22-2002, 07:36 PM
Glad I helped...

Thanx for the comment on the terrain...

I am working right now on a sky dome to add it to the terrain; it looks really nice... I will be making some tutorials too for the complete terrain set when I get it all done... I am pretty excited about it...

I would like to take a look at your stuff sometime if you dont mind... I like seeing what other people do... http://www.opengl.org/discussion_boards/ubb/smile.gif

Junkstyle
07-22-2002, 09:21 PM
yeah you, ioquan, and a bunch of others are going to get beta versions of my game + source as soon as I make it into a game. Right now its a foggy white coordinate system and a 4 triangle shaped spaceship. I'm working on the camera tracking system, which is going to be pretty weird---I hope. These last 2 weeks have been pretty intense: introduction to quaternions and OGL camera tracking. But the pain and suffering are well worth it. You don't know how great it felt when I implimented simple thruster physics to my space ship and flew it around for the first time.

nomad
07-22-2002, 10:06 PM
Originally posted by Junkstyle:
This is the most frustrating thing I've encountered with OpenGL. Camera control in OGL is totally unintuitive. "Camera is always at 0,0,0 looking down negative Z-axis" Who thought up that?

If anyone has a short demo with source about moving/rotating the "camera" around could you link me? I'm getting really disenchanted with OGL's camera system. I've looked at dozens of code samples and most people wimp out and use gluLookAt().

Everytime I try to rotate the camera around I get just the world rotating at the distinct axis X, Y, or Z.

What I would LOVE to be able to do is take a quaternion as my orientation and set the camera too it. I've tried taking a quaternion and inverting it, but that didn't get the right rotations.

If I can't get that I would love to be able to specify an Right, Up, Forward set of vectors that represent the camera.

This is unbelievably frustrating. I can make all my models rotate PERFECTLY, dance, and sing--via quaternion rotations, but when it comes to moving the camera around its like trying to orient a drunken sumo.

I'd really love any help, thanks!


camera control in OGL is intuitive. learn matrix math well http://www.opengl.org/discussion_boards/ubb/wink.gif.

it's not so hard. there're camera tutorials at gametutorials.com, look into the one with a mouse on it, work on it, and you have a camera system that could move to whatever direction you want your world to be.

Jambolo
07-22-2002, 10:23 PM
Originally posted by Junkstyle:
This is the most frustrating thing I've encountered with OpenGL. Camera control in OGL is totally unintuitive. "Camera is always at 0,0,0 looking down negative Z-axis" Who thought up that?


One of the keys to OpenGL enlightenment is undertanding that OpenGL does not have a "camera system".

If you want a camera system in OpenGL, you have to create it yourself (or use someone else's).

Junkstyle
07-23-2002, 07:45 PM
There is no spoon.
(but the little boy in the Matrix didn't have to invert a quaternion to make it bend)


Nomad, the gametutorials.com samples all use gluLookAt().


[This message has been edited by Junkstyle (edited 07-23-2002).]

rixed
07-25-2002, 07:35 AM
OGL camera style IS intuitive.
Think of the Camera as your screen. The modelview matrixes leed from it to the objects.

In your object hierarchy, lets say you have a matrix that is your camera. Absolute this matrix if its relative to another repere(s), then put the transposed matrix of this camera at the bottom of the modelview stacks (in the bottom = the first matrix that you push)

Whats so terrific about it ?
Oh, and lets stop afraid each other with such alien things as quaternions :-)

07-31-2002, 08:41 PM
Just use glrotated(angle,x,y,z) to rotate the camera and gltranslated(x,y,z) to move the camera

kevinhoque
08-01-2002, 01:14 AM
I am with those who say that camera control is intuitive in opengl. :-) All you have to get over is that there is no camera! Just have to get the effect by altering the modelview matrix. Btw, D3D has a separate camera matrix which is nice. You don't have to use it though. You can still mimic a camera al la opengl.

Kevin

Junkstyle
08-01-2002, 08:07 PM
Why don't you guys all pat yourselves on the back already okay?