Members - Reputation: 140
Posted 23 November 2012 - 09:28 PM
I get that many people will have different uses for the data stored in their particular model format but is there not some base functionality that could be implemented. Such as: load vertices, normals, uv coordinates, and indicies? I seriously have to go write a loader from scratch? Or apparently learn the poorly documented Assimp API?
So my question is: where is the most stable loader library for either a .blend, or .obj, or anything else that Blender can export (or a tutorial). I'm not about to drop 3 grand on Maya or 3DSMax. Jesus. I suppose I can do it if I have to but at this point I could care less about how the mesh is actually loaded. I don't need to know the inner workings of a mesh loader to satisfy a craving for knowledge. Just give me something that says: loadMesh(...), getVertices(...), getIndices(...).... etc, etc.
Help a guy out. My flying cube is pretty sweet and all but I also wanted to add planets with gravity, etc and I don't want to write out the vertices by hand or apply some ungodly function to generate them.
Members - Reputation: 3555
Posted 23 November 2012 - 10:23 PM
There is no good general purpose 3D model format because 3D data is very versatile and can be used in many different ways. Blender, Maya, 3DS Max, and similar programs all have their own internal data structures and ways of representing things, and their file formats are not general purpose, or even useful to other programs.
Because of that, loading someone else's file format into your program is VERY counter productive. Your program will end up wasting a lot of time allocating memory to load foreign data structures, and then restructuring it all at load time to map to your own internal data structures. This is a very slow and messy process.
It's best to use something like Blender's scripting language to export data out of the program into a file format of your choosing in a way that makes sense for your own program, and it's data structures. If all you want is a list of vertices, then write a small script that will dump out a list of vertices into a txt file. Evolve your own format over time, and then when you are done you can make a proper binary format.
Crossbones+ - Reputation: 3748
Posted 29 November 2012 - 04:52 AM
Then export the geometry as collada and load it up using AssImp. This way, you still get some benefits of collada and full support of your features. Yeah, theorically, Collada alone could do that but looks like AssImp doesn't (sure blender don't export them anyway) so we have to work around that.
The idea of producing my own format for data exchange ... mh, I'd rather not do that.
Members - Reputation: 938
Posted 17 December 2012 - 06:05 PM
Or apparently learn the poorly documented Assimp API?
Really? poorly documented? I found their documentation very useful. All you have to do is load the data using a single call to assimp and then you have a fairly transparent structure that holds all your data. Like so:
Assimp::Importer importer; const aiScene* scene = importer.ReadFile("file.obj", flags);
Then you can grab vertex positions from that same structure like so:
xpos = scene->mMeshes->mVertices[i].x; ypos = scene->mMeshes->mVertices[i].y; zpos = scene->mMeshes->mVertices[i].z;
you know you program too much when you start ending sentences with semicolons;