Sign in to follow this  

QuakeIII camera style (this should be interesting, why not just click it? )

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings people of earth who don't have anything else to do in this life, but GAMES! :) (can't figure out how to post those darn emoticons that smile definatly just up above, but let's stick to the initial subject) I implemented a simple camera and by looking through various tutorials on the internet I did not find only one that shows/explains how to implement a camera that acts exacly as, say, the camera in QuakeIII. That is: if you have the game or any other FPS game enter the game and move the mouse to look up, perpendicular to the ground plane then spin the mouse... that's raher cool isn't it? :) Now do this: take a tutorial from www.GameTutorials.com , www.UltimateGameProgramming.com or http://nehe.gamedev.net/ and do the same thing: try to look perpendicular to the ground plane: SHOCK! the view is limited, otherwise the camera code would create degenerate 3 axis systems(that is 3D orthogonal systems) Anyway these tutorials don't even bother to maintain an orthogonal system when calculating the view,position rotation of the camera. To put it shortly: How do I create a camera that acts exactly as in a proffesional FPS (like QuakeIII for example) without any quaternion or other matrix operations just using trigonometry and the function: RotateByAxis present in the tutorials from the sites above. I would be mainly interested in the logic involved.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What's wrong with NeHe Tutorial #10 camera?
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10

Share this post


Link to post
Share on other sites
If all you want is to be able to look "up", you could just impose a like a 1 degree restriction from straight up which would be almost unnoticable. As a general solution, I'm not reall sure, but could just rotate your Up vector around the up-down rotation axis when you rotate your view vector?

tj963

Share this post


Link to post
Share on other sites
Quote:
Original post by Deliverance
How do I create a camera that acts exactly as in a proffesional FPS (like QuakeIII for example) without any quaternion or other matrix operations just using trigonometry and the function


er... you don't? "Professional" camera systems use either quaterions or a matrix to represent the rotation of the camera. In fact, I've never seen a "professional" system for orientation (of cameras or objects of anything else) that doesn't use either quats or matrices. Learn how to use them, they're a fundimental tool for game programming.

Most "professional" FPS cameras do, in fact limit the look. They just cap your looking up and looking down to 1 degree less than directly up or directly down. If you want a full 6-degrees of freedom camera (like for a flight-sim), you'll want a nice quaternion driven camera so you don't have the hassle of gimbal lock. You can certainly do it with euler angles, but then you have to deal with the gimbal (not a hard problem really as the solution is know and easily available).

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Deliverance
Thanks for the replies guy, guess I'll just use quaternions then.


good stuff. expect a fair amount of frustration for 3-5 days. they can be pretty confusing the first time through. you'll be happy to have a quaternion class though, comes in handy for tons of stuff.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Deliverance
without any quaternion or other matrix operations just using trigonometry and the function: RotateByAxis present in the tutorials from the sites above.
That's a recipe for disaster.

The simple way to do this is to maintain your three orientation vectors -- right, up, and look -- and transform each of them by a rotation matrix. They'll always be rotated around the current local Right vector for the case of looking up or down, and always around the current world Up vector (this is always <0, 1, 0>) for looking side to side.

When you've done all the relevant transformations, simply orthonormalize the entire system (it will creep otherwise) and construct the appropriate matrix from the vectors (absolutely trivial).

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
Quote:
Original post by Deliverance
without any quaternion or other matrix operations just using trigonometry and the function: RotateByAxis present in the tutorials from the sites above.
That's a recipe for disaster.

The simple way to do this is to maintain your three orientation vectors -- right, up, and look -- and transform each of them by a rotation matrix. They'll always be rotated around the current local Right vector for the case of looking up or down, and always around the current world Up vector (this is always <0, 1, 0>) for looking side to side.

When you've done all the relevant transformations, simply orthonormalize the entire system (it will creep otherwise) and construct the appropriate matrix from the vectors (absolutely trivial).

Seconded. I use this system almost exclusively.

Share this post


Link to post
Share on other sites
Just wanted to add a couple of other thoughts:

- Although a quaternion class is useful to have, it's entirely unnecessary for this type of camera

- IMO an FPS camera is best implemented using 'from scratch' matrix construction rather than incremental rotations; with the former approach, no orthonormalization is required

- Although as has been mentioned a 1-degree pitch limit will hardly be noticable, it's also not at all necessary if your code is implemented correctly

Also, this thread might be of interest to you. If you look towards the bottom there's a post that goes into some detail as to how to construct the basis vectors for an FPS camera.

Share this post


Link to post
Share on other sites
Contrary to popular belief Euler angles are in fact fine for a FPS camera – you don't want 6 DOF and you do want 'I'm walking in this direction and looking up/down', which is exactly what Euler angles do. Just create a camera matrix from scratch every frame:

ResetMatrix();
Translate(Camera.Position);
Rotate(0, 0, Camera.Yaw);
Rotate(0, Camera.Pitch, 0);
Rotate(Camera.Roll, 0, 0);

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
u dont need quat's or matrixs for a quake3, in fact im 99% sure q3 doesnt
You're right about quaternions, but not so much about matrices.

For one thing, any app that communicates with an API such as OpenGL (and this includes Q3) will have to deal with matrices at some point, whether implicitly or explicitly. To this end, Q3 stores matrices in OpenGL float[16] form along with other relevant data.

This other data includes, among other things, a position and three basis vectors, which in essence is just another representation of the data in the matrix (and vice versa).

So although there may be other intermediate forms, there's really no getting away from matrices. To answer the OP's original question though, it is possible to set up such a camera using only functions such as glRotate*() and so on. You're still using matrices though, just indirectly.

Share this post


Link to post
Share on other sites
Q3 uses euler angles as in pitch-yaw-roll and convert it to a matrix to send to OpenGL. Older quakes didnt do that cause Q3 uses separate thread for GL and a messaging system between renderer and the backend and exports matrices via this.
I guess its just all about in which order you create the matrix? You always get gimbal lock at some point, but that's up to the order where it happens.

And also, the source code to quake3 is released, so just go and look it up there?

ch.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this