Loading...
Searching...
No Matches
Ogre::SubMesh Class Reference
Core » Resources

Defines a part of a complete mesh. More...

`#include <OgreSubMesh.h>`

Inheritance diagram for Ogre::SubMesh:
[legend]

## Public Types

typedef MapIterator< VertexBoneAssignmentList > | BoneAssignmentIterator
typedef std::vector< unsigned short > | IndexMap
| Dedicated index map for translate blend index to bone index (only valid if useSharedVertices = false).
typedef std::vector< IndexData * > | LODFaceList
typedef std::multimap< size_t, VertexBoneAssignment > | VertexBoneAssignmentList
| Multimap of verex bone assignments (orders by vertex index).

## Public Member Functions

| SubMesh ()
| ~SubMesh ()
void | _compileBoneAssignments (void)
| Must be called once to compile bone assignments into geometry buffer.
void | _getRenderOperation (RenderOperation &rend, ushort lodIndex=0)
| Returns a RenderOperation structure required to render this mesh.
void | addBoneAssignment (const VertexBoneAssignment &vertBoneAssign)
| Assigns a vertex to a bone with a given weight, for skeletal animation.
void | clearBoneAssignments (void)
| Removes all bone assignments for this mesh.
SubMesh * | clone (const String &newName, Mesh *parentMesh=0)
| Makes a copy of this submesh object and gives it a new name.
void | createVertexData (HardwareBufferManagerBase *mgr=nullptr)
| Creates a new local vertex data object.
void | generateExtremes (size_t count)
| Generate the submesh extremes (see extremityPoints()).
BoneAssignmentIterator | getBoneAssignmentIterator (void)
const VertexBoneAssignmentList & | getBoneAssignments () const
| Gets a const reference to the list of bone assignments.
const MaterialPtr & | getMaterial () const
const String & | getMaterialName (void) const
bool | getVertexAnimationIncludesNormals () const
| Returns whether animation on dedicated vertex data includes normals.
VertexAnimationType | getVertexAnimationType (void) const
| Get the type of any vertex animation used by dedicated geometry.
bool | isBuildEdgesEnabled (void) const
| Returns true(by default) if the submesh should be included in the mesh EdgeList, otherwise returns false.
void | resetVertexData (VertexData *data=nullptr)
| replace the vertex data with a new one
void | setBuildEdgesEnabled (bool b)
void | setMaterial (const MaterialPtr &mat)
void | setMaterialName (const String &matName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
| Sets the name of the Material which this SubMesh will use.

## Public Attributes

IndexMap | blendIndexToBoneIndexMap
std::vector< Vector3 > | extremityPoints
| A list of extreme points on the submesh (optional).
IndexData * | indexData
| Face index data.
LODFaceList | mLodFaceList
RenderOperation::OperationType | operationType
| The render operation type used to render this submesh.
Mesh * | parent
| Reference to parent Mesh (not a smart pointer so child does not keep parent alive).
bool | useSharedVertices
| Indicates if this submesh shares vertex data with other meshes or whether it has it's own vertices.
VertexData * | vertexData
| Dedicated vertex data (only valid if useSharedVertices = false).

## Detailed Description

Defines a part of a complete mesh.

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.

  Like the Mesh class, instantiations of 3D objects in the scene share the SubMesh instances, and have the option of overriding their material differences on a per-object basis if required. See the SubEntity class for more information.

## Member Typedef Documentation

## IndexMap

typedef std::vector<unsigned short> Ogre::SubMesh::IndexMap

Dedicated index map for translate blend index to bone index (only valid if useSharedVertices = false).

This data is completely owned by this submesh.

  We collect actually used bones of all bone assignments, and build the blend index in 'packed' form, then the range of the blend index in vertex data VES_BLEND_INDICES element is continuous, with no gaps. Thus, by minimising the world matrix array constants passing to GPU, we can support more bones for a mesh when hardware skinning is used. The hardware skinning support limit is applied to each set of vertex data in the mesh, in other words, the hardware skinning support limit is applied only to the actually used bones of each SubMeshes, not all bones across the entire Mesh.

  Because the blend index is different to the bone index, therefore, we use the index map to translate the blend index to bone index.

  The use of shared or non-shared index map is determined when model data is converted to the OGRE .mesh format.

## LODFaceList

typedef std::vector<IndexData*> Ogre::SubMesh::LODFaceList

## VertexBoneAssignmentList

typedef std::multimap<size_t, VertexBoneAssignment> Ogre::SubMesh::VertexBoneAssignmentList

Multimap of verex bone assignments (orders by vertex index).

## BoneAssignmentIterator

typedef MapIterator<VertexBoneAssignmentList> Ogre::SubMesh::BoneAssignmentIterator

## Constructor & Destructor Documentation

## SubMesh()

Ogre::SubMesh::SubMesh | ( |  | ) |

Referenced by clone().

## ~SubMesh()

Ogre::SubMesh::~SubMesh | ( |  | ) |

## Member Function Documentation

## resetVertexData()

void Ogre::SubMesh::resetVertexData | ( | VertexData * | data = nullptr | ) |

inline

replace the vertex data with a new one

References useSharedVertices, and vertexData.

Referenced by createVertexData().

## createVertexData()

void Ogre::SubMesh::createVertexData | ( | HardwareBufferManagerBase * | mgr = nullptr | ) |

inline

Creates a new local vertex data object.

References resetVertexData().

## setMaterialName()

void Ogre::SubMesh::setMaterialName | ( | const String & | matName,
|  | const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME )

Sets the name of the Material which this SubMesh will use.

References Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME.

## getMaterialName()

const String & Ogre::SubMesh::getMaterialName | ( | void |  | ) | const

## setMaterial()

void Ogre::SubMesh::setMaterial | ( | const MaterialPtr & | mat | ) |

inline

## getMaterial()

const MaterialPtr & Ogre::SubMesh::getMaterial | ( |  | ) | const

inline

## _getRenderOperation()

void Ogre::SubMesh::_getRenderOperation | ( | RenderOperation & | rend,
|  | ushort | lodIndex = 0 )

Returns a RenderOperation structure required to render this mesh.

Parameters

  rend | Reference to a RenderOperation structure to populate.
  lodIndex | The index of the LOD to use.

## addBoneAssignment()

void Ogre::SubMesh::addBoneAssignment | ( | const VertexBoneAssignment & | vertBoneAssign | ) |

Assigns a vertex to a bone with a given weight, for skeletal animation.

This method is only valid after calling setSkeletonName. Since this is a one-off process there exists only 'addBoneAssignment' and 'clearBoneAssignments' methods, no 'editBoneAssignment'. You should not need to modify bone assignments during rendering (only the positions of bones) and OGRE reserves the right to do some internal data reformatting of this information, depending on render system requirements.

  This method is for assigning weights to the dedicated geometry of the SubMesh. To assign weights to the shared Mesh geometry, see the equivalent methods on Mesh.

## clearBoneAssignments()

void Ogre::SubMesh::clearBoneAssignments | ( | void |  | ) |

Removes all bone assignments for this mesh.

  This method is for assigning weights to the dedicated geometry of the SubMesh. To assign weights to the shared Mesh geometry, see the equivalent methods on Mesh.

## getBoneAssignmentIterator()

BoneAssignmentIterator Ogre::SubMesh::getBoneAssignmentIterator | ( | void |  | ) |

Deprecated
  use getBoneAssignments

## getBoneAssignments()

const VertexBoneAssignmentList & Ogre::SubMesh::getBoneAssignments | ( |  | ) | const

inline

Gets a const reference to the list of bone assignments.

## _compileBoneAssignments()

void Ogre::SubMesh::_compileBoneAssignments | ( | void |  | ) |

Must be called once to compile bone assignments into geometry buffer.

## getVertexAnimationType()

VertexAnimationType Ogre::SubMesh::getVertexAnimationType | ( | void |  | ) | const

Get the type of any vertex animation used by dedicated geometry.

## getVertexAnimationIncludesNormals()

bool Ogre::SubMesh::getVertexAnimationIncludesNormals | ( |  | ) | const

inline

Returns whether animation on dedicated vertex data includes normals.

## generateExtremes()

void Ogre::SubMesh::generateExtremes | ( | size_t | count | ) |

Generate the submesh extremes (see extremityPoints()).

Parameters

  count | Number of extreme points to compute for the submesh.

## isBuildEdgesEnabled()

bool Ogre::SubMesh::isBuildEdgesEnabled | ( | void |  | ) | const

inline

Returns true(by default) if the submesh should be included in the mesh EdgeList, otherwise returns false.

## setBuildEdgesEnabled()

void Ogre::SubMesh::setBuildEdgesEnabled | ( | bool | b | ) |

## clone()

SubMesh * Ogre::SubMesh::clone | ( | const String & | newName,
|  | Mesh * | parentMesh = 0 )

Makes a copy of this submesh object and gives it a new name.

Parameters

  newName | The name to give the clone.
  parentMesh | Optional mesh to make the parent of the newly created clone. If you leave this blank, the clone will be parented to the same Mesh as the original.

References SubMesh(), and Mesh.

## Member Data Documentation

## vertexData

VertexData* Ogre::SubMesh::vertexData

Dedicated vertex data (only valid if useSharedVertices = false).

This data is completely owned by this submesh.

  The use of shared or non-shared buffers is determined when model data is converted to the OGRE .mesh format.

Referenced by resetVertexData(), and Ogre::Lod0Stripifier::StripLod0Vertices().

## indexData

IndexData* Ogre::SubMesh::indexData

Face index data.

Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().

## blendIndexToBoneIndexMap

IndexMap Ogre::SubMesh::blendIndexToBoneIndexMap

## mLodFaceList

LODFaceList Ogre::SubMesh::mLodFaceList

Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().

## extremityPoints

std::vector<Vector3> Ogre::SubMesh::extremityPoints

A list of extreme points on the submesh (optional).

These points are some arbitrary points on the mesh that are used by engine to better sort submeshes by depth. This doesn't matter much for non-transparent submeshes, as Z-buffer takes care of invisible surface culling anyway, but is pretty useful for semi-transparent submeshes because the order in which transparent submeshes must be rendered cannot be always correctly deduced from entity position.

  These points are intelligently chosen from the points that make up the submesh, the criteria for choosing them should be that these points somewhat characterize the submesh outline, e.g. they should not be close to each other, and they should be on the outer hull of the submesh. They can be stored in the .mesh file, or generated at runtime (see generateExtremes()).

  If this array is empty, submesh sorting is done like in older versions - by comparing the positions of the owning entity.

## parent

Mesh* Ogre::SubMesh::parent

Reference to parent Mesh (not a smart pointer so child does not keep parent alive).

## useSharedVertices

bool Ogre::SubMesh::useSharedVertices

Indicates if this submesh shares vertex data with other meshes or whether it has it's own vertices.

Referenced by resetVertexData(), and Ogre::Lod0Stripifier::StripLod0Vertices().

## operationType

RenderOperation::OperationType Ogre::SubMesh::operationType

The render operation type used to render this submesh.

The documentation for this class was generated from the following file:

- OgreSubMesh.h