OgreMeshManager.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __MeshManager_H__
#define __MeshManager_H__
#include "OgrePrerequisites.h"
#include "OgreResourceManager.h"
#include "OgreSingleton.h"
#include "OgreVector3.h"
#include "OgreHardwareBuffer.h"
#include "OgreMesh.h"
#include "OgrePatchMesh.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class MeshSerializerListener;
class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>,
public ManualResourceLoader
{
public:
MeshManager();
~MeshManager();
void _initialise(void);
MeshPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
MeshPtr create (const String& name, const String& group,
bool isManual = false, ManualResourceLoader* loader = 0,
const NameValuePairList* createParams = 0);
ResourceCreateOrRetrieveResult createOrRetrieve(
const String& name,
const String& group,
bool isManual=false, ManualResourceLoader* loader=0,
const NameValuePairList* params=0,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
MeshPtr prepare( const String& filename, const String& groupName,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
MeshPtr load( const String& filename, const String& groupName,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
MeshPtr createManual( const String& name, const String& groupName,
ManualResourceLoader* loader = 0);
MeshPtr createPlane(
const String& name, const String& groupName, const Plane& plane,
Real width, Real height,
int xsegments = 1, int ysegments = 1,
bool normals = true, unsigned short numTexCoordSets = 1,
Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
MeshPtr createCurvedIllusionPlane(
const String& name, const String& groupName, const Plane& plane,
Real width, Real height, Real curvature,
int xsegments = 1, int ysegments = 1,
bool normals = true, unsigned short numTexCoordSets = 1,
Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
const Quaternion& orientation = Quaternion::IDENTITY,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexShadowBuffer = true, bool indexShadowBuffer = true,
int ySegmentsToKeep = -1);
MeshPtr createCurvedPlane(
const String& name, const String& groupName, const Plane& plane,
Real width, Real height, Real bow = 0.5f,
int xsegments = 1, int ysegments = 1,
bool normals = false, unsigned short numTexCoordSets = 1,
Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
PatchMeshPtr createBezierPatch(
const String& name, const String& groupName, void* controlPointBuffer,
VertexDeclaration *declaration, size_t width, size_t height,
size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
bool vbUseShadow = true, bool ibUseShadow = true);
void setPrepareAllMeshesForShadowVolumes(bool enable);
bool getPrepareAllMeshesForShadowVolumes(void);
static MeshManager& getSingleton(void);
static MeshManager* getSingletonPtr(void);
Real getBoundsPaddingFactor(void);
void setBoundsPaddingFactor(Real paddingFactor);
void setListener(MeshSerializerListener *listener);
MeshSerializerListener *getListener();
void loadResource(Resource* res);
protected:
Resource* createImpl(const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader,
const NameValuePairList* createParams);
void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight,
bool doubleSided = false,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool indexSysMem = false);
void createPrefabPlane(void);
void createPrefabCube(void);
void createPrefabSphere(void);
enum MeshBuildType
{
MBT_PLANE,
MBT_CURVED_ILLUSION_PLANE,
MBT_CURVED_PLANE
};
struct MeshBuildParams
{
MeshBuildType type;
Plane plane;
Real width;
Real height;
Real curvature;
int xsegments;
int ysegments;
bool normals;
unsigned short numTexCoordSets;
Real xTile;
Real yTile;
Vector3 upVector;
Quaternion orientation;
HardwareBuffer::Usage vertexBufferUsage;
HardwareBuffer::Usage indexBufferUsage;
bool vertexShadowBuffer;
bool indexShadowBuffer;
int ySegmentsToKeep;
};
typedef map<Resource*, MeshBuildParams>::type MeshBuildParamsMap;
MeshBuildParamsMap mMeshBuildParams;
void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
bool mPrepAllMeshesForShadowVolumes;
//the factor by which the bounding box of an entity is padded
Real mBoundsPaddingFactor;
// The listener to pass to serializers
MeshSerializerListener *mListener;
};
} //namespace
#include "OgreHeaderSuffix.h"
#endif
Ogre::ResourceManager::ResourceCreateOrRetrieveResult
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Definition: OgreResourceManager.h:152
Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY
Combination of HBU_STATIC and HBU_WRITE_ONLY.
Definition: OgreHardwareBuffer.h:108
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::MeshSerializerListener
Definition: OgreMeshSerializer.h:192
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::PatchSurface::AUTO_LEVEL
Definition: OgrePatchSurface.h:68
Ogre::MeshManager::MeshBuildParams::normals
bool normals
Definition: OgreMeshManager.h:472
OgreMesh.h
Ogre::MeshManager::MeshBuildParams::indexBufferUsage
HardwareBuffer::Usage indexBufferUsage
Definition: OgreMeshManager.h:479
Ogre::MeshManager::MeshBuildParams::orientation
Quaternion orientation
Definition: OgreMeshManager.h:477
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition: OgreResourceGroupManager.h:270
Ogre::PatchSurface::VS_FRONT
The side from which u goes right and v goes up (as in texture coords)
Definition: OgrePatchSurface.h:73
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::MeshManager::MeshBuildParams::vertexShadowBuffer
bool vertexShadowBuffer
Definition: OgreMeshManager.h:480
Ogre::MeshManager::MeshBuildParams::yTile
Real yTile
Definition: OgreMeshManager.h:475
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::MeshManager::MeshBuildParamsMap
map< Resource *, MeshBuildParams >::type MeshBuildParamsMap
Map from resource pointer to parameter set.
Definition: OgreMeshManager.h:485
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Ogre::SubMesh
Defines a part of a complete mesh.
Definition: OgreSubMesh.h:62
Ogre::MeshManager::mListener
MeshSerializerListener * mListener
Definition: OgreMeshManager.h:501
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::MeshManager::MeshBuildType
MeshBuildType
Enum identifying the types of manual mesh built by this manager.
Definition: OgreMeshManager.h:456
Ogre::MeshManager::MeshBuildParams::ysegments
int ysegments
Definition: OgreMeshManager.h:471
OgreSingleton.h
Ogre::VertexDeclaration
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
Definition: OgreHardwareVertexBuffer.h:337
OgrePrerequisites.h
Ogre::MeshManager::MBT_PLANE
Definition: OgreMeshManager.h:458
Ogre::MeshManager::mPrepAllMeshesForShadowVolumes
bool mPrepAllMeshesForShadowVolumes
Definition: OgreMeshManager.h:495
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
Definition: OgreHardwareBuffer.h:114
Ogre::MeshManager::MeshBuildParams::vertexBufferUsage
HardwareBuffer::Usage vertexBufferUsage
Definition: OgreMeshManager.h:478
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::MeshManager::MeshBuildParams::width
Real width
Definition: OgreMeshManager.h:467
Ogre::Mesh
Resource holding data about 3D mesh.
Definition: OgreMesh.h:93
Ogre::HardwareBuffer::Usage
Usage
Enums describing buffer usage; not mutually exclusive.
Definition: OgreHardwareBuffer.h:79
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
OgreResourceManager.h
Ogre::MeshManager::MBT_CURVED_ILLUSION_PLANE
Definition: OgreMeshManager.h:459
Ogre::MeshManager::MeshBuildParams::type
MeshBuildType type
Definition: OgreMeshManager.h:465
Ogre::Vector3::UNIT_Y
static const Vector3 UNIT_Y
Definition: OgreVector3.h:802
OgreHeaderSuffix.h
Ogre::MeshManager
Handles the management of mesh resources.
Definition: OgreMeshManager.h:58
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::MeshManager::MeshBuildParams::plane
Plane plane
Definition: OgreMeshManager.h:466
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::MeshManager::MeshBuildParams::curvature
Real curvature
Definition: OgreMeshManager.h:469
Ogre::MeshManager::MeshBuildParams
Saved parameters used to (re)build a manual mesh built by this class.
Definition: OgreMeshManager.h:463
OgreHardwareBuffer.h
Ogre::SharedPtr< Mesh >
Ogre::MeshManager::MeshBuildParams::height
Real height
Definition: OgreMeshManager.h:468
OgreHeaderPrefix.h
Ogre::Singleton
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Ogre::PatchSurface::VisibleSide
VisibleSide
Definition: OgrePatchSurface.h:71
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::MeshManager::MeshBuildParams::ySegmentsToKeep
int ySegmentsToKeep
Definition: OgreMeshManager.h:482
Ogre::Quaternion::IDENTITY
static const Quaternion IDENTITY
Definition: OgreQuaternion.h:301
Ogre::MeshManager::MeshBuildParams::xsegments
int xsegments
Definition: OgreMeshManager.h:470
Ogre::MeshManager::mBoundsPaddingFactor
Real mBoundsPaddingFactor
Definition: OgreMeshManager.h:498
Ogre::MeshManager::mMeshBuildParams
MeshBuildParamsMap mMeshBuildParams
Definition: OgreMeshManager.h:486
Ogre::MeshManager::MeshBuildParams::numTexCoordSets
unsigned short numTexCoordSets
Definition: OgreMeshManager.h:473
Ogre::MeshManager::MeshBuildParams::upVector
Vector3 upVector
Definition: OgreMeshManager.h:476
Ogre::MeshManager::MeshBuildParams::indexShadowBuffer
bool indexShadowBuffer
Definition: OgreMeshManager.h:481
OgrePatchMesh.h
Ogre::MeshManager::MeshBuildParams::xTile
Real xTile
Definition: OgreMeshManager.h:474

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.