PDA

View Full Version : glulookat vs. explicit transformations



lavalamp
01-09-2003, 10:52 AM
I'm using gluPerspective in a 30-deg FOV with a huge depth in a space simulator.

If I move in space using gltranslatef, my scene renders "normally".
i.e. gltranslatef(Xtrans,Ytrans,Ztrans)

If I use glulookat, different points (stars) in space seem to disappear and reappear as I move, or maybe the rendering is so slow the display is just flickering.

I change the 1st three coordinates as I move, the 2nd set are the location I'm moving towards (fixed) and I leave 0,1,0 for the up vector.

example:
at time1 - glulookat(Xtrans1,Ytrans1,Ztrans1,Xdest,Ydest,Zdes t,0,1,0)
at time2 - glulookat(Xtrans2,Ytrans2,Ztrans2,Xdest,Ydest,Zdes t,0,1,0)

Should I be recalculating Xdest,Ydest,Zdest as I move?

shinpaughp
01-09-2003, 02:25 PM
I believe the first 6 arguments passed to gluLookAt represent points in global space and the last 3 arguments represent a vector. Therefore, you should recalculate Xdest,Ydest,Zdest otherwise if you pass through or beyond that point you are then looking behind you where you came from.

Hope this helps.

SThomas
01-09-2003, 03:16 PM
the middle 3 parameters represent the location in space that you're looking at. so if you leave them unchanged and just change the first three parameters (camera location), then it'll be like you have your view locked on a particular point as you move around it. what you probably want is to be changing the middle 3 parameters also. if your camera position moves 5 units to the left, also move the point that you're looking at (the middle parameters) 5 units to the left. that's probably what you want.

edit: fixed the wording.

[This message has been edited by SThomas (edited 01-09-2003).]

lavalamp
01-09-2003, 06:22 PM
thanks for the suggestions. I DO wish to be moving towards and looking at particular point in space, so it seems just changing the camera location coords is what I want. I'm not moving past the destination z-coord, and I slowly line up the x and y coords to match the destination as I move towards it on the z-coord. It's definitely not flicker - there are stars disappearing and reappearing as I move, so it must be my gl calls or something. Thanks again, I'll study my rendering routine again.