# 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __MeshManager_H__
    00030 #define __MeshManager_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreResourceManager.h"
    00035 #include "OgreSingleton.h"
    00036 #include "OgreVector3.h"
    00037 #include "OgreHardwareBuffer.h"
    00038 #include "OgreMesh.h"
    00039 #include "OgrePatchMesh.h"
    00040
    00041 namespace Ogre {
    00042
    00043     class MeshSerializerListener;
    00044
    00052     class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>,
    00053         public ManualResourceLoader
    00054     {
    00055     public:
    00056         MeshManager();
    00057         ~MeshManager();
    00058
    00060         void _initialise(void);
    00061
    00074         ResourceCreateOrRetrieveResult createOrRetrieve(
    00075             const String& name,
    00076             const String& group,
    00077             bool isManual=false, ManualResourceLoader* loader=0,
    00078             const NameValuePairList* params=0,
    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
    00104         MeshPtr prepare( const String& filename, const String& groupName,
    00105             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00106             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00107             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
    00108
    00130         MeshPtr load( const String& filename, const String& groupName,
    00131             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00132             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00133             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
    00134
    00135
    00149         MeshPtr createManual( const String& name, const String& groupName,
    00150             ManualResourceLoader* loader = 0);
    00151
    00191         MeshPtr createPlane(
    00192             const String& name, const String& groupName, const Plane& plane,
    00193             Real width, Real height,
    00194             int xsegments = 1, int ysegments = 1,
    00195             bool normals = true, int numTexCoordSets = 1,
    00196             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00197             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00198             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00199             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
    00200
    00201
    00252         MeshPtr createCurvedIllusionPlane(
    00253             const String& name, const String& groupName, const Plane& plane,
    00254             Real width, Real height, Real curvature,
    00255             int xsegments = 1, int ysegments = 1,
    00256             bool normals = true, int numTexCoordSets = 1,
    00257             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00258             const Quaternion& orientation = Quaternion::IDENTITY,
    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             int ySegmentsToKeep = -1);
    00263
    00305         MeshPtr createCurvedPlane(
    00306             const String& name, const String& groupName, const Plane& plane,
    00307             Real width, Real height, Real bow = 0.5f,
    00308             int xsegments = 1, int ysegments = 1,
    00309             bool normals = false, int numTexCoordSets = 1,
    00310             Real xTile = 1.0f, Real yTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00311             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00312             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00313             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
    00314
    00351         PatchMeshPtr createBezierPatch(
    00352             const String& name, const String& groupName, void* controlPointBuffer,
    00353             VertexDeclaration *declaration, size_t width, size_t height,
    00354             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00355             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00356             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
    00357             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00358             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
    00359             bool vbUseShadow = true, bool ibUseShadow = true);
    00360
    00364         void setPrepareAllMeshesForShadowVolumes(bool enable);
    00366         bool getPrepareAllMeshesForShadowVolumes(void);
    00367
    00383         static MeshManager& getSingleton(void);
    00399         static MeshManager* getSingletonPtr(void);
    00400
    00404         Real getBoundsPaddingFactor(void);
    00405
    00408         void setBoundsPaddingFactor(Real paddingFactor);
    00409
    00412         void setListener(MeshSerializerListener *listener);
    00413
    00416         MeshSerializerListener *getListener();
    00417
    00419         void loadResource(Resource* res);
    00420
    00421     protected:
    00423         Resource* createImpl(const String& name, ResourceHandle handle,
    00424             const String& group, bool isManual, ManualResourceLoader* loader,
    00425             const NameValuePairList* createParams);
    00426
    00429         void tesselate2DMesh(SubMesh* pSub, int meshWidth, int meshHeight,
    00430             bool doubleSided = false,
    00431             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00432             bool indexSysMem = false);
    00433
    00434         void createPrefabPlane(void);
    00435         void createPrefabCube(void);
    00436         void createPrefabSphere(void);
    00437
    00439         enum MeshBuildType
    00440         {
    00441             MBT_PLANE,
    00442             MBT_CURVED_ILLUSION_PLANE,
    00443             MBT_CURVED_PLANE
    00444         };
    00446         struct MeshBuildParams
    00447         {
    00448             MeshBuildType type;
    00449             Plane plane;
    00450             Real width;
    00451             Real height;
    00452             Real curvature;
    00453             int xsegments;
    00454             int ysegments;
    00455             bool normals;
    00456             int numTexCoordSets;
    00457             Real xTile;
    00458             Real yTile;
    00459             Vector3 upVector;
    00460             Quaternion orientation;
    00461             HardwareBuffer::Usage vertexBufferUsage;
    00462             HardwareBuffer::Usage indexBufferUsage;
    00463             bool vertexShadowBuffer;
    00464             bool indexShadowBuffer;
    00465             int ySegmentsToKeep;
    00466         };
    00468         typedef std::map<Resource*, MeshBuildParams> MeshBuildParamsMap;
    00469         MeshBuildParamsMap mMeshBuildParams;
    00470
    00472         void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
    00474         void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
    00476         void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
    00477
    00478         bool mPrepAllMeshesForShadowVolumes;
    00479
    00480         //the factor by which the bounding box of an entity is padded
    00481         Real mBoundsPaddingFactor;
    00482
    00483         // The listener to pass to serializers
    00484         MeshSerializerListener *mListener;
    00485     };
    00486
    00487
    00488 } //namespace
    00489
    00490 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:32:18 2009