2
\$\begingroup\$

For my current game I'm working on I've decided to implement a custom model class to store my models in. Reasons being is that I want to make adding new models as painless as possible for the rest of the team without needing to go through the XNA/Monogame content pipeline (Them having VS + Dev framework installed just to compile a few models, or passing them onto me to compile every time a change is made would just get tedious further on, not to mention different timezones when testing slowing things down)

To this end I've been looking at the model structure of different frameworks, XNA/Monogame, SharpDX and AssImp.NET being the main ones. The structure for XNA/MG and SharpDX is Model->MeshCollection->MeshPartCollection, whereas Assimp only has Scene->MeshCollection.

From previous experience in XNA, MeshParts seem kinda redundant. None of my meshes ever had more than one, and a lot of the XNA examples I've seen only ever had one mesh part per mesh.

From everything I've experienced and seen, MeshParts seem redundant, surplus to requirements and just makes for an extra level of complexity (Should I use a loop, or just hardcode it to use the first element in the collection?). Is there some useful aspect of them that I am not aware of, or a particular use case or scenario where they are actually useful?

\$\endgroup\$
3
\$\begingroup\$

Answer to your question can be found on Shawn Hargreaves Blog who was one of the XNA creators:

Within a ModelMesh, each ModelMeshPart represents a single graphics card draw call. It contains a set of triangles that share the same material (stored in the ModelMeshPart.Effect property) and vertex declaration. For instance the ModelMesh for the body of our car might contain one ModelMeshPart for the painted car surface, one using an environment mapping effect for the reflective windscreen, and another using a normalmap texture for the snakeskin leather seats (I hasten to assure concerned readers that no snakes were harmed during the production of this blog post…)

the article about this hierarchy: http://blogs.msdn.com/b/shawnhar/archive/2006/11/20/models-meshes-parts-and-bones.aspx

\$\endgroup\$
1
\$\begingroup\$

MeshParts in XNA, SubMesh in Ogre or other similar entities usually serve the main purpose of applying multiple materials to the same 3D model, yet still dealing with it as a single higher level entity (Mesh). You can't assign different materials to different parts of the same mesh, without having multiple draw calls, hence separating the model to different parts.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.