Jump to content
• Advertisement

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

This topic is 4539 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

##### Share on other sites
Advertisement
What's wrong with NeHe Tutorial #10 camera?
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10

#### Share this 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

##### Share on other sites
Quote:
 Original post by DeliveranceHow 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

##### Share on other sites
Thanks for the replies guy, guess I'll just use quaternions then.

#### Share this post

##### Share on other sites
Quote:
 Original post by DeliveranceThanks 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

##### Share on other sites
Quote:
 Original post by Deliverancewithout 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

##### Share on other sites
Quote:
Original post by Promit
Quote:
 Original post by Deliverancewithout 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

##### 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

##### 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 12
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011514
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!