Rotate an object given only by its points?
- by d33tah
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?