Moving camera

9275cef0ad2f15ec1813d63b0c5b0fad
0
rogerdv 101 Aug 21, 2003 at 15:23

I want to move the camera following a circle around a point. Im using gluLookAt, so I know that I only have to change the first vector (the position of the camera) and leave the target unmodified. Can somebody suggest me an idea?

8 Replies

Please log in or register to post a reply.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Aug 21, 2003 at 20:08

using sine and cosine (wich take radians.. not degrees :D) to calculate your position..

and yes, leave your target unchanged, of course.. :D

9275cef0ad2f15ec1813d63b0c5b0fad
0
rogerdv 101 Aug 21, 2003 at 20:21

But how do I convert that to opengl coordinates (x,y,z)? Sorry, Im bad with maths.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Aug 21, 2003 at 20:47

hm..

xdistfrommidpoint = radius * sinf(rotation);
ydistfrommidpoint = 0;
zdistfrommidpoint = radius * cosf(rotation);

cameraxpos = xdistfrommidpoint + midpointx;
cameraypos = ydistfrommidpoint + midpointy;
camerazpos = zdistfrommidpoint + midpointz;

and voilà, you have your camerapos, and your target (midpoint)..

hope that inspires you..

oh, and math is the most important thing in graphics, quick! catch up! vector math all the way! its not much actually..

9275cef0ad2f15ec1813d63b0c5b0fad
0
rogerdv 101 Aug 21, 2003 at 21:44

Thanks a lot! Ill try that tomorrow. Maybe some kicks in the head in the training session now clear my mind.

F33eec98e0fc761467c315aad881c035
0
Jesse_M 101 Aug 22, 2003 at 02:03

Our graphic-programmer forebears would laugh. The advent of the device-independant graphics API has stolen away our knowledge of simple 3D math. :lol:

I remember the day I was squeezing every processor tick out of my 3D routines. All for not I guess…

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Aug 22, 2003 at 05:37

jesse, i like your sign

and yeah.. todays apis allow you to “forget about 3d”.. but just to render some cubes or so.. at the first point after THAT, you’ll learn that you need to understand math anyways..

and once you do, the world is so much simpler…

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Aug 22, 2003 at 12:50

luckily programable gpus reintroduce math to 3d programming…

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Aug 22, 2003 at 13:29

partially, yes:D