OGRE  1.9.0
OgreMeshManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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#include "OgreHeaderPrefix.h"
40
41namespace Ogre {
42
43 class MeshSerializerListener;
44
58 class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>,
60 {
61 public:
64
66 void _initialise(void);
67
70 MeshPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
71
72
75 MeshPtr create (const String& name, const String& group,
76 bool isManual = false, ManualResourceLoader* loader = 0,
78
92 const String& name,
93 const String& group,
94 bool isManual=false, ManualResourceLoader* loader=0,
96 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
97 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
98 bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
99
121 MeshPtr prepare( const String& filename, const String& groupName,
122 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
123 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
124 bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
125
147 MeshPtr load( const String& filename, const String& groupName,
148 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
149 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
150 bool vertexBufferShadowed = true, bool indexBufferShadowed = true);
151
152
166 MeshPtr createManual( const String& name, const String& groupName,
167 ManualResourceLoader* loader = 0);
168
209 const String& name, const String& groupName, const Plane& plane,
210 Real width, Real height,
211 int xsegments = 1, int ysegments = 1,
212 bool normals = true, unsigned short numTexCoordSets = 1,
213 Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
214 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
215 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
216 bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
217
218
270 const String& name, const String& groupName, const Plane& plane,
271 Real width, Real height, Real curvature,
272 int xsegments = 1, int ysegments = 1,
273 bool normals = true, unsigned short numTexCoordSets = 1,
274 Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
275 const Quaternion& orientation = Quaternion::IDENTITY,
276 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
277 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
278 bool vertexShadowBuffer = true, bool indexShadowBuffer = true,
279 int ySegmentsToKeep = -1);
280
323 const String& name, const String& groupName, const Plane& plane,
324 Real width, Real height, Real bow = 0.5f,
325 int xsegments = 1, int ysegments = 1,
326 bool normals = false, unsigned short numTexCoordSets = 1,
327 Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
328 HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
329 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
330 bool vertexShadowBuffer = true, bool indexShadowBuffer = true);
331
369 const String& name, const String& groupName, void* controlPointBuffer,
370 VertexDeclaration *declaration, size_t width, size_t height,
371 size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
372 size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
373 PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
374 HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
375 HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
376 bool vbUseShadow = true, bool ibUseShadow = true);
377
384
417
422
426
430
434
437
438 protected:
441 const String& group, bool isManual, ManualResourceLoader* loader,
443
446 void tesselate2DMesh(SubMesh* pSub, unsigned short meshWidth, unsigned short meshHeight,
447 bool doubleSided = false,
448 HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
449 bool indexSysMem = false);
450
454
457 {
460 MBT_CURVED_PLANE
461 };
464 {
473 unsigned short numTexCoordSets;
483 };
487
494
496
497 //the factor by which the bounding box of an entity is padded
499
500 // The listener to pass to serializers
502 };
503
507} //namespace
508
509#include "OgreHeaderSuffix.h"
510
511#endif
#define _OgreExport
Usage
Enums describing buffer usage; not mutually exclusive.
Interface describing a manual resource loader.
Handles the management of mesh resources.
MeshPtr load(const String &filename, const String &groupName, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexBufferShadowed=true, bool indexBufferShadowed=true)
Loads a mesh from a file, making it immediately available for use.
void setBoundsPaddingFactor(Real paddingFactor)
Sets the factor by which the bounding box of an entity is padded.
MeshPtr createPlane(const String &name, const String &groupName, const Plane &plane, Real width, Real height, int xsegments=1, int ysegments=1, bool normals=true, unsigned short numTexCoordSets=1, Real uTile=1.0f, Real vTile=1.0f, const Vector3 &upVector=Vector3::UNIT_Y, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexShadowBuffer=true, bool indexShadowBuffer=true)
Creates a basic plane, by default majoring on the x/y axes facing positive Z.
MeshSerializerListener * getListener()
Gets the listener used to control mesh loading through the serializer.
void loadManualCurvedIllusionPlane(Mesh *pMesh, MeshBuildParams &params)
Utility method for manual loading a curved illusion plane.
void loadManualCurvedPlane(Mesh *pMesh, MeshBuildParams &params)
Utility method for manual loading a curved plane.
Resource * createImpl(const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, const NameValuePairList *createParams)
Create a new resource instance compatible with this manager (no custom parameters are populated at th...
map< Resource *, MeshBuildParams >::type MeshBuildParamsMap
Map from resource pointer to parameter set.
MeshPtr prepare(const String &filename, const String &groupName, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexBufferShadowed=true, bool indexBufferShadowed=true)
Prepares a mesh for loading from a file.
MeshSerializerListener * mListener
MeshPtr createCurvedPlane(const String &name, const String &groupName, const Plane &plane, Real width, Real height, Real bow=0.5f, int xsegments=1, int ysegments=1, bool normals=false, unsigned short numTexCoordSets=1, Real uTile=1.0f, Real vTile=1.0f, const Vector3 &upVector=Vector3::UNIT_Y, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexShadowBuffer=true, bool indexShadowBuffer=true)
Creates a genuinely curved plane, by default majoring on the x/y axes facing positive Z.
bool getPrepareAllMeshesForShadowVolumes(void)
Retrieves whether all Meshes should prepare themselves for shadow volumes.
ResourceCreateOrRetrieveResult createOrRetrieve(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *params=0, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexBufferShadowed=true, bool indexBufferShadowed=true)
Create a new mesh, or retrieve an existing one with the same name if it already exists.
Real getBoundsPaddingFactor(void)
Gets the factor by which the bounding box of an entity is padded.
static MeshManager & getSingleton(void)
Override standard Singleton retrieval.
static MeshManager * getSingletonPtr(void)
Override standard Singleton retrieval.
void createPrefabSphere(void)
void tesselate2DMesh(SubMesh *pSub, unsigned short meshWidth, unsigned short meshHeight, bool doubleSided=false, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool indexSysMem=false)
Utility method for tessellating 2D meshes.
void loadManualPlane(Mesh *pMesh, MeshBuildParams &params)
Utility method for manual loading a plane.
MeshPtr createCurvedIllusionPlane(const String &name, const String &groupName, const Plane &plane, Real width, Real height, Real curvature, int xsegments=1, int ysegments=1, bool normals=true, unsigned short numTexCoordSets=1, Real uTile=1.0f, Real vTile=1.0f, const Vector3 &upVector=Vector3::UNIT_Y, const Quaternion &orientation=Quaternion::IDENTITY, HardwareBuffer::Usage vertexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage indexBufferUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, bool vertexShadowBuffer=true, bool indexShadowBuffer=true, int ySegmentsToKeep=-1)
Creates a plane, which because of it's texture coordinates looks like a curved surface,...
PatchMeshPtr createBezierPatch(const String &name, const String &groupName, void *controlPointBuffer, VertexDeclaration *declaration, size_t width, size_t height, size_t uMaxSubdivisionLevel=PatchSurface::AUTO_LEVEL, size_t vMaxSubdivisionLevel=PatchSurface::AUTO_LEVEL, PatchSurface::VisibleSide visibleSide=PatchSurface::VS_FRONT, HardwareBuffer::Usage vbUsage=HardwareBuffer::HBU_STATIC_WRITE_ONLY, HardwareBuffer::Usage ibUsage=HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, bool vbUseShadow=true, bool ibUseShadow=true)
Creates a Bezier patch based on an array of control vertices.
void createPrefabCube(void)
MeshBuildType
Enum identifying the types of manual mesh built by this manager.
void loadResource(Resource *res)
void createPrefabPlane(void)
void _initialise(void)
Initialises the manager, only to be called by OGRE internally.
MeshPtr create(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Create a new mesh.
MeshPtr createManual(const String &name, const String &groupName, ManualResourceLoader *loader=0)
Creates a new Mesh specifically for manual definition rather than loading from an object file.
MeshBuildParamsMap mMeshBuildParams
void setListener(MeshSerializerListener *listener)
Sets the listener used to control mesh loading through the serializer.
void setPrepareAllMeshesForShadowVolumes(bool enable)
Tells the mesh manager that all future meshes should prepare themselves for shadow volumes on loading...
MeshPtr getByName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Get a resource by name.
Resource holding data about 3D mesh.
Definition OgreMesh.h:94
Defines a plane in 3D space.
Definition OgrePlane.h:62
Implementation of a Quaternion, i.e.
Defines a generic resource handler.
std::pair< ResourcePtr, bool > ResourceCreateOrRetrieveResult
Abstract class representing a loadable resource (e.g.
Template class for creating single-instance global classes.
Defines a part of a complete mesh.
Definition OgreSubMesh.h:63
Standard 3-dimensional vector.
Definition OgreVector3.h:52
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition OgreCommon.h:550
unsigned long long int ResourceHandle
_StringBase String
Saved parameters used to (re)build a manual mesh built by this class.
HardwareBuffer::Usage indexBufferUsage
HardwareBuffer::Usage vertexBufferUsage
std::map< K, V, P, A > type