Mesh Loaders (.obj, b3dxml etc.)

BlitzMax Forums/MiniB3D Module/Mesh Loaders (.obj, b3dxml etc.)

Difference(Posted 2007) [#1]
Hi

I am planning to make som file importeres for miniB3D (simons base version)

I'f they are any good I'll release them here, unless someone beats me to it.

Any advice on how to lay them out?

Do I simply make my own include file, and return a TMesh:

Function LoadWavefrontObj:TMesh(parent_ent:TEntity=Null)
Local mesh:TMesh=TMesh.CreateMesh(parent_ent)

'actual loading here....


Brucey(Posted 2007) [#2]
Do I simply make my own include file

Of course, you mean "a file for importing" :-)


klepto2(Posted 2007) [#3]
I would say irt depends on the kind of model you want to load.
If the models are static only then a simple mesh as a return will work, but if you import some kind of animation it may be needed to implement some animation handlers to the Core of minib3d (maybe you could take look to my md2 loader).
Also a possibility is to integrate the model loaders in a way that they could use the already implemented animation routines, but that also will need a bit of understanding how minib3d is working under his hood.

So I would start with static mesh support and an import file, like I will do with my try to integrate a collada importer.

Have fun and good luck ;)


Difference(Posted 2007) [#4]
Thx guys, I'll try with a static .obj loader.


klepto2(Posted 2007) [#5]
The thing with the animations have inspired me to think a bit about it.
Well the whole animation is handled in the UpdateWorld command, so here is my idea:
We add a Functionhandler to the TMesh Type or TEntity Type
and if updateWorld is called then you simply call this FunctionPointer. This would be also an easy way to provide somekind of plugin loaders. So Minib3D would stay a bit minimal but you could simply add the different loaders per extra independent includes or imports without changeing the source of minib3d.

What do you think about this?


LAB[au](Posted 2007) [#6]
This sounds like a good plan, I like it and I hope Simon likes it too!


Difference(Posted 2007) [#7]
I like the idea of plugins. In my case a mesh loader plugin.
I don't think it however it nessesarily should be implemented as a native minib3d feature.

Here is how I'm planning to do my mesh loading:

Because I wan't to be able to reuse my mesh loader for other things than minib3d, I'm making a genereric model type (static objects only for now).
It will have some generic material type, vertices,triangles and objects.

It will have a ReadWaveFrontFile() method and maybe someday a SaveWaveFrontFile() method
Then I'll have another module with a function to convert the generic model to a minib3d entity, with a wrapper function to call from my main program

This will also allow extention of the mesh loader by adding ReadSome3DFormatFile() , only having to worry about a simple generic format.