Skip to main content
gamedev.net
🔒 Locked

Am I Doing it wrong?

Started by TheLabRat 2 replies 200+ views
Original Post
TheLabRat
TheLabRat
I am implementing a basic 3D engine using opengl. Originally I used the plain old glTranslate/glRotate commands to move objects and the camera around - but gimbal lock caught me out, so now I''m trying to use all my own matrix transformations to manipulate the position of the camera and objects and then only giving the draw commands to GL -is this stupid or the right way to go about things. Would it be easier to do polygon sorting with my own matrix calculations or should I leave it up to GL?
fifty1
fifty1
It''s fine to do all your own matrix transformations, but in most cases it won''t be as fast as the OpenGL implementation.

How are you doing your transformations? If you''re using angle-axis, you should just use glRotate() since that''s what it''s meant for. Since gimbal lock was your problem, you may be using quaternions now. In that case you''ll have to do your own conversions from quaternions to matrices and use glLoadMatrix().

Rather than transforming polygons yourself, I would highly recommend using glLoadMatrix() and letting OpenGL handle the transformations.

Polygon sorting is entirely different. If you want to avoid using a depth buffer for performance (in software) or memory reasons, you''ll have to depth-sort your polygons yourself. This is very difficult in all but the simplest cases. Even if you are using a depth buffer, you may want to sort your polygons for culling reasons.

I don''t know how much experience you have, but unless you''re an expert I think it''s best to use the default OpenGL way of doing things.

Hope this helps.
TheLabRat
TheLabRat
Thanks for replying - and the advice.
No I''m not so experienced - I hate matrix math and am still not sure about the whole gimbal lock/ axis and angle problem.
know any good tutorials about implementing the axis and angle system directly with opengl?
fifty1
fifty1
I can''t help much with pointers to tutorials since I tend to learn better from reference books. A lot of other people around here seem to know where the tutorials are. Any help guys?

You can use axis/angle directly with calls to glRotatef(angle, axis[0], axis[1], axis[2]), where angle is in degrees. Unfortunately, this doesn''t solve the problem of finding the appropriate angle or axis. In most cases, you can use Euler angles (3 consecutive rotations around different axes), but gimbal lock will sometimes stop you.

Topic Locked

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

Sign in to reply to this topic.