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-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 __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:
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;
153  void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
154  HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
155 
165 
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
OgreHeaderSuffix.h
Ogre::PatchSurface::mMaxVLevel
size_t mMaxVLevel
Definition: OgrePatchSurface.h:197
Ogre::PatchSurface::mCtlHeight
size_t mCtlHeight
Height in control points.
Definition: OgrePatchSurface.h:188
Ogre::PatchSurface::mVecCtlPoints
vector< Vector3 >::type mVecCtlPoints
Definition: OgrePatchSurface.h:207
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::PatchSurface::setSubdivisionFactor
void setSubdivisionFactor(Real factor)
Alters the level of subdivision for this surface.
Ogre::PatchSurface::mVertexBuffer
HardwareVertexBufferSharedPtr mVertexBuffer
Definition: OgrePatchSurface.h:221
Ogre::PatchSurface::getControlPointBuffer
void * getControlPointBuffer(void) const
Definition: OgrePatchSurface.h:169
Ogre::PatchSurface::findLevel
size_t findLevel(Vector3 &a, Vector3 &b, Vector3 &c)
Internal method for finding the subdivision level given 3 control points.
Ogre::PatchSurface::mVSide
VisibleSide mVSide
Which side is visible.
Definition: OgrePatchSurface.h:203
Ogre::PatchSurface::mAABB
AxisAlignedBox mAABB
Definition: OgrePatchSurface.h:229
Ogre::PatchSurface::distributeControlPoints
void distributeControlPoints(void *lockedBuffer)
Ogre::PatchSurface::PatchSurface
PatchSurface()
Ogre::PatchSurface::getBoundingSphereRadius
Real getBoundingSphereRadius(void) const
Gets the radius of the bounding sphere for this patch, only valid after defineSurface has been called...
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:80
Ogre::PatchSurface::makeTriangles
void makeTriangles(void)
Ogre::PatchSurface::mULevel
size_t mULevel
U-direction subdivision level.
Definition: OgrePatchSurface.h:192
Ogre::PatchSurface::VisibleSide
VisibleSide
Definition: OgrePatchSurface.h:71
Ogre::PatchSurface::getBounds
const AxisAlignedBox & getBounds(void) const
Gets the bounds of this patch, only valid after calling defineSurface.
Ogre::PatchSurface::getCurrentIndexCount
size_t getCurrentIndexCount(void) const
Gets the current index count based on the current subdivision level.
Ogre::PatchSurface
A surface which is defined by curves of some kind to form a patch, e.g.
Definition: OgrePatchSurface.h:54
Ogre::PatchSurface::VS_FRONT
@ VS_FRONT
The side from which u goes right and v goes up (as in texture coords)
Definition: OgrePatchSurface.h:73
Ogre::PatchSurface::interpolateVertexData
void interpolateVertexData(void *lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex)
Ogre::PatchSurface::mCtlCount
size_t mCtlCount
TotalNumber of control points.
Definition: OgrePatchSurface.h:190
Ogre::PatchSurface::mVLevel
size_t mVLevel
V-direction subdivision level.
Definition: OgrePatchSurface.h:194
Ogre::PatchSurface::defineSurface
void defineSurface(void *controlPointBuffer, VertexDeclaration *declaration, size_t width, size_t height, PatchSurfaceType pType=PST_BEZIER, size_t uMaxSubdivisionLevel=AUTO_LEVEL, size_t vMaxSubdivisionLevel=AUTO_LEVEL, VisibleSide visibleSide=VS_FRONT)
Sets up the surface by defining it's control points, type and initial subdivision level.
Ogre::PatchSurface::mDeclaration
VertexDeclaration * mDeclaration
Vertex declaration describing the control point buffer.
Definition: OgrePatchSurface.h:180
Ogre::PatchSurface::mCurrIndexCount
size_t mCurrIndexCount
Definition: OgrePatchSurface.h:227
OgreRenderOperation.h
OgreHeaderPrefix.h
Ogre::PatchSurface::mMeshWidth
size_t mMeshWidth
Width of the subdivided mesh (big enough for max level)
Definition: OgrePatchSurface.h:199
Ogre::PatchSurface::build
void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart, HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart)
Tells the system to build the mesh relating to the surface into externally created buffers.
Ogre::PatchSurface::subdivideCurve
void subdivideCurve(void *lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations)
OgrePrerequisites.h
Ogre::VertexDeclaration
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
Definition: OgreHardwareVertexBuffer.h:338
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:87
Ogre::PatchSurface::getRequiredIndexCount
size_t getRequiredIndexCount(void) const
Based on a previous call to defineSurface, establishes the number of indexes required to hold this pa...
Ogre::PatchSurface::getVertexOffset
size_t getVertexOffset(void) const
Returns the vertex offset used by this buffer to write data into the buffer.
Definition: OgrePatchSurface.h:130
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:55
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::PatchSurface::mIndexOffset
size_t mIndexOffset
Definition: OgrePatchSurface.h:224
Ogre::PatchSurface::getIndexOffset
size_t getIndexOffset(void) const
Returns the index offset used by this buffer to write data into the buffer.
Definition: OgrePatchSurface.h:128
Ogre::PatchSurface::getAutoVLevel
size_t getAutoVLevel(bool forMax=false)
Ogre::PatchSurface::mMaxULevel
size_t mMaxULevel
Max subdivision level.
Definition: OgrePatchSurface.h:196
Ogre::PatchSurface::mBoundingSphere
Real mBoundingSphere
Definition: OgrePatchSurface.h:230
Ogre::PatchSurface::mSubdivisionFactor
Real mSubdivisionFactor
Definition: OgrePatchSurface.h:205
Ogre::PatchSurface::mIndexBuffer
HardwareIndexBufferSharedPtr mIndexBuffer
Definition: OgrePatchSurface.h:222
Ogre::PatchSurface::mVertexOffset
size_t mVertexOffset
Definition: OgrePatchSurface.h:223
Ogre::PatchSurface::getRequiredVertexCount
size_t getRequiredVertexCount(void) const
Based on a previous call to defineSurface, establishes the number of vertices required to hold this p...
Ogre::PatchSurface::PatchSurfaceType
PatchSurfaceType
Definition: OgrePatchSurface.h:60
Ogre::PatchSurface::mRequiredIndexCount
size_t mRequiredIndexCount
Definition: OgrePatchSurface.h:226
Ogre::PatchSurface::mCtlWidth
size_t mCtlWidth
Width in control points.
Definition: OgrePatchSurface.h:186
Ogre::PatchSurface::mControlPointBuffer
void * mControlPointBuffer
Buffer containing the system-memory control points.
Definition: OgrePatchSurface.h:182
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::PatchSurface::VS_BACK
@ VS_BACK
The side from which u goes right and v goes down (reverse of texture coords)
Definition: OgrePatchSurface.h:75
Ogre::PatchSurface::getAutoULevel
size_t getAutoULevel(bool forMax=false)
OgreAxisAlignedBox.h
Ogre::PatchSurface::getSubdivisionFactor
Real getSubdivisionFactor(void) const
Gets the current level of subdivision.
OgreString.h
Ogre::vector
Definition: OgrePrerequisites.h:492
OgreVector3.h
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Ogre::PatchSurface::mType
PatchSurfaceType mType
Type of surface.
Definition: OgrePatchSurface.h:184
Ogre::PatchSurface::mRequiredVertexCount
size_t mRequiredVertexCount
Definition: OgrePatchSurface.h:225
Ogre::PatchSurface::mMeshHeight
size_t mMeshHeight
Height of the subdivided mesh (big enough for max level)
Definition: OgrePatchSurface.h:201
Ogre::PatchSurface::notifyControlPointBufferDeallocated
void notifyControlPointBufferDeallocated(void)
Convenience method for telling the patch that the control points have been deleted,...
Definition: OgrePatchSurface.h:175
Ogre::PatchSurface::~PatchSurface
~PatchSurface()

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.