OGRE 2.1
Object-Oriented Graphics Rendering Engine
|
Resource holding data about 3D mesh. More...
#include <OgreMesh2.h>
Public Types | |
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 } |
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 } |
Enum identifying the loading state of the resource. More... | |
typedef FastArray< Real > | LodValueArray |
typedef vector< SubMesh * >::type | SubMeshVec |
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. | |
~Mesh () | |
virtual void | _dirtyState () |
Manually mark the state of this resource as having been changed. | |
virtual void | _fireLoadingComplete (bool wasBackgroundLoaded) |
Firing of loading complete event. | |
virtual void | _firePreparingComplete (bool wasBackgroundLoaded) |
Firing of preparing complete event. | |
virtual void | _fireUnloadingComplete (void) |
Firing of unloading complete event. | |
const LodValueArray * | _getLodValueArray (void) const |
VaoManager * | _getVaoManager () const |
will return the vao manager that this mesh will use for creating and destroying array objects | |
virtual void | _notifyOrigin (const String &origin) |
Notify this resource of it's origin. | |
void | _notifySkeleton (v1::SkeletonPtr &pSkel) |
Internal notification, used to tell the Mesh which Skeleton to use without loading it. | |
void | _setBoundingSphereRadius (Real radius) |
Manually set the bounding radius. | |
void | _setBounds (const Aabb &bounds, bool pad=true) |
Manually set the bounding box for this Mesh. | |
void | _setLodInfo (unsigned short numLevels) |
Internal methods for loading LOD, do not use. | |
void | _setVaoManager (VaoManager *vaoManager) |
will manually set the vao manager the mesh will use when it loads. | |
void | _updateBoundsFromVertexBuffers (bool pad=false) |
Automatically update the bounding radius and bounding box for this Mesh. | |
void | addBoneAssignment (const VertexBoneAssignment &vertBoneAssign) |
Assigns a vertex to a bone with a given weight, for skeletal animation. | |
virtual void | addListener (Listener *lis) |
Register a listener on this resource. | |
void | arrangeEfficient (bool halfPos, bool halfTexCoords, bool qTangents) |
Converts this SubMesh to an efficient arrangement. | |
virtual void | changeGroupOwnership (const String &newGroup) |
Change the resource group ownership of a Resource. | |
void | clearBoneAssignments (void) |
Removes all bone assignments for this mesh. | |
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. | |
void | copy (const MeshPtr &destination, int vertexBufferType=-1, int indexBufferType=-1) |
Will copy this mesh into the destination mesh. | |
virtual void | copyParametersTo (StringInterface *dest) const |
Method for copying this object's parameters to another object. | |
SubMesh * | createSubMesh (size_t index=~0u) |
Creates a new SubMesh. | |
void | dearrangeToInefficient (void) |
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 | destroySubMesh (unsigned short index) |
Destroy a SubMesh with the given index. | |
virtual void | escalateLoading () |
Escalates the loading of a background loaded resource. | |
const Aabb & | getAabb (void) const |
Get the axis-aligned bounding box for this mesh. | |
Real | getBoundingSphereRadius (void) const |
Gets the radius of the bounding sphere surrounding this mesh. | |
virtual ResourceManager * | getCreator (void) |
Gets the manager which created this resource. | |
virtual const String & | getGroup (void) const |
Gets the group which this resource is a member of. | |
virtual ResourceHandle | getHandle (void) const |
BufferType | getIndexBufferDefaultType (void) const |
Gets the usage setting for this meshes index buffers. | |
virtual LoadingState | getLoadingState () const |
Returns the current loading state. | |
uint16 | getLodIndex (Real value) const |
Retrieves the level of detail index for the given LOD value. | |
const String & | getLodStrategyName (void) const |
Returns the name of the Lod strategy the user lod values have been calibrated for. | |
virtual const String & | getName (void) const |
Gets resource name. | |
uint16 | getNumLodLevels (void) const |
Returns the number of levels of detail that this mesh supports. | |
unsigned short | getNumSubMeshes (void) const |
Gets the number of sub meshes which comprise this mesh. | |
virtual const String & | getOrigin (void) const |
Get the origin of this resource, e.g. | |
ParamDictionary * | getParamDictionary (void) |
Retrieves the parameter dictionary for this class. | |
const ParamDictionary * | getParamDictionary (void) const |
virtual String | getParameter (const String &name) const |
Generic parameter retrieval method. | |
const ParameterList & | getParameters (void) const |
Retrieves a list of parameters valid for this object. | |
virtual size_t | getSize (void) const |
Retrieves info about the size of the resource. | |
const SkeletonDefPtr & | getSkeleton (void) const |
Gets a pointer to any linked Skeleton. | |
const String & | getSkeletonName (void) const |
Gets the name of any linked Skeleton. | |
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. | |
SubMesh * | getSubMesh (unsigned short index) const |
Gets a pointer to the submesh indicated by the index. | |
const SubMeshVec & | getSubMeshes (void) const |
Gets an iterator over the available submeshes. | |
const SubMeshNameMap & | getSubMeshNameMap (void) const |
Gets a reference to the optional name assignments of the SubMeshes. | |
BufferType | getVertexBufferDefaultType (void) const |
Gets the usage setting for this meshes vertex buffers. | |
bool | hasIndependentShadowMappingVaos (void) 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. | |
bool | hasSkeleton (void) const |
Returns true if this Mesh has a linked Skeleton. | |
bool | hasValidShadowMappingVaos (void) const |
Returns true if the mesh is ready for rendering with valid shadow mapping Vaos Otherwise prepareForShadowMapping must be called on this mesh. | |
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. | |
virtual bool | isBackgroundLoaded (void) const |
Returns whether this Resource has been earmarked for background loading. | |
bool | isIndexBufferShadowed (void) const |
Gets whether or not this meshes index buffers are shadowed. | |
virtual bool | isLoaded (void) const |
Returns true if the Resource has been loaded, false otherwise. | |
virtual bool | isLoading () const |
Returns whether the resource is currently in the process of background loading. | |
virtual bool | isManuallyLoaded (void) const |
Is this resource manually loaded? | |
virtual bool | isPrepared (void) const |
Returns true if the Resource has been prepared, false otherwise. | |
virtual bool | isReloadable (void) const |
Returns true if the Resource is reloadable, false otherwise. | |
bool | isVertexBufferShadowed (void) const |
Gets whether or not this meshes vertex buffers are shadowed. | |
virtual void | load (bool backgroundThread=false) |
Loads the resource, if it is not already. | |
void | nameSubMesh (const String &name, ushort index) |
Gives a name to a SubMesh. | |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete (void *ptr, void *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, const char *file, int line, const char *func) |
operator new, with debug line info | |
void * | operator new (size_t sz, void *ptr) |
placement operator new | |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info | |
virtual void | prepare (bool backgroundThread=false) |
Prepares the resource for load, if it is not already. | |
void | prepareForShadowMapping (bool forceSameBuffers) |
virtual void | reload (LoadingFlags flags=LF_DEFAULT) |
Reloads the resource, if it is already loaded. | |
virtual void | removeListener (Listener *lis) |
Remove a listener on this resource. | |
void | removeLodLevels (void) |
Internal methods for loading LOD, do not use. | |
virtual void | setBackgroundLoaded (bool bl) |
Tells the resource whether it is background loaded or not. | |
void | setIndexBufferPolicy (BufferType bufferType, bool shadowBuffer=false) |
Sets the policy for the index buffers to be used when loading this Mesh. | |
void | setLodStrategyName (const String &name) |
virtual void | setManuallyLoaded (bool isManual) |
Set "Is this resource manually loaded?". | |
virtual bool | setParameter (const String &name, const String &value) |
Generic parameter setting method. | |
virtual void | setParameterList (const NameValuePairList ¶mList) |
Generic multiple parameter setting method. | |
void | setSkeletonName (const String &skelName) |
Calculates. | |
virtual void | setToLoaded (void) |
Change the Resource loading state to loaded. | |
void | setVertexBufferPolicy (BufferType bufferType, bool shadowBuffer=false) |
Sets the policy for the vertex buffers to be used when loading this Mesh. | |
virtual void | touch (void) |
'Touches' the resource to indicate it has been used. | |
virtual void | unload (void) |
Unloads the resource; this is not permanent, the resource can be reloaded later if required. | |
void | unnameSubMesh (const String &name) |
Removes a name from a SubMesh. | |
Static Public Member Functions | |
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. | |
Public Attributes | |
OGRE_AUTO_MUTEX | |
Static Public Attributes | |
static bool | msOptimizeForShadowMapping |
When this bool is false, prepareForShadowMapping will use the same Vaos for both regular and shadow mapping rendering. | |
Friends | |
class | MeshSerializerImpl |
class | SubMesh |
Resource holding data about 3D mesh.
typedef vector<SubMesh*>::type Ogre::Mesh::SubMeshVec |
|
inherited |
Enum that allow to choose subset of unloaded/reloaded resources and to adjust reloading behavior.
|
inherited |
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.
Ogre::Mesh::~Mesh | ( | ) |
Manually mark the state of this resource as having been changed.
Firing of loading complete event.
wasBackgroundLoaded | Whether this was a background loaded event |
Firing of preparing complete event.
wasBackgroundLoaded | Whether this was a background loaded event |
Firing of unloading complete event.
|
inline |
|
inline |
will return the vao manager that this mesh will use for creating and destroying array objects
Notify this resource of it's origin.
void Ogre::Mesh::_notifySkeleton | ( | v1::SkeletonPtr & | pSkel | ) |
Internal notification, used to tell the Mesh which Skeleton to use without loading it.
Manually set the bounding radius.
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 |
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!
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.
Register a listener on this resource.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Converts this SubMesh to an efficient arrangement.
@See Mesh::importV1 for an explanation on the parameters.
Change the resource group ownership of a Resource.
newGroup | Name of the new group |
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.
MaterialManager) initializes.
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. |
|
inlinevirtualinherited |
Method for copying this object's parameters to another object.
dest | Pointer to object to have it's parameters set the same as this object. |
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. |
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.
Escalates the loading of a background loaded resource.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Gets the radius of the bounding sphere surrounding this mesh.
|
inlinevirtualinherited |
Gets the manager which created this resource.
Gets the group which this resource is a member of.
Reimplemented in Ogre::v1::OldSkeletonInstance.
|
inlinevirtualinherited |
Reimplemented in Ogre::v1::OldSkeletonInstance.
|
inline |
Gets the usage setting for this meshes index buffers.
|
inlinevirtualinherited |
Returns the current loading state.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Retrieves the level of detail index for the given LOD value.
Returns the name of the Lod strategy the user lod values have been calibrated for.
Gets resource name.
Reimplemented in Ogre::v1::OldSkeletonInstance.
Referenced by Ogre::GpuProgramUsage::getProgramName().
Returns the number of levels of detail that this mesh supports.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
Gets the number of sub meshes which comprise this mesh.
Referenced by Ogre::Lod0Stripifier::StripLod0Vertices().
Get the origin of this resource, e.g.
a script file name.
|
inlineinherited |
Retrieves the parameter dictionary for this class.
|
inlineinherited |
|
inlinevirtualinherited |
Generic parameter retrieval method.
name | The name of the parameter to get |
|
inherited |
Retrieves a list of parameters valid for this object.
Retrieves info about the size of the resource.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram, and Ogre::CgProgram.
|
inline |
Gets a pointer to any linked Skeleton.
Returns the number of times this resource has changed state, which generally means the number of times it has been loaded.
Objects that build derived data based on the resource can check this value against a copy they kept last time they built this derived data, in order to know whether it needs rebuilding. This is a nice way of monitoring changes without having a tightly-bound callback.
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.
Returns true if the shadow mapping buffers do not just reference the real buffers, but are rather their own separate set of optimized geometry.
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.
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. |
Returns whether this Resource has been earmarked for background loading.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Gets whether or not this meshes index buffers are shadowed.
Returns true if the Resource has been loaded, false otherwise.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Returns whether the resource is currently in the process of background loading.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Is this resource manually loaded?
Returns true if the Resource has been prepared, false otherwise.
Returns true if the Resource is reloadable, false otherwise.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Gets whether or not this meshes vertex buffers are shadowed.
Loads the resource, if it is not already.
backgroundThread | Indicates whether the caller of this method is the background resource loading thread. |
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
placement operator new
|
inlineinherited |
|
inlineinherited |
array operator new, with debug line info
Prepares the resource for load, if it is not already.
One can call prepare() before load(), but this is not required as load() will call prepare() itself, if needed. When OGRE_THREAD_SUPPORT==1 both load() and prepare() are thread-safe. When OGRE_THREAD_SUPPORT==2 however, only prepare() is thread-safe. The reason for this function is to allow a background thread to do some of the loading work, without requiring the whole render system to be thread-safe. The background thread would call prepare() while the main render loop would later call load(). So long as prepare() remains thread-safe, subclasses can arbitrarily split the work of loading a resource between load() and prepare(). It is best to try and do as much work in prepare(), however, since this will leave less work for the main render thread to do and thus increase FPS.
backgroundThread | Whether this is occurring in a background thread |
|
virtualinherited |
Reloads the resource, if it is already loaded.
Reimplemented in Ogre::v1::Mesh, and Ogre::UnifiedHighLevelGpuProgram.
Remove a listener on this resource.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
Internal methods for loading LOD, do not use.
Removes all LOD data from this Mesh.
Tells the resource whether it is background loaded or not.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
void Ogre::Mesh::setIndexBufferPolicy | ( | BufferType | bufferType, |
bool | shadowBuffer = false |
||
) |
Sets the policy for the index buffers to be used when loading this Mesh.
Set "Is this resource manually loaded?".
|
virtualinherited |
Generic parameter setting method.
name | The name of the parameter to set |
value | String value. Must be in the right format for the type specified in the parameter definition. See the StringConverter class for more information. |
|
virtualinherited |
Generic multiple parameter setting method.
paramList | Name/value pair list |
Calculates.
skelName | The name of the .skeleton file to use, or an empty string to use no skeleton |
Change the Resource loading state to loaded.
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. |
'Touches' the resource to indicate it has been used.
Reimplemented in Ogre::Material, Ogre::UnifiedHighLevelGpuProgram, and Ogre::CgProgram.
Referenced by Ogre::Material::touch().
Unloads the resource; this is not permanent, the resource can be reloaded later if required.
Reimplemented in Ogre::UnifiedHighLevelGpuProgram.
|
friend |
|
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.
|
inherited |