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 00297 PatchMeshPtr createBezierPatch( 00298 const String& name, const String& groupName, void* controlPointBuffer, 00299 VertexDeclaration *declaration, size_t width, size_t height, 00300 size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, 00301 size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, 00302 PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT, 00303 HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 00304 HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, 00305 bool vbUseShadow = true, bool ibUseShadow = true); 00306 00310 void setPrepareAllMeshesForShadowVolumes(bool enable); 00312 bool getPrepareAllMeshesForShadowVolumes(void); 00313 00329 static MeshManager& getSingleton(void); 00345 static MeshManager* getSingletonPtr(void); 00346 00350 Real getBoundsPaddingFactor(void); 00351 00354 void setBoundsPaddingFactor(Real paddingFactor); 00355 00357 void loadResource(Resource* res); 00358 00359 protected: 00361 Resource* createImpl(const String& name, ResourceHandle handle, 00362 const String& group, bool isManual, ManualResourceLoader* loader, 00363 const NameValuePairList* createParams); 00364 00367 void tesselate2DMesh(SubMesh* pSub, int meshWidth, int meshHeight, 00368 bool doubleSided = false, 00369 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 00370 bool indexSysMem = false); 00371 00372 void createPrefabPlane(void); 00373 00375 enum MeshBuildType 00376 { 00377 MBT_PLANE, 00378 MBT_CURVED_ILLUSION_PLANE, 00379 MBT_CURVED_PLANE 00380 }; 00382 struct MeshBuildParams 00383 { 00384 MeshBuildType type; 00385 Plane plane; 00386 Real width; 00387 Real height; 00388 Real curvature; 00389 int xsegments; 00390 int ysegments; 00391 bool normals; 00392 int numTexCoordSets; 00393 Real xTile; 00394 Real yTile; 00395 Vector3 upVector; 00396 Quaternion orientation; 00397 HardwareBuffer::Usage vertexBufferUsage; 00398 HardwareBuffer::Usage indexBufferUsage; 00399 bool vertexShadowBuffer; 00400 bool indexShadowBuffer; 00401 int ySegmentsToKeep; 00402 }; 00404 typedef std::map<Resource*, MeshBuildParams> MeshBuildParamsMap; 00405 MeshBuildParamsMap mMeshBuildParams; 00406 00408 void loadManualPlane(Mesh* pMesh, MeshBuildParams& params); 00410 void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params); 00412 void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params); 00413 00414 bool mPrepAllMeshesForShadowVolumes; 00415 00416 //the factor by which the bounding box of an entity is padded 00417 Real mBoundsPaddingFactor; 00418 }; 00419 00420 00421 } //namespace 00422 00423 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:18 2005