Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I haven't found an answer in the documentation. Im writing a piece of code that transforms imported aiScene into my own data structures and I'm wondering in what case the scene would have an aiNode that contains more than 1 mesh. Or when it would have more than 1 aiNode that refers to the same mesh.
I need this to be able to identify meshes in the scene so I can assign appropriate shaders to them.
The doc. says 2 aiNodes refering to the same mesh is a way for simple instancing. I tried craeting a file in 3ds Max that would produce such an aiScene (object clone: copy/instance/reference) but to no avail. I don't even have an idea how to create 1 aiNode with multiple meshes.
That's nothing a documentation can answer.
Multiple nodes referring to a mesh: that's instancing. File formats and exporters need to support this, though. File formats with instancing support are FBX, Collada, 3ds, XFile, erm... don't know exactly. LWO maybe? You can also employ the post processing step FindInstances, but this step can only do so much when someone already processed the mesh data.
Multiple meshes in one node: some file formats support this, e.g. Collada. Also Assimp splits up meshes when they use multiple materials, one mesh for each material. The meshes should be named, though, even though mesh names are a pretty new addition to Assimp and I can't tell you which parts make use of these already.
"That's nothing a documentation can answer."
Did you mean "can't"? Because if so, I read it twice or thrice and failed to find my answers. You said Collada should support both cases. I actually did try this format when trying to get necessary aiScene but I didn't know what I needed to do in 3ds max to get that.
As to the first case, I know it's instancing and I DID write I knew it. But the only thing about instancing (or closest to) I can find in 3ds max is object cloning and I've tried that already. No success.
As to mesh names - actually scenes I've tested always had all mesh names set to "" (empty). :P
As I wrote above: Instancing support requires a file format that can express this kind of relationship AND an exporter making use of it. The Collada file format does support instancing, but I don't know which exporters make use of it. If you need to rely on instancing, try the FindInstances PPStep and hope that the exporter doesn't bake transformations into the meshes. Also, don't use PreTransformVertices, but that should be obvious.
Ok, the only thing I really need - a reliable way to identify meshes in my scene (so I can assign appropriate shaders to them). And since meshes (at least in a couple of test scenes and formats I tried) have names set to "" and there's no guarantee that 1 aiNode == 1 aiMesh then what's the reliable way to identify meshes in a scene?
By the node? Or by material, like shaders are supposed to be used?
Can I assume that aiScene's mRootNode will always have 0 meshes?
No. Use the PreTransform_Vertices step and you'll get a root node with some meshes, for example.