OGRE: OgreMeshManager.h Source File - OGRE Documentation

# 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-2009 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
    00040 namespace Ogre {
    00041
    00042     class MeshSerializerListener;
    00043
    00057     class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>,
    00058         public ManualResourceLoader
    00059     {
    00060     public:
    00061         MeshManager();
    00062         ~MeshManager();
    00063
    00065         void _initialise(void);
    00066
    00079         ResourceCreateOrRetrieveResult createOrRetrieve(
    00080             const String& name,
    00081             const String& group,
    00082             bool isManual=false, ManualResourceLoader* loader=0,
    00083             const NameValuePairList* params=0,
    00084             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00085             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00086             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
    00087
    00109         MeshPtr prepare( const String& filename, const String& groupName,
    00110             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00111             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00112             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
    00113
    00135         MeshPtr load( const String& filename, const String& groupName,
    00136             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00137             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00138             bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
    00139
    00140
    00154         MeshPtr createManual( const String& name, const String& groupName,
    00155             ManualResourceLoader* loader = 0);
    00156
    00196         MeshPtr createPlane(
    00197             const String& name, const String& groupName, const Plane& plane,
    00198             Real width, Real height,
    00199             int xsegments = 1, int ysegments = 1,
    00200             bool normals = true, unsigned short numTexCoordSets = 1,
    00201             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00202             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00203             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00204             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
    00205
    00206
    00257         MeshPtr createCurvedIllusionPlane(
    00258             const String& name, const String& groupName, const Plane& plane,
    00259             Real width, Real height, Real curvature,
    00260             int xsegments = 1, int ysegments = 1,
    00261             bool normals = true, unsigned short numTexCoordSets = 1,
    00262             Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00263             const Quaternion& orientation = Quaternion::IDENTITY,
    00264             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00265             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00266             bool vertexShadowBuffer = true, bool indexShadowBuffer = true,
    00267             int ySegmentsToKeep = -1);
    00268
    00310         MeshPtr createCurvedPlane(
    00311             const String& name, const String& groupName, const Plane& plane,
    00312             Real width, Real height, Real bow = 0.5f,
    00313             int xsegments = 1, int ysegments = 1,
    00314             bool normals = false, unsigned short numTexCoordSets = 1,
    00315             Real xTile = 1.0f, Real yTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
    00316             HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00317             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00318             bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
    00319
    00356         PatchMeshPtr createBezierPatch(
    00357             const String& name, const String& groupName, void* controlPointBuffer,
    00358             VertexDeclaration *declaration, size_t width, size_t height,
    00359             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00360             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00361             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
    00362             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00363             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
    00364             bool vbUseShadow = true, bool ibUseShadow = true);
    00365
    00369         void setPrepareAllMeshesForShadowVolumes(bool enable);
    00371         bool getPrepareAllMeshesForShadowVolumes(void);
    00372
    00388         static MeshManager& getSingleton(void);
    00404         static MeshManager* getSingletonPtr(void);
    00405
    00409         Real getBoundsPaddingFactor(void);
    00410
    00413         void setBoundsPaddingFactor(Real paddingFactor);
    00414
    00417         void setListener(MeshSerializerListener *listener);
    00418
    00421         MeshSerializerListener *getListener();
    00422
    00424         void loadResource(Resource* res);
    00425
    00426     protected:
    00428         Resource* createImpl(const String& name, ResourceHandle handle,
    00429             const String& group, bool isManual, ManualResourceLoader* loader,
    00430             const NameValuePairList* createParams);
    00431
    00434         void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight,
    00435             bool doubleSided = false,
    00436             HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00437             bool indexSysMem = false);
    00438
    00439         void createPrefabPlane(void);
    00440         void createPrefabCube(void);
    00441         void createPrefabSphere(void);
    00442
    00444         enum MeshBuildType
    00445         {
    00446             MBT_PLANE,
    00447             MBT_CURVED_ILLUSION_PLANE,
    00448             MBT_CURVED_PLANE
    00449         };
    00451         struct MeshBuildParams
    00452         {
    00453             MeshBuildType type;
    00454             Plane plane;
    00455             Real width;
    00456             Real height;
    00457             Real curvature;
    00458             int xsegments;
    00459             int ysegments;
    00460             bool normals;
    00461             unsigned short numTexCoordSets;
    00462             Real xTile;
    00463             Real yTile;
    00464             Vector3 upVector;
    00465             Quaternion orientation;
    00466             HardwareBuffer::Usage vertexBufferUsage;
    00467             HardwareBuffer::Usage indexBufferUsage;
    00468             bool vertexShadowBuffer;
    00469             bool indexShadowBuffer;
    00470             int ySegmentsToKeep;
    00471         };
    00473         typedef map<Resource*, MeshBuildParams>::type MeshBuildParamsMap;
    00474         MeshBuildParamsMap mMeshBuildParams;
    00475
    00477         void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
    00479         void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
    00481         void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
    00482
    00483         bool mPrepAllMeshesForShadowVolumes;
    00484
    00485         //the factor by which the bounding box of an entity is padded
    00486         Real mBoundsPaddingFactor;
    00487
    00488         // The listener to pass to serializers
    00489         MeshSerializerListener *mListener;
    00490     };
    00491
    00495 } //namespace
    00496
    00497 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52