Skip to main content
GameDev.net gamedev.net
🔒 Locked

avoiding a invalid 3d-camera

Started by rtime Sep 3, 2000 at 9:52 PM 5 replies 200+ views
Original Post
rtime
rtime
hi ppl... in case this was just asked a while ago: i cant search the forum, (timeout error) here''s the story i have an old 3d-engine, which i wanted to convert to direct-3d and open-gl... i felt quite comfortable with it UNTIL NOW reviewing the camera-code i found an ugly workaround for the problem... i use 2 vertices (and 3 floats) for the camera 1 vertex is the position 1 vertex is the look-at the floats are the rotation angles with both vertices i calculate the up, right and front vector for the camera-matrix.. i think i calculate the camera in the standart fashion, but to be sure, there''s the "code" (front=look-at-position normalized) (up=calculated with sin/cos from roll-angle) (right=cross product of front&up normalized) (up=recalculated cross product of front&right normalized) this works really fine, but if the front-vector is the world-y-axis, it produces 0/0/0 for the up-vector (or right-vector, i can choose ;-)) my workaround was an if-then for every camera-change but i think this sucks a lot ! is there any cool workaround for it ? and another question how can i calculate a matrix from lens-info (for example F=24mm) of a real camera ? so long torsten camera,
a2k
a2k
sounds like you''re experiencing the joys of gimbal lock. look into using quaternions for your camera.

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Zipster
Zipster
Er, uh, I''ve been hearing the phrase "gimbal lock" a lot. I''m new to all this 3D stuff, so uh, what is Gimbal Lock? Sounds like a symtom of arthritis...

=======================================
A man with no head is still a man.
A head with no man is plain freaky.
paulcoz
paulcoz
"Gimbal lock" is something that occurs when you are compounding rotations around the three axis (x, y, z) to represent an orientation.

It basically means that the order in which you apply the rotations eg. first around the x axis, then y axis, then the z axis is different to applying them to the z axis first, then the y axis, then the x axis.

Your rotations start going in different directions than you expect and you potentially lose a degree of freedom.

Paulcoz.

Edited by - paulcoz on September 4, 2000 5:01:00 AM
Yoshi
Yoshi
To understand quaternions and gimbal lock have a look at gamasutra. They have an article about his topics.

Yoshi
The last truth is that there is no magic(Feist)
rtime
rtime
a2k:
gimbal lock ?

i just want to calculate 3 vertices out of 2
if i do not rotate (all angles 0) then the 0/0/0 for the
upvector appears, too....

for calc of the 3 vertices i only use the
z-rotating angle.... (so i could throw the other 2 angles
away)

so a gimbal lock couldn't occur... (or am i totally wrong ?)


Edited by - rtime on September 4, 2000 1:37:19 PM
Zipster
Zipster
So Gimbal Lock is what its called! I always just knew it as the "wrong order of multiplying the matrices". But now I know the COOL term.

=======================================
A man with no head is still a man.
A head with no man is plain freaky.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.