OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePatchMesh.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-2013 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 __PatchMesh_H__
29 #define __PatchMesh_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreMesh.h"
33 #include "OgrePatchSurface.h"
34 
35 namespace Ogre {
36 
47  class _OgreExport PatchMesh : public Mesh
48  {
49  protected:
54  public:
56  PatchMesh(ResourceManager* creator, const String& name, ResourceHandle handle,
57  const String& group);
59  void update(void* controlPointBuffer, size_t width, size_t height,
60  size_t uMaxSubdivisionLevel, size_t vMaxSubdivisionLevel,
61  PatchSurface::VisibleSide visibleSide);
63  void define(void* controlPointBuffer,
64  VertexDeclaration *declaration, size_t width, size_t height,
65  size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
66  size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
70  bool vbUseShadow = false, bool ibUseShadow = false);
71 
72  /* Sets the current subdivision level as a proportion of full detail.
73  @param factor Subdivision factor as a value from 0 (control points only) to 1 (maximum
74  subdivision). */
75  void setSubdivision(Real factor);
76  protected:
78  void loadImpl(void);
80  void prepareImpl(void) {}
81 
82  };
89  class _OgreExport PatchMeshPtr : public SharedPtr<PatchMesh>
90  {
91  public:
93  explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr<PatchMesh>(rep) {}
96  {
97  // lock & copy other mutex pointer
98  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
99  {
100  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
101  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
102  pRep = static_cast<PatchMesh*>(r.getPointer());
103  pUseCount = r.useCountPointer();
104  if (pUseCount)
105  {
106  ++(*pUseCount);
107  }
108  }
109  }
110 
113  {
114  if (pRep == static_cast<PatchMesh*>(r.getPointer()))
115  return *this;
116  release();
117 
118  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
119  {
120  // lock & copy other mutex pointer
121  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
122  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
123  pRep = static_cast<PatchMesh*>(r.getPointer());
124  pUseCount = r.useCountPointer();
125  if (pUseCount)
126  {
127  ++(*pUseCount);
128  }
129  }
130  else
131  {
132  // RHS must be a null pointer
133  assert(r.isNull() && "RHS must be null if it has no mutex!");
134  setNull();
135  }
136  return *this;
137  }
140  {
141  if (pRep == static_cast<PatchMesh*>(r.getPointer()))
142  return *this;
143  release();
144  // lock & copy other mutex pointer
145  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
146  {
147  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
148  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
149  pRep = static_cast<PatchMesh*>(r.getPointer());
150  pUseCount = r.useCountPointer();
151  if (pUseCount)
152  {
153  ++(*pUseCount);
154  }
155  }
156  return *this;
157  }
158  };
162 }
163 
164 #endif
VertexDeclaration * mDeclaration
Vertex declaration, cloned from the input.
Definition: OgrePatchMesh.h:53
PatchMeshPtr & operator=(const MeshPtr &r)
Operator used to convert a MeshPtr to a PatchMeshPtr.
T * getPointer() const
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
PatchMeshPtr(const PatchMeshPtr &r)
Definition: OgrePatchMesh.h:94
void prepareImpl(void)
Overridden from Resource - do nothing (no disk caching)
Definition: OgrePatchMesh.h:80
PatchMeshPtr(const ResourcePtr &r)
Definition: OgrePatchMesh.h:95
PatchMeshPtr(PatchMesh *rep)
Definition: OgrePatchMesh.h:93
PatchSurface mSurface
Internal surface definition.
Definition: OgrePatchMesh.h:51
#define OGRE_MUTEX_CONDITIONAL(name)
Combination of HBU_STATIC and HBU_WRITE_ONLY.
Specialisation of SharedPtr to allow SharedPtr to be assigned to PatchMeshPtr.
Definition: OgrePatchMesh.h:89
A surface which is defined by curves of some kind to form a patch, e.g.
Combination of HBU_DYNAMIC and HBU_WRITE_ONLY.
Usage
Enums describing buffer usage; not mutually exclusive.
unsigned long long int ResourceHandle
Definition: OgreResource.h:40
#define OGRE_LOCK_MUTEX(name)
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
Defines a generic resource handler.
unsigned int * useCountPointer() const
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
The side from which u goes right and v goes up (as in texture coords)
_StringBase String
Patch specialisation of Mesh.
Definition: OgrePatchMesh.h:47
PatchMeshPtr & operator=(const ResourcePtr &r)
Operator used to convert a ResourcePtr to a PatchMeshPtr.
Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr.
Definition: OgreMesh.h:875
#define OGRE_COPY_AUTO_SHARED_MUTEX(from)
bool isNull(void) const