Advertisement

Camera problem

Started by January 09, 2003 03:05 PM
4 comments, last by ProfEich 22 years, 1 month ago
Hi! I''m programming a game and I began to program a camera class. But now my problems began! I''m a newbie in OpenGL so I don''t know possible functions: I''m looking for a camera which I can turn in every directory (like a free camera). If I rotate (180°) it upwards you can see the floor at the ceiling sometimes. If you rotate (180°) upwards again you can see the floor at the correct position. If I turn the camera to the right it turns 360° until its so as before. If you know Descent or Forsaken you know what I mean. (Sorry about my English, maybe someone else can explain it better ^^") Thx 4 every help =)
I think what your asking for is the function:

gluLookAt( fromX, fromY, fromZ,
toX, toY, toZ,
upX, upY, upZ );

which is defined in "glu.h"

This puts the camera at a position in 3d space designated by 'from', pointed towards the point 'to' and tilted in the direction of up. Usually you will have up as 0,1,0 in most first person shooters (because the character is stainding upright) owever in a game like descent you can twirl around so it would change.

[edited by - Mulligan on January 9, 2003 4:14:48 PM]
Advertisement
Well. This function has the problem that I have to calculate the target position.. (I can't calculate it =( )

[EDIT:] I can make it with glRotatef but even there I need to calculate for everything.

[edited by - ProfEich on January 9, 2003 4:28:35 PM]
Have a look at NeHe''s GameTut 7.
As I wrote the tut I realized the camera code with quaternions but you can also use matrixes. (more popular technique
keep a marix locally and rotate it by the delta rotation values each frame. Then load the transpose.

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |
GameTutorials.com has some very good tuts on camera setup, with answers for what I think you''re looking for.

This topic is closed to new replies.

Advertisement