Utility of submesh class ?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
wexxer
Gnoblar
Posts: 2
Joined: Tue Aug 26, 2014 3:28 pm

Utility of submesh class ?

Post by wexxer »

Hello,

I quote from here :
https://bitbucket.org/sinbad/ogre/src/2 ... at=default
Meshes which make up the definition of a discrete 3D object
are made up of potentially multiple parts. This is because
different parts of the mesh may use different materials or
use different vertex formats, such that a rendering state
change is required between them.
Why not simply use the scenegraph ( Nodes ) to achieve that ? Every single node has its own mesh and material right ? And it can have infinite children.

For example we could have a Car node ( without any mesh or material ) composed of children like wheel, window, who would have different material and mesh, instead having a car mesh composed of submeshes.

What's the benefit of submeshes ?

thanks.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: Utility of submesh class ?

Post by tod »

Nodes have some overhead. They are organized internally in some way or another, like a tree or other structure, and must be traversed when doing stuff with the scene. Adding nodes for no reason is not very good. I'm sure there are other reasons why submeshes exist, but I don't know them for sure.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Utility of submesh class ?

Post by Kojack »

wexxer wrote:Why not simply use the scenegraph ( Nodes ) to achieve that ? Every single node has its own mesh and material right ? And it can have infinite children.
Scene nodes don't have meshes or materials.

Mesh is the primary class for holding loaded model information. Submeshes are created to divide a single mesh based on materials (you can only have one material per draw call).
Entities are the objects that are instances of meshes. Entities have subentities, with a 1 to 1 correspondence to submeshes.

Entities can be attached to scene nodes. So can many other objects such as lights, cameras, particle systems, billboards, etc. You can also have more than one thing in a scene node. For example you could have 4 entities all in the same scene node.

All submeshes share the same local coordinate system. This means a scene node's transform can be calculated once, then all subentities (and therefore submeshes) share it. This is faster than using multiple scene nodes.
wexxer
Gnoblar
Posts: 2
Joined: Tue Aug 26, 2014 3:28 pm

Re: Utility of submesh class ?

Post by wexxer »

Okay thanks.


I have another question: How do I deal with duplicate objects ? Does the render engine automatically optimize 2 similar objects or do I have to create them in a specific way for being able to render them using only one buffer instead of two ?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Utility of submesh class ?

Post by Kojack »

The entity class is effectively an instance of a mesh. If you add several entities that use the same mesh, only one copy of the mesh is loaded into memory (even if you give different materials or bone settings to the entities).
There's also an instancing system that tries to reduce draw calls for the same kinds of entities, although this isn't automatic, you need to set it up. There's some info here: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=59902
Post Reply