Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __MeshManager_H__
00026 #define __MeshManager_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 #include "OgreResourceManager.h"
00031 #include "OgreSingleton.h"
00032 #include "OgreVector3.h"
00033 #include "OgreHardwareBuffer.h"
00034 #include "OgreMesh.h"
00035 #include "OgrePatchMesh.h"
00036 
00037 namespace Ogre {
00038 
00046     class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>, 
00047         public ManualResourceLoader
00048     {
00049     public:
00050         MeshManager();
00051         ~MeshManager();
00052 
00054         void _initialise(void);
00055 
00078         MeshPtr load( const String& filename, const String& groupName,
00079             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00080             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00081             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
00082 
00083 
00097         MeshPtr createManual( const String& name, const String& groupName, 
00098             ManualResourceLoader* loader = 0);
00099 
00139         MeshPtr createPlane(
00140             const String& name, const String& groupName, const Plane& plane,
00141             Real width, Real height,
00142             int xsegments = 1, int ysegments = 1,
00143             bool normals = true, int numTexCoordSets = 1,
00144             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00145             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00146             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00147             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
00148 
00149         
00200         MeshPtr createCurvedIllusionPlane(
00201             const String& name, const String& groupName, const Plane& plane,
00202             Real width, Real height, Real curvature,
00203             int xsegments = 1, int ysegments = 1,
00204             bool normals = true, int numTexCoordSets = 1,
00205             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00206             const Quaternion& orientation = Quaternion::IDENTITY,
00207             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00208             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00209             bool vertexShadowBuffer = true, bool indexShadowBuffer = true, 
00210             int ySegmentsToKeep = -1);
00211 
00253         MeshPtr createCurvedPlane( 
00254             const String& name, const String& groupName, const Plane& plane, 
00255             Real width, Real height, Real bow = 0.5f, 
00256             int xsegments = 1, int ysegments = 1,
00257             bool normals = false, int numTexCoordSets = 1, 
00258             Real xTile = 1.0f, Real yTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
00259             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00260             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00261             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
00262 
00299         PatchMeshPtr createBezierPatch(
00300             const String& name, const String& groupName, void* controlPointBuffer, 
00301             VertexDeclaration *declaration, size_t width, size_t height,
00302             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, 
00303             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
00304             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
00305             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00306             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
00307             bool vbUseShadow = true, bool ibUseShadow = true);
00308         
00312         void setPrepareAllMeshesForShadowVolumes(bool enable);
00314         bool getPrepareAllMeshesForShadowVolumes(void);
00315 
00331         static MeshManager& getSingleton(void);
00347         static MeshManager* getSingletonPtr(void);
00348 
00352         Real getBoundsPaddingFactor(void);
00353     
00356         void setBoundsPaddingFactor(Real paddingFactor);
00357 
00359         void loadResource(Resource* res);
00360 
00361     protected:
00363         Resource* createImpl(const String& name, ResourceHandle handle, 
00364             const String& group, bool isManual, ManualResourceLoader* loader, 
00365             const NameValuePairList* createParams);
00366         
00369         void tesselate2DMesh(SubMesh* pSub, int meshWidth, int meshHeight, 
00370             bool doubleSided = false, 
00371             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
00372             bool indexSysMem = false);
00373 
00374         void createPrefabPlane(void);
00375     
00377         enum MeshBuildType
00378         {
00379             MBT_PLANE,
00380             MBT_CURVED_ILLUSION_PLANE,
00381             MBT_CURVED_PLANE
00382         };
00384         struct MeshBuildParams
00385         {
00386             MeshBuildType type;
00387             Plane plane;
00388             Real width;
00389             Real height;
00390             Real curvature;
00391             int xsegments;
00392             int ysegments;
00393             bool normals;
00394             int numTexCoordSets;
00395             Real xTile;
00396             Real yTile;
00397             Vector3 upVector;
00398             Quaternion orientation;
00399             HardwareBuffer::Usage vertexBufferUsage;
00400             HardwareBuffer::Usage indexBufferUsage;
00401             bool vertexShadowBuffer;
00402             bool indexShadowBuffer;
00403             int ySegmentsToKeep;
00404         };
00406         typedef std::map<Resource*, MeshBuildParams> MeshBuildParamsMap;
00407         MeshBuildParamsMap mMeshBuildParams;
00408 
00410         void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
00412         void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
00414         void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
00415 
00416         bool mPrepAllMeshesForShadowVolumes;
00417     
00418     //the factor by which the bounding box of an entity is padded   
00419     Real mBoundsPaddingFactor;
00420     };
00421 
00422 
00423 } //namespace
00424 
00425 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:44 2006