Rotate an object given only by its points?

Posted by d33tah on Game Development See other posts from Game Development or by d33tah
Published on 2012-11-12T21:57:07Z Indexed on 2012/11/12 23:14 UTC
Read the original article Hit count: 148

Filed under:
|

I was recently writing a simple 3D maze FPP game. Once I was done fiddling with planes in OpenGL, I wanted to add support for importing Blender objects. The approach I used was triangulization of the object, then using Three.js to export the points to plaintext and then parsing the result JSON in my app.

The example file can be seen here: https://github.com/d33tah/tinyfpp/blob/master/Data/Models/cross.txt The numbers represent x,y,z,u,v of a single vertex, which combined in three make a triangle.

Then I rendered such an object triangle-by-triangle and played with it. I could move it back and forth and sideways, but I still have no idea how to rotate it by some axis. Let's say I'd like to rotate all the points by five degrees to the left, how would a code doing it look like?

© Game Development or respective owner

Related posts about opengl

Related posts about geometry