Use of a submesh

Problems building or running the engine, queries about how to use features etc.
Post Reply
rrl
Halfling
Posts: 78
Joined: Sun Jun 04, 2017 12:33 am

Use of a submesh

Post by rrl »

I have several groups of elements that are a part of a car model. One element group is the the car body, another are the wheels of the car, and another the drivetrain. Currently I ... 1) create the mesh, 2) create the submesh, 3) do vertex declarations, and then go on to do the buffers and render them in a scene. At this point, I render the entire model.

I only call 'car_mesh = MeshManager::getSingleton().createManual("My Car", ...' to reference the entire model. Is mesh->createSubMesh() meant to be used to render each part/group of elements I want to display, i.e., a separate submesh for the wheels, one for the body, one for the drive train? If I use it in that manner, is that the intended purpose of a submesh? How it should be done? Then I can just select a pointer to that submesh to display only those elements/parts?

Also, I have one additional question. How is a submesh added back to the parent mesh once it's created from createManual()? I'm using the DynamicGeometry sample and it seems that Ogre::Item is created to show the parent mesh, but I'm not seeing how the submesh's are attached to the parent mesh.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1280
Contact:

Re: Use of a submesh

Post by dark_sylinc »

That's something you'll have to evaluate based on your needs.
The purpose of a submesh is to share the same resources and setup (Node transform, node hierarchies, skeleton) and while using different materials on a specific subsection of the geometry, while simplifying the setup (i.e. you only worry about the Item as if it were one single object).
For example a house with a wall material and a roof material being two submeshes of the same mesh.

However if you require finer control of each sub element (like toggling its visibility on/off, tightly controlling rendering order, moving/rotating/scaling the object individually without the aid of a skeleton bone), then you likely what you want is to treat them as separate meshes.
Post Reply