OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePatchSurface.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 __PatchSurface_H__
29 #define __PatchSurface_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreVector3.h"
34 #include "OgreString.h"
35 #include "OgreRenderOperation.h"
36 #include "OgreAxisAlignedBox.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
54  {
55  public:
56  PatchSurface();
57  ~PatchSurface();
58 
60  {
62  PST_BEZIER
63  };
64 
66  enum
67  {
68  AUTO_LEVEL = -1
69  };
70 
71  enum VisibleSide {
77  VS_BOTH
78  };
106  void defineSurface(void* controlPointBuffer,
107  VertexDeclaration *declaration, size_t width, size_t height,
108  PatchSurfaceType pType = PST_BEZIER,
109  size_t uMaxSubdivisionLevel = AUTO_LEVEL, size_t vMaxSubdivisionLevel = AUTO_LEVEL,
110  VisibleSide visibleSide = VS_FRONT);
111 
117  size_t getRequiredVertexCount(void) const;
123  size_t getRequiredIndexCount(void) const;
124 
126  size_t getCurrentIndexCount(void) const;
128  size_t getIndexOffset(void) const { return mIndexOffset; }
130  size_t getVertexOffset(void) const { return mVertexOffset; }
131 
132 
134  const AxisAlignedBox& getBounds(void) const;
137  Real getBoundingSphereRadius(void) const;
153  void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
154  HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
155 
164  void setSubdivisionFactor(Real factor);
165 
167  Real getSubdivisionFactor(void) const;
168 
169  void* getControlPointBuffer(void) const
170  {
171  return mControlPointBuffer;
172  }
176  mControlPointBuffer = 0;
177  }
178  protected:
186  size_t mCtlWidth;
188  size_t mCtlHeight;
190  size_t mCtlCount;
192  size_t mULevel;
194  size_t mVLevel;
196  size_t mMaxULevel;
197  size_t mMaxVLevel;
199  size_t mMeshWidth;
201  size_t mMeshHeight;
204 
206 
208 
211  size_t findLevel( Vector3& a, Vector3& b, Vector3& c);
212 
213  void distributeControlPoints(void* lockedBuffer);
214  void subdivideCurve(void* lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations);
215  void interpolateVertexData(void* lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex);
216  void makeTriangles(void);
217 
218  size_t getAutoULevel(bool forMax = false);
219  size_t getAutoVLevel(bool forMax = false);
220 
224  size_t mIndexOffset;
228 
231 
232 
233 
234  };
235 
239 } // namespace
240 
241 #include "OgreHeaderSuffix.h"
242 
243 #endif
size_t mMeshWidth
Width of the subdivided mesh (big enough for max level)
The side from which u goes right and v goes down (reverse of texture coords)
float Real
Software floating point type.
vector< Vector3 >::type mVecCtlPoints
#define _OgreExport
Definition: OgrePlatform.h:260
size_t mMeshHeight
Height of the subdivided mesh (big enough for max level)
size_t mULevel
U-direction subdivision level.
Shared pointer implementation used to share vertex buffers.
A 3D box aligned with the x/y/z axes.
size_t getVertexOffset(void) const
Returns the vertex offset used by this buffer to write data into the buffer.
Shared pointer implementation used to share index buffers.
size_t mVLevel
V-direction subdivision level.
size_t mCtlCount
TotalNumber of control points.
VisibleSide mVSide
Which side is visible.
A surface which is defined by curves of some kind to form a patch, e.g.
void notifyControlPointBufferDeallocated(void)
Convenience method for telling the patch that the control points have been deleted, since once the patch has been built they are not required.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
void * getControlPointBuffer(void) const
size_t mCtlHeight
Height in control points.
AxisAlignedBox mAABB
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
void * mControlPointBuffer
Buffer containing the system-memory control points.
VertexDeclaration * mDeclaration
Vertex declaration describing the control point buffer.
size_t getIndexOffset(void) const
Returns the index offset used by this buffer to write data into the buffer.
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
HardwareVertexBufferSharedPtr mVertexBuffer
PatchSurfaceType mType
Type of surface.
The side from which u goes right and v goes up (as in texture coords)
size_t mCtlWidth
Width in control points.
HardwareIndexBufferSharedPtr mIndexBuffer
size_t mMaxULevel
Max subdivision level.