View Full Version : Orbiting Camera
Hi, I'm making a ferris wheel in openGL and i need to be able to select one a viewpoint from within each of the 8 carriages that it has.
I currently have the wheel and carriages drawn, and other viewpoints made, but i dont know how to use glRotate to make my camera rotate around a point, and have it continue to look horizontal, ie. i dont want the camera to look at the centre of rotation.
05-12-2004, 04:53 AM
How about to control camera by using gluLookAt ?
It will be more easier than using glRotate.
Yeah, i could use glLookAt, but how would i keep track of the coordinates for my camera, and the coordinates to look at if im orbiting around a point?
Is there an algorithm to work out the dynamic translations needed to simulate a rotation and therefore let me update the coordinates of a point on the wheel dynamically as it rotates?
I've managed to get it so that my camera is orbiting and staying level, but it is orbiting around the world origin (at ground level) not around the cenre of the wheel (0.0, 30.0, 0.0)
the wheel is of radius 20 and here is the code im using at the moment
glRotatef(-wheel_angle, 1.0, 0.0, .0);
glTranslatef(0.0, -30.0, 0.0);
gluLookAt(0.0, 20.0, 0.0,
-1.0, 20.0, 0.0,
0.0, 1.0, 0.0);
glRotatef(-wheel_angle, 0.0, 0.0, 1.0);
<edit> thats 0.0, not .0 in the first Rotate
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.