SubMesh examples

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

SubMesh examples

Post by rrl » Thu Oct 18, 2018 3:49 am

I'm trying to create several separate meshes in 2.1 that together make a whole mesh, but display them separately. There used to be a sample in 2.1 that used SubMesh's and IIRC, had a function named createStaticMesh, but I can no longer find this. Any know where that might have gone. I've grep'd the entire Sample tree but can't find it.
Last edited by rrl on Sat Oct 20, 2018 4:01 am, edited 1 time in total.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3997
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 192
Contact:

Re: SubMesh examples

Post by dark_sylinc » Thu Oct 18, 2018 6:42 am

0 x

rrl
Halfling
Posts: 59
Joined: Sun Jun 04, 2017 12:33 am

Re: SubMesh examples

Post by rrl » Sat Oct 20, 2018 4:04 am

In this sample, DynamicGeometryGameState::createScene01() calls createStaticMesh multiple times where upon each call, it calls createManual(...).

Are the MeshPtr's mStaticMesh and mPartialMesh (within DynamicGeometryGameState::createScene01) examples of two separate meshes, and not two sub meshes of the same mesh? Each call of createManual is a separate mesh, correct?

Just trying to understand when to use a submesh. I have several models and want to show/hide each wireframe, have each wireframe model appear in different colors, etc...
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3997
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 192
Contact:

Re: SubMesh examples

Post by dark_sylinc » Sat Oct 20, 2018 4:38 am

rrl wrote:
Sat Oct 20, 2018 4:04 am
Are the MeshPtr's mStaticMesh and mPartialMesh (within DynamicGeometryGameState::createScene01) examples of two separate meshes, and not two sub meshes of the same mesh? Each call of createManual is a separate mesh, correct?
That's correct.
rrl wrote:
Sat Oct 20, 2018 4:04 am
Just trying to understand when to use a submesh. I have several models and want to show/hide each wireframe, have each wireframe model appear in different colors, etc...
Ogre has the following hierarchy:
  • Mesh
    • SubMesh 0
    • SubMesh 1
    • ...
    • SubMesh N
And likewise instantiation is done through Items:
  • Item (instantiates Mesh)
    • SubItem 0 (instantiates SubMesh 0)
    • SubItem 1 (instantiates SubMesh 1)
    • ...
    • SubItem N (instantiates SubMesh N)
Mesh contains information such as AABB that encloses all of its Submeshes, list of LOD distances, references the associated skeleton.
Submeshes contains the actual geometry and a material. Each SubMesh can only have one material.

Items contain position/orientation/scale information, AABB for frustum culling, can toggle themselves visible or not (via setVisible). SubItems contain material information, and reference the SubMesh.

SubItems cannot normally be turned on/off at will, Items can. BUT which Renderables will be rendered is determined by MovableObject::mRenderables which is a public member.
You could theoretically manipulate MovableObject::mRenderables from an Item to hide a particular SubItem/SubMesh. However this is probably a bit hacky and thus I suggest you restore mRenderables back to how it was before destroying the Item.
I have several models and want to show/hide each wireframe, have each wireframe model appear in different colors, etc...
If it's the same exact model just with different material, then I suggest you create multiple Items based on the same Mesh, and change the materials of these Items. Items can change their material. The one in the Mesh is just "the default one", but it is not immutable.
0 x

Post Reply