OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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 "OgrePatchSurface.h"
38 #include "OgreHeaderPrefix.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 
69  MeshPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
70 
71 
74  MeshPtr create (const String& name, const String& group,
75  bool isManual = false, ManualResourceLoader* loader = 0,
76  const NameValuePairList* createParams = 0);
77 
90  ResourceCreateOrRetrieveResult createOrRetrieve(
91  const String& name,
92  const String& group,
93  bool isManual=false, ManualResourceLoader* loader=0,
94  const NameValuePairList* params=0,
97  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
98 
120  MeshPtr prepare( const String& filename, const String& groupName,
123  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
124 
146  MeshPtr load( const String& filename, const String& groupName,
149  bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
150 
151 
165  MeshPtr createManual( const String& name, const String& groupName,
166  ManualResourceLoader* loader = 0);
167 
207  MeshPtr createPlane(
208  const String& name, const String& groupName, const Plane& plane,
209  Real width, Real height,
210  int xsegments = 1, int ysegments = 1,
211  bool normals = true, unsigned short numTexCoordSets = 1,
212  Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
215  bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
216 
217 
268  MeshPtr createCurvedIllusionPlane(
269  const String& name, const String& groupName, const Plane& plane,
270  Real width, Real height, Real curvature,
271  int xsegments = 1, int ysegments = 1,
272  bool normals = true, unsigned short numTexCoordSets = 1,
273  Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
274  const Quaternion& orientation = Quaternion::IDENTITY,
277  bool vertexShadowBuffer = true, bool indexShadowBuffer = true,
278  int ySegmentsToKeep = -1);
279 
321  MeshPtr createCurvedPlane(
322  const String& name, const String& groupName, const Plane& plane,
323  Real width, Real height, Real bow = 0.5f,
324  int xsegments = 1, int ysegments = 1,
325  bool normals = false, unsigned short numTexCoordSets = 1,
326  Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
329  bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
330 
367  PatchMeshPtr createBezierPatch(
368  const String& name, const String& groupName, void* controlPointBuffer,
369  VertexDeclaration *declaration, size_t width, size_t height,
370  size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
371  size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
375  bool vbUseShadow = true, bool ibUseShadow = true);
376 
380  void setPrepareAllMeshesForShadowVolumes(bool enable);
382  bool getPrepareAllMeshesForShadowVolumes(void);
383 
399  static MeshManager& getSingleton(void);
415  static MeshManager* getSingletonPtr(void);
416 
420  Real getBoundsPaddingFactor(void);
421 
424  void setBoundsPaddingFactor(Real paddingFactor);
425 
428  void setListener(MeshSerializerListener *listener);
429 
432  MeshSerializerListener *getListener();
433 
435  void loadResource(Resource* res);
436 
437  protected:
439  Resource* createImpl(const String& name, ResourceHandle handle,
440  const String& group, bool isManual, ManualResourceLoader* loader,
441  const NameValuePairList* createParams);
442 
445  void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight,
446  bool doubleSided = false,
448  bool indexSysMem = false);
449 
450  void createPrefabPlane(void);
451  void createPrefabCube(void);
452  void createPrefabSphere(void);
453 
456  {
459  MBT_CURVED_PLANE
460  };
463  {
471  bool normals;
472  unsigned short numTexCoordSets;
482  };
486 
488  void loadManualPlane(Mesh* pMesh, MeshBuildParams& params);
490  void loadManualCurvedPlane(Mesh* pMesh, MeshBuildParams& params);
492  void loadManualCurvedIllusionPlane(Mesh* pMesh, MeshBuildParams& params);
493 
495 
496  //the factor by which the bounding box of an entity is padded
498 
499  // The listener to pass to serializers
501  };
502 
506 } //namespace
507 
508 #include "OgreHeaderSuffix.h"
509 
510 #endif
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
bool mPrepAllMeshesForShadowVolumes
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
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.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Interface describing a manual resource loader.
Definition: OgreResource.h:498
MeshSerializerListener * mListener
Implementation of a Quaternion, i.e.
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:60
Saved parameters used to (re)build a manual mesh built by this class.
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
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:809
The side from which u goes right and v goes up (as in texture coords)
_StringBase String
Definition: OgreCommon.h:53
Resource holding data about 3D mesh.
Definition: OgreMesh.h:86