blender models in opengl


(karsten) #1

Hi,

anyone here who uses Blender models in OpenGL programs?
What is the best way to export the models, so that they can used in an OpenGL program (C/C++)?
Is there already an export script and/or sample code for C/C++?


(nutville) #2

Hello Kartsten,

OpenGL by itself does not have a file format. What do you like to do, are you writing your own app or do you want to import Blender models into other apps?
If you want to write your own program you will have to choose a file format yourself. In that case choose one that has an export script available in Blender.
If you want to use your Blender models in other applications, there are already floating Python export scripts around for a lot of file formats.

Maarten


(karsten) #3

I know that OpenGL has no own file format.

I just play around with opengl and thought, that it would be good that I can use Blender models for OpenGL, it is easier to model them in Blender instead of writing an ascii file or so.

I am only looking for a small python program to export the model in an easy to read file format. I haven’t done an python program until now, so it would be good if there is already a solution for that.


(nikoy) #4

I’ve exported Blender models as .dxf and written a simple program that imported and rendered the models into opengl. DXF is a fairly simple format and is well documented (sort of…). Also it seems to lend itself well to being piled into an array of structures. I can’t find the code right now, but I remember it didn’t take long to write a more-or-less functional importer/opengl renderer from dxf.

So in other words, I can offer no help whatsoever. Oh no wait, if you import a model into crossroads (its a windows free app.) it can output a model into a structure of polygons (or something, I don’t remember). That’s even easier to work with since then you only need to worry about rendering the data.

Crossroads can be found at:

http://home.europa.com/~keithr/Crossroads/index.html


(dalexander) #5

I have been playing around with this for the last two weeks or so. You might want to look at the blenderman export script to see how to get to the data and roll your own. You can produce a file that has information stored like the videoscape format. I use a binary format because it is easier than trying to parse ascii text. It is similiar to parts of the MD2 format…arrays of vertices and arrays of polygons that its members are indexes to the array of vertices. I have gotten far enough in my playing around to load two snapshots of data from the rungirlrun.blend demo and animate it in OpenGL. Still working with the uv tex coordinates, though.

I am a novice and still trying to figure most of this stuff out, but if I can be of any help drop me a line at [email protected]

good luck,
Dave Alexander


(ChrisGarret) #6

Hi,

I am working on a game where all the models are created and vertex painted in Blender. I then export them from Blender as VRML CTRL+F2 as this preserves all the color information.

I them import them into an OpenGL engine.

Chris


(theeth) #7

just a quick reminder, Blender can already export to videoscape, it’s built-in.

Martin


(SirDude) #8

Check out http://www.cs.umn.edu/~mein/blender/converters.html


(karsten) #9

Thanks to all for your tips.

For my first test the gl_exporter1.0 script looks fine. It writes directly the GL code to a file.

Later I have to look for a solution to load dynamicly the models.