c - OpenGL - 3D Rotation around Local Axes -
background: have been working on problem of 3d object rotation around local axes, using opengl. after having extensively searched on different forums mathematical model updating axes x/y/z rotations happen, found helpful resource.
http://nehe.gamedev.net/article/camera_class_tutorial/18010/
the problem: stumbling upon rather trivial issue. example resource mentioned above 45 degree rotation around y-axis; hence x- , z-axes need updated. new x-axis calculate (0.707, 0, 0.707), makes sense. z-axis (-0.707, 0, 0.707), intuitive. corresponding gl commands are:
glrotatef(x_rot, 0.707, 0, 0.707); glrotatef(y_rot, 0, 1, 0); glrotatef(z_rot, -0.707, 0, 0.707);
now rotating first around y-axis 45 degrees. after x-rotation looks good. around updated (local) axis, intended.
then, remove x-rotation; when apply z-rotation not right. not rotating along local z-axis. axis looks correct mathematically, not sure going wrong graphically.
edit:
the example around middle of page.
Comments
Post a Comment