Rotate Viewpoint

Started by
8 comments, last by Big Cheez 20 years, 2 months ago
How do you rotate the viewpoint in opengl?
"That MSMAGNET program trashed my hard drive!"
Advertisement
You can use glRotate.
I mean like the viewpoint. What the monitor "sees" through.
EXAMPLE. In an FPS, by moving the mouse you rotate the viewpoint.
"That MSMAGNET program trashed my hard drive!"
As I said, glRotate. Get the mouse movements, and feed the movements as angles to glRotate.

For example, if you want to look up/down by moving the mouse up/down, get the mouse movements in the Y-direction, scale it as you like (to "convert" from distance to degrees, choose whatever factor you like; higher factor, higher sensitivity), and rotate that amount about the X-axis. Simple, but works.
That just spins all the objects.
"That MSMAGNET program trashed my hard drive!"
Before I go into depth, I''d want to know: Do you want the simplest hack possible, or do you want a movable camera?



"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler

Globals are not evil. Singletons are evil.
Actually, instead of answering the question I'm just going to point you to some OpenGL tutorials that would be many times more helpful than any one post I would make:
http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg1.htm

Edit: Yes, yes, it's not NeHe, I know. But gluLookAt isn't terrible, as best as I can tell, and it does the job.



"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler


[edited by - Indigo Darkwolf on January 27, 2004 5:20:27 PM]

Globals are not evil. Singletons are evil.
At the beginning of your drawing routine (after positioning the camera) i use glRotatef(xrot,1,0,0) and glRotatef(zrot,0,0,1) which lets the user/player look down (x) and look around the vertical axis (z). This works perfect.
Can''t make heads or tails out of GameTutorials... Mabye im just not getting it. And ill try GLRotate again.
"That MSMAGNET program trashed my hard drive!"
GLRotate works... kinda. See, sometimes your turning to face the square and your turn "rebounds". If you want the code i''d be happy to send it to you. And you have to press the down arrow key to see the square.

Oh, and another thing... You kinda "slide" on a line perpendicular to the square no matter which direction your facing.
"That MSMAGNET program trashed my hard drive!"

This topic is closed to new replies.

Advertisement