Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Camera rotations X,Y,Z or Roll/Pitch/Yaw?

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

Hi. At the moment I have defined my OpenGL camera rotations with a vertex "rot", so I have rot.x, rot.y and rot.z. In my renderscene I use: glRotatef(rot.x, 1, 0 ,0); glRotatef(rot.y, 0, 1, 0); glRotatef(rot.z, 0, 0, 1); In examples of other programmers I hear them talk about pitch, yaw and roll, offcourse there interesting words, but I think there the same as my rot.x, rot.y and rot.z. Can someone tell me if this is true? I also wonder what people mean with the terms "view" and "up", I think there vectors, is it true that these vectors define the "forward" and "up" direction of a 3d camera? Since I'm trying to optimize my 3d engine, I'd like to hear your opinion on using vector-style or rotationstyle camera (rot.x, rot.y and rot.z or view/up vectors). In my opinion working with 3 rotation floats works kinda easy. Thanks for your reactions and opinions.

Share this post

Link to post
Share on other sites
Pitch, yaw, roll and your rot.x etc. are probably the same. They are called 'Euler angles'. You can use these quite happily for FPS style control.

'up' and 'view' refer to ways to focus camera transforms on a particular point.

To setup a rotation in this way, you need three (orthogonal) vectors.

Say the camera is at point C and you want to look at a point A.

view = normalize(C - A)

up = [ 0, 1, 0 ]

Note 'up' is an arbitrary vector which points in the direction you consider upwards (here it is pointing up the y axis, I presume Y is the vertical direction).

You can now build the three vectors for this transform:

X = cross(up, view)
Y = cross(X, view)
Z = view

(cross is the cross-product obviously :)

You can translate Z as 'forward' and Y as 'up' if you like.

This has nothing whatsoever to do with optimization. Which style you use depends entirely on what capabilities you want to give your engine. IMO you should probably just accept general 4x4 matrices and let the user of the engine (i.e. game code) decide how it wants to represent its camera settings (that way you can use Euler angles for FPS control and the 'view, up' style for cinematic camera.

Share this post

Link to post
Share on other sites
That sounds really clear, thanks.
What I'm gonna do is add the view/up (vector-style) camera, to use in cinematic movement of the camera.

For now on I know I can use my pitch/yaw/roll rotation system, to expand my 3d engine with features.

Thanks again.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!