Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

A simple camera model

Started by Lmc Oct 12, 2005 at 2:04 AM 3 replies 650+ views
Original Post
Lmc
Lmc
I need to implement a simple routine which, given a distance, pitch angle and yaw angle, will provide the inputs to an OpenGL GLrotatef command which will cause the object located at the origin to rotate the specified amount. I presume this would entail converting the input Euler data into a quaternion, doing the rotation and then converting the quaternion to the required vector/angle format. Does anyone have such a thing handy and working?
Zakwayda
Zakwayda
Quote:
I need to implement a simple routine which, given a distance, pitch angle and yaw angle, will provide the inputs to an OpenGL GLrotatef command which will cause the object located at the origin to rotate the specified amount. I presume this would entail converting the input Euler data into a quaternion, doing the rotation and then converting the quaternion to the required vector/angle format. Does anyone have such a thing handy and working?
One thing I can tell you is that quaternions needn't be involved unless you want them to be. In fact, you could probably do it directly through glRotatef(), without matrices or quaternions.

My question is, what is the distance variable for? Is that the distance from the camera to the object? If so, how does that affect the rotation of the object?
Lmc
Lmc
Yes, that's exactly what it's for. The effect I'm looking for is exactly like the Study mode button in most VRML browser plugins, where the camera is always pointed toward the center, but can move to any position in the space around the center. (In my question I couched the question in terms of rotation of the object, but what I'm really looking for is this "helicopter" effect.)
Silex
Silex
Quaternions can be handy for interpolating rotations, but I wouldn't use them for the effect you're trying to accomplish.

I would instead look into the function gluLookAt. It takes 9 doubles: the first 3 are the position of the camera or eye, the next 3 are where the camera is looking at, and the final 3 are the up vector.
Lmc
Lmc
OK, that did the trick for me. Thanks for the help. This is what you get when you have to learn a new API in two days.

Thanks again.

Topic Locked

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

Sign in to reply to this topic.