OgreMeshManager.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __MeshManager_H__
00029 #define __MeshManager_H__
00030 
00031 #include "OgrePrerequisites.h"
00032 
00033 #include "OgreResourceManager.h"
00034 #include "OgreSingleton.h"
00035 #include "OgreVector3.h"
00036 #include "OgreHardwareBuffer.h"
00037 #include "OgreMesh.h"
00038 #include "OgrePatchMesh.h"
00039 #include "OgreHeaderPrefix.h"
00040 
00041 namespace Ogre {
00042 
00043     class MeshSerializerListener;
00044 
00058     class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>, 
00059         public ManualResourceLoader
00060     {
00061     public:
00062         MeshManager();
00063         ~MeshManager();
00064 
00066         void _initialise(void);
00067 
00070         MeshPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
00071 
00072 
00075         MeshPtr create (const String& name, const String& group,
00076                             bool isManual = false, ManualResourceLoader* loader = 0,
00077                             const NameValuePairList* createParams = 0);
00078 
00091         ResourceCreateOrRetrieveResult createOrRetrieve(
00092             const String& name,
00093             const String& group,
00094             bool isManual=false, ManualResourceLoader* loader=0,
00095             const NameValuePairList* params=0,
00096             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00097             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00098             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
00099 
00121         MeshPtr prepare( const String& filename, const String& groupName,
00122             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00123             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00124             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
00125 
00147         MeshPtr load( const String& filename, const String& groupName,
00148             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00149             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00150             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
00151 
00152 
00166         MeshPtr createManual( const String& name, const String& groupName, 
00167             ManualResourceLoader* loader = 0);
00168 
00208         MeshPtr createPlane(
00209             const String& name, const String& groupName, const Plane& plane,
00210             Real width, Real height,
00211             int xsegments = 1, int ysegments = 1,
00212             bool normals = true, unsigned short numTexCoordSets = 1,
00213             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00214             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00215             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00216             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
00217 
00218         
00269         MeshPtr createCurvedIllusionPlane(
00270             const String& name, const String& groupName, const Plane& plane,
00271             Real width, Real height, Real curvature,
00272             int xsegments = 1, int ysegments = 1,
00273             bool normals = true, unsigned short numTexCoordSets = 1,
00274             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00275             const Quaternion& orientation = Quaternion::IDENTITY,
00276             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00277             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00278             bool vertexShadowBuffer = true, bool indexShadowBuffer = true, 
00279             int ySegmentsToKeep = -1);
00280 
00322         MeshPtr createCurvedPlane( 
00323             const String& name, const String& groupName, const Plane& plane, 
00324             Real width, Real height, Real bow = 0.5f, 
00325             int xsegments = 1, int ysegments = 1,
00326             bool normals = false, unsigned short numTexCoordSets = 1, 
00327             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00328             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00329             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00330             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
00331 
00368         PatchMeshPtr createBezierPatch(
00369             const String& name, const String& groupName, void* controlPointBuffer, 
00370             VertexDeclaration *declaration, size_t width, size_t height,
00371             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, 
00372             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
00373             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
00374             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00375             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
00376             bool vbUseShadow = true, bool ibUseShadow = true);
00377         
00381         void setPrepareAllMeshesForShadowVolumes(bool enable);
00383         bool getPrepareAllMeshesForShadowVolumes(void);
00384 
00400         static MeshManager& getSingleton(void);
00416         static MeshManager* getSingletonPtr(void);
00417 
00421         Real getBoundsPaddingFactor(void);
00422     
00425         void setBoundsPaddingFactor(Real paddingFactor);
00426 
00429         void setListener(MeshSerializerListener *listener);
00430         
00433         MeshSerializerListener *getListener();
00434 
00436         void loadResource(Resource* res);
00437 
00438     protected:
00440         Resource* createImpl(const String& name, ResourceHandle handle, 
00441             const String& group, bool isManual, ManualResourceLoader* loader, 
00442             const NameValuePairList* createParams);
00443         
00446         void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight, 
00447             bool doubleSided = false, 
00448             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00449             bool indexSysMem = false);
00450 
00451         void createPrefabPlane(void);
00452         void createPrefabCube(void);
00453         void createPrefabSphere(void);
00454     
00456         enum MeshBuildType
00457         {
00458             MBT_PLANE,
00459             MBT_CURVED_ILLUSION_PLANE,
00460             MBT_CURVED_PLANE
00461         };
00463         struct MeshBuildParams
00464         {
00465             MeshBuildType type;
00466             Plane plane;
00467             Real width;
00468             Real height;
00469             Real curvature;
00470             int xsegments;
00471             int ysegments;
00472             bool normals;
00473             unsigned short numTexCoordSets;
00474             Real xTile;
00475             Real yTile;
00476             Vector3 upVector;
00477             Quaternion orientation;
00478             HardwareBuffer::Usage vertexBufferUsage;
00479             HardwareBuffer::Usage indexBufferUsage;
00480             bool vertexShadowBuffer;
00481             bool indexShadowBuffer;
00482             int ySegmentsToKeep;
00483         };
00485         typedef map<Resource*, MeshBuildParams>::type MeshBuildParamsMap;
00486         MeshBuildParamsMap mMeshBuildParams;
00487 
00489         void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
00491         void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
00493         void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
00494 
00495         bool mPrepAllMeshesForShadowVolumes;
00496     
00497         //the factor by which the bounding box of an entity is padded   
00498         Real mBoundsPaddingFactor;
00499 
00500         // The listener to pass to serializers
00501         MeshSerializerListener *mListener;
00502     };
00503 
00507 } //namespace
00508 
00509 #include "OgreHeaderSuffix.h"
00510 
00511 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:44