OGRE-Next
4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
Resource holding data about 3D mesh. More...
#include <OgreMesh2.h>
Public Types | |
typedef FastArray< Real > | LodValueArray |
typedef vector< SubMesh * >::type | SubMeshVec |
Public Types inherited from Ogre::Resource | |
enum | LoadingFlags { LF_DEFAULT = 0 , LF_INCLUDE_NON_RELOADABLE = 1 , LF_ONLY_UNREFERENCED = 2 , LF_ONLY_UNREFERENCED_INCLUDE_NON_RELOADABLE = 3 , LF_PRESERVE_STATE = 4 , LF_MARKED_FOR_RELOAD = 8 } |
Enum that allow to choose subset of unloaded/reloaded resources and to adjust reloading behavior. More... | |
enum | LoadingState { LOADSTATE_UNLOADED , LOADSTATE_LOADING , LOADSTATE_LOADED , LOADSTATE_UNLOADING , LOADSTATE_PREPARED , LOADSTATE_PREPARING , LOADSTATE_UNLOADED_MARKED_FOR_RELOAD } |
Enum identifying the loading state of the resource. More... | |
Public Member Functions | |
Mesh (ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, VaoManager *vaoManager, bool isManual=false, ManualResourceLoader *loader=0) | |
Default constructor - used by MeshManager. More... | |
~Mesh () override | |
const LodValueArray * | _getLodValueArray () const |
VaoManager * | _getVaoManager () const |
will return the vao manager that this mesh will use for creating and destroying array objects More... | |
void | _notifySkeleton (v1::SkeletonPtr &pSkel) |
Internal notification, used to tell the Mesh which Skeleton to use without loading it. More... | |
void | _setBoundingSphereRadius (Real radius) |
Manually set the bounding radius. More... | |
void | _setBounds (const Aabb &bounds, bool pad=true) |
Manually set the bounding box for this Mesh. More... | |
void | _setHashForCaches (const uint64 hash[2]) |
Explicitly set a hash for caches. See Mesh::getHashForCaches. More... | |
void | _setLodInfo (unsigned short numLevels) |
Internal methods for loading LOD, do not use. More... | |
void | _setVaoManager (VaoManager *vaoManager) |
will manually set the vao manager the mesh will use when it loads. More... | |
void | _updateBoundsFromVertexBuffers (bool pad=false) |
Automatically update the bounding radius and bounding box for this Mesh. More... | |
void | addBoneAssignment (const VertexBoneAssignment &vertBoneAssign) |
Assigns a vertex to a bone with a given weight, for skeletal animation. More... | |
void | arrangeEfficient (bool halfPos, bool halfTexCoords, bool qTangents) |
Converts this SubMesh to an efficient arrangement. More... | |
void | clearBoneAssignments () |
Removes all bone assignments for this mesh. More... | |
MeshPtr | clone (const String &newName, const String &newGroup=BLANKSTRING, int vertexBufferType=-1, int indexBufferType=-1) |
Makes a copy of this mesh object and gives it a new name. More... | |
void | copy (const MeshPtr &destination, int vertexBufferType=-1, int indexBufferType=-1) |
Will copy this mesh into the destination mesh. More... | |
SubMesh * | createSubMesh (size_t index=~0u) |
Creates a new SubMesh. More... | |
void | dearrangeToInefficient () |
Reverts the effects from arrangeEfficient by converting all 16-bit half float back to 32-bit float; and QTangents to Normal, Tangent + Reflection representation, which are more compatible for doing certain operations vertex operations in the CPU. More... | |
void | destroySubMesh (unsigned index) |
Destroy a SubMesh with the given index. More... | |
const Aabb & | getAabb () const |
Get the axis-aligned bounding box for this mesh. More... | |
Real | getBoundingSphereRadius () const |
Gets the radius of the bounding sphere surrounding this mesh. More... | |
const uint64 * | getHashForCaches () const |
Returns an array of [2] containing a hash for use in caches. More... | |
BufferType | getIndexBufferDefaultType () const |
Gets the usage setting for this meshes index buffers. More... | |
uint16 | getLodIndex (Real value) const |
Retrieves the level of detail index for the given LOD value. More... | |
const String & | getLodStrategyName () const |
Returns the name of the Lod strategy the user lod values have been calibrated for. More... | |
uint16 | getNumLodLevels () const |
Returns the number of levels of detail that this mesh supports. More... | |
unsigned | getNumSubMeshes () const |
Gets the number of sub meshes which comprise this mesh. More... | |
const SkeletonDefPtr & | getSkeleton () const |
Gets a pointer to any linked Skeleton. More... | |
const String & | getSkeletonName () const |
Gets the name of any linked Skeleton. More... | |
SubMesh * | getSubMesh (unsigned index) const |
Gets a pointer to the submesh indicated by the index. More... | |
const SubMeshVec & | getSubMeshes () const |
Gets an iterator over the available submeshes. More... | |
const SubMeshNameMap & | getSubMeshNameMap () const |
Gets a reference to the optional name assignments of the SubMeshes. More... | |
BufferType | getVertexBufferDefaultType () const |
Gets the usage setting for this meshes vertex buffers. More... | |
bool | hasIndependentShadowMappingVaos () const |
Returns true if the shadow mapping buffers do not just reference the real buffers, but are rather their own separate set of optimized geometry. More... | |
bool | hasSkeleton () const |
Returns true if this Mesh has a linked Skeleton. More... | |
bool | hasValidShadowMappingVaos () const |
Returns true if the mesh is ready for rendering with valid shadow mapping Vaos Otherwise prepareForShadowMapping must be called on this mesh. More... | |
void | importV1 (v1::Mesh *mesh, bool halfPos, bool halfTexCoords, bool qTangents, bool halfPose=true) |
Imports a v1 mesh to this mesh, with optional optimization conversions. More... | |
bool | isIndexBufferShadowed () const |
Gets whether or not this meshes index buffers are shadowed. More... | |
bool | isVertexBufferShadowed () const |
Gets whether or not this meshes vertex buffers are shadowed. More... | |
void | nameSubMesh (const String &name, unsigned index) |
Gives a name to a SubMesh. Note, only first 65536 submeshes could be named. More... | |
void | prepareForShadowMapping (bool forceSameBuffers) |
void | removeLodLevels () |
Internal methods for loading LOD, do not use. More... | |
void | setIndexBufferPolicy (BufferType bufferType, bool shadowBuffer=false) |
Sets the policy for the index buffers to be used when loading this Mesh. More... | |
void | setLodStrategyName (const String &name) |
void | setSkeletonName (const String &skelName) |
Calculates. More... | |
void | setVertexBufferPolicy (BufferType bufferType, bool shadowBuffer=false) |
Sets the policy for the vertex buffers to be used when loading this Mesh. More... | |
void | unnameSubMesh (const String &name) |
Removes a name from a SubMesh. More... | |
Public Member Functions inherited from Ogre::Resource | |
Resource (ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual=false, ManualResourceLoader *loader=0) | |
Standard constructor. More... | |
virtual | ~Resource () |
Virtual destructor. More... | |
virtual void | _dirtyState () |
Manually mark the state of this resource as having been changed. More... | |
virtual void | _fireLoadingComplete (bool wasBackgroundLoaded) |
Firing of loading complete event. More... | |
virtual void | _firePreparingComplete (bool wasBackgroundLoaded) |
Firing of preparing complete event. More... | |
virtual void | _fireUnloadingComplete () |
Firing of unloading complete event. More... | |
virtual void | _notifyOrigin (const String &origin) |
Notify this resource of it's origin. More... | |
virtual void | addListener (Listener *lis) |
Register a listener on this resource. More... | |
virtual void | changeGroupOwnership (const String &newGroup) |
Change the resource group ownership of a Resource. More... | |
virtual void | escalateLoading () |
Escalates the loading of a background loaded resource. More... | |
virtual ResourceManager * | getCreator () |
Gets the manager which created this resource. More... | |
virtual const String & | getGroup () const |
Gets the group which this resource is a member of. More... | |
virtual ResourceHandle | getHandle () const |
virtual LoadingState | getLoadingState () const |
Returns the current loading state. More... | |
virtual const String & | getName () const |
Gets resource name. More... | |
virtual const String & | getOrigin () const |
Get the origin of this resource, e.g. More... | |
virtual size_t | getSize () const |
Retrieves info about the size of the resource. More... | |
virtual size_t | getStateCount () const |
Returns the number of times this resource has changed state, which generally means the number of times it has been loaded. More... | |
virtual bool | isBackgroundLoaded () const |
Returns whether this Resource has been earmarked for background loading. More... | |
virtual bool | isLoaded () const |
Returns true if the Resource has been loaded, false otherwise. More... | |
virtual bool | isLoading () const |
Returns whether the resource is currently in the process of background loading. More... | |
virtual bool | isManuallyLoaded () const |
Is this resource manually loaded? More... | |
virtual bool | isPrepared () const |
Returns true if the Resource has been prepared, false otherwise. More... | |
virtual bool | isReloadable () const |
Returns true if the Resource is reloadable, false otherwise. More... | |
virtual void | load (bool backgroundThread=false) |
Loads the resource, if it is not already. More... | |
bool | markForReload () |
virtual void | prepare (bool backgroundThread=false) |
Prepares the resource for load, if it is not already. More... | |
virtual void | reload (LoadingFlags flags=LF_DEFAULT) |
Reloads the resource, if it is already loaded. More... | |
virtual void | removeListener (Listener *lis) |
Remove a listener on this resource. More... | |
virtual void | setBackgroundLoaded (bool bl) |
Tells the resource whether it is background loaded or not. More... | |
virtual void | setManuallyLoaded (bool isManual) |
Set "Is this resource manually loaded?". More... | |
virtual void | setToLoaded () |
Change the Resource loading state to loaded. More... | |
virtual void | touch () |
'Touches' the resource to indicate it has been used. More... | |
virtual void | unload () |
Unloads the resource; this is not permanent, the resource can be reloaded later if required. More... | |
Public Member Functions inherited from Ogre::StringInterface | |
StringInterface () | |
virtual | ~StringInterface () |
Virtual destructor, see Effective C++. More... | |
virtual void | copyParametersTo (StringInterface *dest) const |
Method for copying this object's parameters to another object. More... | |
ParamDictionary * | getParamDictionary () |
Retrieves the parameter dictionary for this class. More... | |
const ParamDictionary * | getParamDictionary () const |
virtual String | getParameter (const String &name) const |
Generic parameter retrieval method. More... | |
const ParameterList & | getParameters () const |
Retrieves a list of parameters valid for this object. More... | |
virtual bool | setParameter (const String &name, const String &value) |
Generic parameter setting method. More... | |
virtual void | setParameterList (const NameValuePairList ¶mList) |
Generic multiple parameter setting method. More... | |
Static Public Attributes | |
static bool | msOptimizeForShadowMapping |
When this bool is false, prepareForShadowMapping will use the same Vaos for both regular and shadow mapping rendering. More... | |
static bool | msUseTimestampAsHash |
If a mesh file didn't save hash information (see Mesh::getHashForCaches) and msUseTimestampAsHash == true; then we use the file last modified timestamp as hash (it's better than nothing). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Ogre::StringInterface | |
static void | cleanupDictionary () |
Cleans up the static 'msDictionary' required to reset Ogre, otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the ResourceManager implementers (e.g. More... | |
Public Attributes inherited from Ogre::Resource | |
OGRE_AUTO_MUTEX | |
Resource holding data about 3D mesh.
typedef FastArray<Real> Ogre::Mesh::LodValueArray |
typedef vector<SubMesh *>::type Ogre::Mesh::SubMeshVec |
Ogre::Mesh::Mesh | ( | ResourceManager * | creator, |
const String & | name, | ||
ResourceHandle | handle, | ||
const String & | group, | ||
VaoManager * | vaoManager, | ||
bool | isManual = false , |
||
ManualResourceLoader * | loader = 0 |
||
) |
Default constructor - used by MeshManager.
|
override |
|
inline |
|
inline |
will return the vao manager that this mesh will use for creating and destroying array objects
void Ogre::Mesh::_notifySkeleton | ( | v1::SkeletonPtr & | pSkel | ) |
Internal notification, used to tell the Mesh which Skeleton to use without loading it.
void Ogre::Mesh::_setBoundingSphereRadius | ( | Real | radius | ) |
Manually set the bounding radius.
void Ogre::Mesh::_setBounds | ( | const Aabb & | bounds, |
bool | pad = true |
||
) |
Manually set the bounding box for this Mesh.
pad | If true, a certain padding will be added to the bounding box to separate it from the mesh |
void Ogre::Mesh::_setHashForCaches | ( | const uint64 | hash[2] | ) |
Explicitly set a hash for caches. See Mesh::getHashForCaches.
void Ogre::Mesh::_setLodInfo | ( | unsigned short | numLevels | ) |
Internal methods for loading LOD, do not use.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
|
inline |
will manually set the vao manager the mesh will use when it loads.
setting this when the mesh is already loaded will cause a crash on unload, use with caution!
void Ogre::Mesh::_updateBoundsFromVertexBuffers | ( | bool | pad = false | ) |
Automatically update the bounding radius and bounding box for this Mesh.
pad | If true, a certain padding will be added to the bounding box to separate it from the mesh |
void Ogre::Mesh::addBoneAssignment | ( | const VertexBoneAssignment & | vertBoneAssign | ) |
Assigns a vertex to a bone with a given weight, for skeletal animation.
void Ogre::Mesh::arrangeEfficient | ( | bool | halfPos, |
bool | halfTexCoords, | ||
bool | qTangents | ||
) |
Converts this SubMesh to an efficient arrangement.
See Mesh::importV1 for an explanation on the parameters.
void Ogre::Mesh::clearBoneAssignments | ( | ) |
MeshPtr Ogre::Mesh::clone | ( | const String & | newName, |
const String & | newGroup = BLANKSTRING , |
||
int | vertexBufferType = -1 , |
||
int | indexBufferType = -1 |
||
) |
Makes a copy of this mesh object and gives it a new name.
newName | The name to give the clone. |
newGroup | Optional name of the new group to assign the clone to; if you leave this blank, the clone will be assigned to the same group as this Mesh. |
vertexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
indexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
void Ogre::Mesh::copy | ( | const MeshPtr & | destination, |
int | vertexBufferType = -1 , |
||
int | indexBufferType = -1 |
||
) |
Will copy this mesh into the destination mesh.
destination | The mesh that will be the destination for the copy of *this |
vertexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
indexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
SubMesh* Ogre::Mesh::createSubMesh | ( | size_t | index = ~0u | ) |
Creates a new SubMesh.
index | Optional param that will insert the submesh at the specified index. This should be less than getNumSubMeshes(), otherwise it indicates the new submesh will simply be appended to the submesh list. |
void Ogre::Mesh::dearrangeToInefficient | ( | ) |
Reverts the effects from arrangeEfficient by converting all 16-bit half float back to 32-bit float; and QTangents to Normal, Tangent + Reflection representation, which are more compatible for doing certain operations vertex operations in the CPU.
void Ogre::Mesh::destroySubMesh | ( | unsigned | index | ) |
const Aabb& Ogre::Mesh::getAabb | ( | ) | const |
Get the axis-aligned bounding box for this mesh.
Real Ogre::Mesh::getBoundingSphereRadius | ( | ) | const |
Gets the radius of the bounding sphere surrounding this mesh.
|
inline |
Returns an array of [2] containing a hash for use in caches.
A value of { 0, 0 } should be treated as not initialized.
How this cache is calculated is unknown and could just be a filesystem timestamp rather than a checksum.
When callers see that: getCacheHash()[i] != savedHash[i]
they should treat as if the mesh has changed and the cache entry became stale
|
inline |
Gets the usage setting for this meshes index buffers.
Retrieves the level of detail index for the given LOD value.
|
inline |
Returns the name of the Lod strategy the user lod values have been calibrated for.
uint16 Ogre::Mesh::getNumLodLevels | ( | ) | const |
Returns the number of levels of detail that this mesh supports.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
unsigned Ogre::Mesh::getNumSubMeshes | ( | ) | const |
Gets the number of sub meshes which comprise this mesh.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
|
inline |
Gets a pointer to any linked Skeleton.
const String& Ogre::Mesh::getSkeletonName | ( | ) | const |
Gets the name of any linked Skeleton.
SubMesh* Ogre::Mesh::getSubMesh | ( | unsigned | index | ) | const |
Gets a pointer to the submesh indicated by the index.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
|
inline |
Gets an iterator over the available submeshes.
|
inline |
Gets a reference to the optional name assignments of the SubMeshes.
|
inline |
Gets the usage setting for this meshes vertex buffers.
bool Ogre::Mesh::hasIndependentShadowMappingVaos | ( | ) | const |
Returns true if the shadow mapping buffers do not just reference the real buffers, but are rather their own separate set of optimized geometry.
|
inline |
Returns true if this Mesh has a linked Skeleton.
bool Ogre::Mesh::hasValidShadowMappingVaos | ( | ) | const |
Returns true if the mesh is ready for rendering with valid shadow mapping Vaos Otherwise prepareForShadowMapping must be called on this mesh.
void Ogre::Mesh::importV1 | ( | v1::Mesh * | mesh, |
bool | halfPos, | ||
bool | halfTexCoords, | ||
bool | qTangents, | ||
bool | halfPose = true |
||
) |
Imports a v1 mesh to this mesh, with optional optimization conversions.
This mesh must be in unloaded state. Resulting mesh would be non-reloadable, use MeshManager::createByImportingV1 to create mesh that will survive device lost event.
mesh | The source v1 mesh to convert from. You can unload or delete this pointer afterwards. |
halfPos | True if you want to convert the position data to VET_HALF4 format. Recommended on desktop to reduce memory and bandwidth requirements. Rarely the extra precision is needed. Unfortuntately on mobile, not all ES2 devices support VET_HALF4. |
halfTexCoords | True if you want to convert the position data to VET_HALF2 or VET_HALF4 format. Same recommendations as halfPos. |
qTangents | True if you want to generate tangent and reflection information (modifying the original v1 mesh) and convert this data to a QTangent, requiring VET_SHORT4_SNORM (8 bytes vs 28 bytes to store normals, tangents and reflection). Needs much less space, trading for more ALU ops in the vertex shader for decoding the QTangent. Highly recommended on both desktop and mobile if you need tangents (i.e. normal mapping). |
halfPose | True if you want the pose buffer to have pixel format PF_FLOAT16_RGBA which uses significantly less memory. Otherwise it is created with pixel format PF_FLOAT32_RGBA. Rarely the extra precision is needed. |
|
inline |
Gets whether or not this meshes index buffers are shadowed.
|
inline |
Gets whether or not this meshes vertex buffers are shadowed.
void Ogre::Mesh::nameSubMesh | ( | const String & | name, |
unsigned | index | ||
) |
Gives a name to a SubMesh. Note, only first 65536 submeshes could be named.
void Ogre::Mesh::prepareForShadowMapping | ( | bool | forceSameBuffers | ) |
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
void Ogre::Mesh::removeLodLevels | ( | ) |
Internal methods for loading LOD, do not use.
Removes all LOD data from this Mesh.
void Ogre::Mesh::setIndexBufferPolicy | ( | BufferType | bufferType, |
bool | shadowBuffer = false |
||
) |
Sets the policy for the index buffers to be used when loading this Mesh.
|
inline |
void Ogre::Mesh::setSkeletonName | ( | const String & | skelName | ) |
Calculates.
skelName | The name of the .skeleton file to use, or an empty string to use no skeleton |
void Ogre::Mesh::setVertexBufferPolicy | ( | BufferType | bufferType, |
bool | shadowBuffer = false |
||
) |
Sets the policy for the vertex buffers to be used when loading this Mesh.
bufferType | The buffer type flags, which by default is BT_IMMUTABLE |
shadowBuffer | If set to true , the vertex buffers will be created with a system memory shadow buffer. You should set this if you want to be able to read from the buffer, because reading from a hardware buffer is a no-no. |
|
static |
When this bool is false, prepareForShadowMapping will use the same Vaos for both regular and shadow mapping rendering.
When it's true, it will calculate an optimized version to speed up shadow map rendering (uses a bit more GPU VRAM). Large meshes can take long to optimize thus it is recommended to perform this offline and save it into the mesh file. It's off by default.
|
static |
If a mesh file didn't save hash information (see Mesh::getHashForCaches) and msUseTimestampAsHash == true; then we use the file last modified timestamp as hash (it's better than nothing).
By default this is disabled since it's often not needed and can't hurt loading times with unnecessary disk access