OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreMeshManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2011 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __MeshManager_H__
29 #define __MeshManager_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreResourceManager.h"
34 #include "OgreSingleton.h"
35 #include "OgreVector3.h"
36 #include "OgreHardwareBuffer.h"
37 #include "OgreMesh.h"
38 #include "OgrePatchMesh.h"
39 
40 namespace Ogre {
41 
42  class MeshSerializerListener;
43 
57  class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>,
59  {
60  public:
61  MeshManager();
62  ~MeshManager();
63 
65  void _initialise(void);
66 
79  ResourceCreateOrRetrieveResult createOrRetrieve(
80  const String& name,
81  const String& group,
82  bool isManual=false, ManualResourceLoader* loader=0,
83  const NameValuePairList* params=0,
86  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
87 
109  MeshPtr prepare( const String& filename, const String& groupName,
112  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
113 
135  MeshPtr load( const String& filename, const String& groupName,
138  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
139 
140 
154  MeshPtr createManual( const String& name, const String& groupName,
155  ManualResourceLoader* loader = 0);
156 
196  MeshPtr createPlane(
197  const String& name, const String& groupName, const Plane& plane,
198  Real width, Real height,
199  int xsegments = 1, int ysegments = 1,
200  bool normals = true, unsigned short numTexCoordSets = 1,
201  Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
204  bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
205 
206 
257  MeshPtr createCurvedIllusionPlane(
258  const String& name, const String& groupName, const Plane& plane,
259  Real width, Real height, Real curvature,
260  int xsegments = 1, int ysegments = 1,
261  bool normals = true, unsigned short numTexCoordSets = 1,
262  Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
263  const Quaternion& orientation = Quaternion::IDENTITY,
266  bool vertexShadowBuffer = true, bool indexShadowBuffer = true,
267  int ySegmentsToKeep = -1);
268 
310  MeshPtr createCurvedPlane(
311  const String& name, const String& groupName, const Plane& plane,
312  Real width, Real height, Real bow = 0.5f,
313  int xsegments = 1, int ysegments = 1,
314  bool normals = false, unsigned short numTexCoordSets = 1,
315  Real xTile = 1.0f, Real yTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
318  bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
319 
356  PatchMeshPtr createBezierPatch(
357  const String& name, const String& groupName, void* controlPointBuffer,
358  VertexDeclaration *declaration, size_t width, size_t height,
359  size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
360  size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
364  bool vbUseShadow = true, bool ibUseShadow = true);
365 
369  void setPrepareAllMeshesForShadowVolumes(bool enable);
371  bool getPrepareAllMeshesForShadowVolumes(void);
372 
388  static MeshManager& getSingleton(void);
404  static MeshManager* getSingletonPtr(void);
405 
409  Real getBoundsPaddingFactor(void);
410 
413  void setBoundsPaddingFactor(Real paddingFactor);
414 
417  void setListener(MeshSerializerListener *listener);
418 
421  MeshSerializerListener *getListener();
422 
424  void loadResource(Resource* res);
425 
426  protected:
428  Resource* createImpl(const String& name, ResourceHandle handle,
429  const String& group, bool isManual, ManualResourceLoader* loader,
430  const NameValuePairList* createParams);
431 
434  void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight,
435  bool doubleSided = false,
437  bool indexSysMem = false);
438 
439  void createPrefabPlane(void);
440  void createPrefabCube(void);
441  void createPrefabSphere(void);
442 
445  {
448  MBT_CURVED_PLANE
449  };
452  {
460  bool normals;
461  unsigned short numTexCoordSets;
471  };
475 
477  void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
479  void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
481  void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
482 
484 
485  //the factor by which the bounding box of an entity is padded
487 
488  // The listener to pass to serializers
490  };
491 
495 } //namespace
496 
497 #endif
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:203
bool mPrepAllMeshesForShadowVolumes
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:524
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Combination of HBU_STATIC and HBU_WRITE_ONLY.
Interface describing a manual resource loader.
Definition: OgreResource.h:512
MeshSerializerListener * mListener
Implementation of a Quaternion, i.e.
Specialisation of SharedPtr to allow SharedPtr to be assigned to PatchMeshPtr.
Definition: OgrePatchMesh.h:86
MeshBuildType
Enum identifying the types of manual mesh built by this manager.
HardwareBuffer::Usage vertexBufferUsage
static const Quaternion IDENTITY
map< Resource *, MeshBuildParams >::type MeshBuildParamsMap
Map from resource pointer to parameter set.
MeshBuildParamsMap mMeshBuildParams
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Usage
Enums describing buffer usage; not mutually exclusive.
HardwareBuffer::Usage indexBufferUsage
Defines a part of a complete mesh.
Definition: OgreSubMesh.h:62
Saved parameters used to (re)build a manual mesh built by this class.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
Handles the management of mesh resources.
Defines a generic resource handler.
static const Vector3 UNIT_Y
Definition: OgreVector3.h:776
The side from which u goes right and v goes up (as in texture coords)
_StringBase String
Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr.
Definition: OgreMesh.h:894