OGRE  2.0
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 
35 #include "OgreAxisAlignedBox.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
53  {
54  public:
55  PatchSurface();
56  ~PatchSurface();
57 
59  {
61  PST_BEZIER
62  };
63 
65  enum
66  {
67  AUTO_LEVEL = -1
68  };
69 
70  enum VisibleSide {
76  VS_BOTH
77  };
105  void defineSurface(void* controlPointBuffer,
106  VertexDeclaration *declaration, size_t width, size_t height,
107  PatchSurfaceType pType = PST_BEZIER,
108  size_t uMaxSubdivisionLevel = AUTO_LEVEL, size_t vMaxSubdivisionLevel = AUTO_LEVEL,
109  VisibleSide visibleSide = VS_FRONT);
110 
116  size_t getRequiredVertexCount(void) const;
122  size_t getRequiredIndexCount(void) const;
123 
125  size_t getCurrentIndexCount(void) const;
127  size_t getIndexOffset(void) const { return mIndexOffset; }
129  size_t getVertexOffset(void) const { return mVertexOffset; }
130 
131 
133  const AxisAlignedBox& getBounds(void) const;
136  Real getBoundingSphereRadius(void) const;
152  void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
153  HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
154 
163  void setSubdivisionFactor(Real factor);
164 
166  Real getSubdivisionFactor(void) const;
167 
168  void* getControlPointBuffer(void) const
169  {
170  return mControlPointBuffer;
171  }
175  mControlPointBuffer = 0;
176  }
177  protected:
185  size_t mCtlWidth;
187  size_t mCtlHeight;
189  size_t mCtlCount;
191  size_t mULevel;
193  size_t mVLevel;
195  size_t mMaxULevel;
196  size_t mMaxVLevel;
198  size_t mMeshWidth;
200  size_t mMeshHeight;
203 
205 
207 
210  size_t findLevel( Vector3& a, Vector3& b, Vector3& c);
211 
212  void distributeControlPoints(void* lockedBuffer);
213  void subdivideCurve(void* lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations);
214  void interpolateVertexData(void* lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex);
215  void makeTriangles(void);
216 
217  size_t getAutoULevel(bool forMax = false);
218  size_t getAutoVLevel(bool forMax = false);
219 
223  size_t mIndexOffset;
227 
230 
231 
232 
233  };
234 
238 } // namespace
239 
240 #include "OgreHeaderSuffix.h"
241 
242 #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:255
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:50
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.