View Full Version : Smooth camera path, Bézier curve?

05-03-2010, 07:03 AM
I have a program that displays a terrain from a heightmap and some objects from OBJ files on that terrain; I have also written routines to move the camera on all axes as well as a mouse "freelook" function for the camera.

I'd like to move the camera on a smooth, curved path like a Bézier curve; I was wondering if someone could point me to a tutorial with a code example for moving the camera in that way.
I did find and try out something using glMap1f() and then using the evaluator glEvalCoord1f() on that -- which can indeed be used to draw a nice curve with GL_LINE_STRIP.

However, I don't want to actually draw the curve on the screen; I want to have a function which can give me the x, y and z coordinates for the camera as a function of time (or something else) which I can use to move the camera along.

Thanks in advance!

05-03-2010, 09:45 AM
Google Bezier curve...

On wikipedia you can jump down to the cubic function, which is pretty standard and use that. Those four points are in 1D so you'll need to evaluate that equation for x,y, and z separately.