Friday 27 March 2015

Convert Blender models into OpenGL code

I have been trying to make games lately, my first attempt was to try and make a 2d game by rendering a character model I made with an Orthographic camera in different angles. The result was this



I didn't really know what to do with that though..

But I also wanted to try and convert my Blender object into c-code. There are probably lots of scripts to be found out there. But I want to do something on my own.

I made a wavefront .obj parser in Flex and Bison that I used to convert the file into c code.

https://github.com/Spekkio/objParser

I made this spaceship in Blender



Then I converted it into c code using objParser and implemented that code into a program.



There are lots of things that can be done with the objParser tool, for example texture locations can be exported, colors etc. I've been thinking about implementing LUA support, to be able to write scripts for the export routines. To make it possible to output to any type you wanted to, VBO's, JavaScript, etc. It would also be possible to implement it as a loader.
I am a little bit worried about the linked list that I wrote though, I don't know how well that will work on very large scenes. Pre parsing a file to check how much memory a file needs before maybe a good thing, I don't know ?