Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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). –  zacharmarz Sep 6 '11 at 6:23
2  
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. –  Roy T. Sep 6 '11 at 8:50
    
@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 –  uorbe001 Sep 6 '11 at 19:53
    
@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? –  uorbe001 Sep 6 '11 at 19:55
    
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). –  uorbe001 Sep 6 '11 at 20:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.