I'm trying to render a rotating cube on Opengl ES 2.0, using some math classes I wrote (based on a lot of online and offline info) for quaternions, matrixes and the like. As far as I know all the math classes are right, but I'm still having some issues rotating objects.

The scene is a simple cube, with no translation or scale, I've tried both without projection setup and with projection, and in any case it acts strangely. Without the projection, it looks like the mesh deforms until at some point it breaks, but it's hard to tell what's really going on. With perspective projection, this is a video of what it does rotating about the y-axis.

The rotation is simply an angle being incremented by 0.05f each frame (never decremented), but the effect isn't what I think it should be at all.

Does someone know where should I start looking for mistakes? Thanks.

Note: I haven't posted any code because I don't know where the problem might be (and posting the whole thing is way too much), if anyone has any clues, I will post any code that might be useful.

| improve this question | | | | |
  • \$\begingroup\$ I think it could be something with shear. If it's, you should control your rotation matrix creation. If you don't know how to control it, you can use for example this slides service.felk.cvut.cz/courses/Y36PHA/data/prednasky/5/… - there is somewhere rotation about each axis. Or you can look for Rodrigues formula (general rotation matrix). \$\endgroup\$ – zacharmarz Sep 6 '11 at 6:23
  • 2
    \$\begingroup\$ Are you sure your depth buffer is ok? It looks like the rotating is alright but that there is something wrong with the depth buffer, so there is no overlapping. \$\endgroup\$ – Roy T. Sep 6 '11 at 8:50
  • \$\begingroup\$ @zacharmarz I've tried changing the rotation matrix to the matrix on those slides, I was getting the rotation matrix from some quaternions on the first video. The deformation persists with the new matrix, it's just... different, it seems to be flattening at some point, even though part of the rotation process looks perfect :-/. This is a video of it (about the x-axis, using the arbitrary axis formula, it looks pretty similar with the x-axis rotation formula) link \$\endgroup\$ – uorbe001 Sep 6 '11 at 19:53
  • \$\begingroup\$ @Roy T. Opengl is reporting no errors, so I'd think the depth buffer is alright, I'm calling glEnable(GL_DEPTH_TEST) and glDepthFunc(GL_LEQUAL) before doing any drawing, and glClear with the depth buffer bit every frame, may I be missing something there? \$\endgroup\$ – uorbe001 Sep 6 '11 at 19:55
  • \$\begingroup\$ A quick note about the videos, the first video is rotating about the y-axis, the second one about the x-axis. The y axis is still getting deformmed with the matrices on those slides, it just looks different. For some reason, x-axis rotation looks the same whether I get the matrix with the formula on those slides(Rodrigues formula) or I get it from the quaternions (it's just a lot faster with quaternions). \$\endgroup\$ – uorbe001 Sep 6 '11 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.