C++ and Blender

Started by
5 comments, last by jayson 17 years, 11 months ago
Not really sure how to ask this question because I'm not too educated in the technical field. But a friend of mine and myself are in the process of developing a game for PC. I am constructing the objects, animations and pretty much everything else that goes into the world using Blender. My friend is doing the programming in C/C++. My question is, I guess, how do I transfer my models and animations in Blender over to his game engine? About his engine - Its not really that developed yet. But it is an engine in First Person view that works very well. He has it in the form of a tank simulator called VazTank. Heres his website www.vazgames.com If all else fails, would ya'll or wouldn't ya'll recommend us writing the game with the engine that is built into the Blender environment? Thanks for any help, I appreciate it.
Advertisement
It comes down to what the Engine wants and what the engine can handle.

People either go with an existing format (in which case you would use the export menu to export a .obj or similar) or make their own.

If the engine uses its own type of model format, then the programmer needs to write an exporter in python. Then you add that to your available exports and export to that file format.
Just finished a school project (a racing sim, sorta) using blender and OpenGL.
In short, blender ended up working out decently well for us, but you should really read the documents before you pick an export format.
Find a good format loader for you code, and test test test test test. There are tones of settings you can pick from, and
only a few are going to make your models look good ingame.

Though it was a long struggle to get it to work.
We tried the 3ds format, and had major issues with the blender exporter.
We then began exporting as .obj, wich had issues with textures, since we didn't read the docs enough the first time around
and didn't realize there is a process for generating UV coords that you have to take before it will export then UV coords.
When we did find a way to export the UV coords, the coords that looked good in the blender rendition didn't look good in our game.

Quote:Original post by KulSeran
Just finished a school project (a racing sim, sorta) using blender and OpenGL.
In short, blender ended up working out decently well for us, but you should really read the documents before you pick an export format.
Find a good format loader for you code, and test test test test test. There are tones of settings you can pick from, and
only a few are going to make your models look good ingame.

Though it was a long struggle to get it to work.
We tried the 3ds format, and had major issues with the blender exporter.
We then began exporting as .obj, wich had issues with textures, since we didn't read the docs enough the first time around
and didn't realize there is a process for generating UV coords that you have to take before it will export then UV coords.
When we did find a way to export the UV coords, the coords that looked good in the blender rendition didn't look good in our game.



Hey, as for export formats, I noticed in the python script window that one of the supported formats are good old DirectX. Whats your feed on that?
And what do you mean by Finding a good loader for my code? What is a loader? Sorry, but a lot of this technical stuff is way over my head.

Thanks for the help.
Quote:Original post by double O sevenAnd what do you mean by Finding a good loader for my code? What is a loader? Sorry, but a lot of this technical stuff is way over my head.


A loader is the library that loads the models and animations into your application, creating geometric data structures like list of vertices with coordinates and lists of triangles referencing the vertices.
The steps from Blender to the game and the problems they can cause form a logical sequence:

- The chosen file format cannot represent all the data needed by the game. Find another one or compromise.
- The export script or built-in function damages the model.
Unsupported file format features and wrong export options are likely.
- The loader library damages the model.
The file could contain something the loader doesn't support.
- The results of loading are mismatched with the game engine.
The game might need to convert the geometrical representation, for examples from triangle lists to triangle strips and fans or vice versa, or to compute additional data, for example interpolated vertex normals. A more suitable file format or loader library could avoid some of this work.

Omae Wa Mou Shindeiru

You could just write your own exporter to blender that suites your needs. Download the api documentation and hack away ;)

Im just gonna add a small question of my own in here:
When it comes to animation and the .obj format, i notice the standard exporter in blender export an .obj for each step of the animation. Does one just take and load all of these, then interpolate all the vertex-positions over time bewteen the files ? or is there a better way?
I'd highly recommend just writing your own custom exporter. It's all in Python, against a very simple API, so it takes minimal effort to get something going, and then you can work against a format tailored for your project, instead of kludging something else in. It generally ends up being less work overall, rather than more.

Take a look at blender/.blender/scripts/rawexport.py for a starting point - it's only like 100 lines =]

This topic is closed to new replies.

Advertisement