Ogre::PatchSurface Class Reference
Core » LOD

A surface which is defined by curves of some kind to form a patch, e.g. More...

`#include <OgrePatchSurface.h>`

Inheritance diagram for Ogre::PatchSurface:
[legend]

## Public Types

enum | { AUTO_LEVEL = -1 }
| Constant for indicating automatic determination of subdivision level for patches. More...
enum | PatchSurfaceType { PST_BEZIER }
enum | VisibleSide { VS_FRONT, VS_BACK, VS_BOTH }

## Public Member Functions

| PatchSurface ()
| ~PatchSurface ()
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. More...
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. More...
Real | getBoundingSphereRadius (void) const
| Gets the radius of the bounding sphere for this patch, only valid after defineSurface has been called. More...
const AxisAlignedBox & | getBounds (void) const
| Gets the bounds of this patch, only valid after calling defineSurface. More...
void * | getControlPointBuffer (void) const
size_t | getCurrentIndexCount (void) const
| Gets the current index count based on the current subdivision level. More...
size_t | getIndexOffset (void) const
| Returns the index offset used by this buffer to write data into the buffer. More...
size_t | getRequiredIndexCount (void) const
| Based on a previous call to defineSurface, establishes the number of indexes required to hold this patch at the maximum detail level. More...
size_t | getRequiredVertexCount (void) const
| Based on a previous call to defineSurface, establishes the number of vertices required to hold this patch at the maximum detail level. More...
Real | getSubdivisionFactor (void) const
| Gets the current level of subdivision. More...
size_t | getVertexOffset (void) const
| Returns the vertex offset used by this buffer to write data into the buffer. More...
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. More...
void | operator delete (void *ptr)
void | operator delete (void *ptr, void *)
void | operator delete (void *ptr, const char *, int, const char *)
void | operator delete[] (void *ptr)
void | operator delete[] (void *ptr, const char *, int, const char *)
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info More...
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new More...
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info More...
void * | operator new[] (size_t sz)
void | setSubdivisionFactor (Real factor)
| Alters the level of subdivision for this surface. More...

## Protected Member Functions

void | distributeControlPoints (void *lockedBuffer)
size_t | findLevel (Vector3 &a, Vector3 &b, Vector3 &c)
| Internal method for finding the subdivision level given 3 control points. More...
size_t | getAutoULevel (bool forMax=false)
size_t | getAutoVLevel (bool forMax=false)
void | interpolateVertexData (void *lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex)
void | makeTriangles (void)
void | subdivideCurve (void *lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations)

## Protected Attributes

AxisAlignedBox | mAABB
Real | mBoundingSphere
void * | mControlPointBuffer
| Buffer containing the system-memory control points. More...
size_t | mCtlCount
| TotalNumber of control points. More...
size_t | mCtlHeight
| Height in control points. More...
size_t | mCtlWidth
| Width in control points. More...
size_t | mCurrIndexCount
VertexDeclaration * | mDeclaration
| Vertex declaration describing the control point buffer. More...
HardwareIndexBufferSharedPtr | mIndexBuffer
size_t | mIndexOffset
size_t | mMaxULevel
| Max subdivision level. More...
size_t | mMaxVLevel
size_t | mMeshHeight
| Height of the subdivided mesh (big enough for max level) More...
size_t | mMeshWidth
| Width of the subdivided mesh (big enough for max level) More...
size_t | mRequiredIndexCount
size_t | mRequiredVertexCount
Real | mSubdivisionFactor
PatchSurfaceType | mType
| Type of surface. More...
size_t | mULevel
| U-direction subdivision level. More...
vector< Vector3 >::type | mVecCtlPoints
HardwareVertexBufferSharedPtr | mVertexBuffer
size_t | mVertexOffset
size_t | mVLevel
| V-direction subdivision level. More...
VisibleSide | mVSide
| Which side is visible. More...

## Detailed Description

A surface which is defined by curves of some kind to form a patch, e.g.

a Bezier patch.

Remarks
  This object will take a list of control points with various assorted data, and will subdivide it into a patch mesh. Currently only Bezier curves are supported for defining the surface, but other techniques such as NURBS would follow the same basic approach.

Definition at line 53 of file OgrePatchSurface.h.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Constant for indicating automatic determination of subdivision level for patches.

Enumerator
AUTO_LEVEL |

Definition at line 66 of file OgrePatchSurface.h.

## PatchSurfaceType

enum Ogre::PatchSurface::PatchSurfaceType

Enumerator
PST_BEZIER | A patch defined by a set of bezier curves.

Definition at line 59 of file OgrePatchSurface.h.

## VisibleSide

enum Ogre::PatchSurface::VisibleSide

Enumerator
VS_FRONT | The side from which u goes right and v goes up (as in texture coords)
VS_BACK | The side from which u goes right and v goes down (reverse of texture coords)
VS_BOTH | Both sides are visible - warning this creates 2x the number of triangles and adds extra overhead for calculating normals.

Definition at line 71 of file OgrePatchSurface.h.

## Constructor & Destructor Documentation

## PatchSurface()

Ogre::PatchSurface::PatchSurface | ( |  | ) |

## ~PatchSurface()

Ogre::PatchSurface::~PatchSurface | ( |  | ) |

## Member Function Documentation

## build()

void Ogre::PatchSurface::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.

Remarks
  The VertexDeclaration of the vertex buffer must be identical to the one passed into defineSurface. In addition, there must be enough space in the buffer to accommodate the patch at full detail level; you should call getRequiredVertexCount and getRequiredIndexCount to determine this. This method does not create an internal mesh for this patch and so getMesh will return null if you call it after building the patch this way.

Parameters

  destVertexBuffer | The destination vertex buffer in which to build the patch.
  vertexStart | The offset at which to start writing vertices for this patch
  destIndexBuffer | The destination index buffer in which to build the patch.
  indexStart | The offset at which to start writing indexes for this patch

## defineSurface()

void Ogre::PatchSurface::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.

Remarks
  This method initialises the surface by passing it a set of control points. The type of curves to be used are also defined here, although the only supported option currently is a bezier patch. You can also specify a global subdivision level here if you like, although it is recommended that the parameter is left as AUTO_LEVEL, which means the system decides how much subdivision is required (based on the curvature of the surface)

Parameters

  controlPointBuffer | A pointer to a buffer containing the vertex data which defines control points of the curves rather than actual vertices. Note that you are expected to provide not just position information, but potentially normals and texture coordinates too. The format of the buffer is defined in the VertexDeclaration parameter
  declaration | VertexDeclaration describing the contents of the buffer. Note this declaration must only draw on buffer source 0!
  width | Specifies the width of the patch in control points.
  height | Specifies the height of the patch in control points.
  pType | The type of surface - currently only PST_BEZIER is supported
  uMaxSubdivisionLevel,vMaxSubdivisionLevel | If you want to manually set the top level of subdivision, do it here, otherwise let the system decide.
  visibleSide | Determines which side of the patch (or both) triangles are generated for.

## distributeControlPoints()

void Ogre::PatchSurface::distributeControlPoints | ( | void * | lockedBuffer | ) |

protected

## findLevel()

size_t Ogre::PatchSurface::findLevel | ( | Vector3 & | a,
|  | Vector3 & | b,
|  | Vector3 & | c
| ) |  |

protected

Internal method for finding the subdivision level given 3 control points.

## getAutoULevel()

size_t Ogre::PatchSurface::getAutoULevel | ( | bool | forMax = `false` | ) |

protected

## getAutoVLevel()

size_t Ogre::PatchSurface::getAutoVLevel | ( | bool | forMax = `false` | ) |

protected

## getBoundingSphereRadius()

Real Ogre::PatchSurface::getBoundingSphereRadius | ( | void |  | ) | const

Gets the radius of the bounding sphere for this patch, only valid after defineSurface has been called.

## getBounds()

const AxisAlignedBox& Ogre::PatchSurface::getBounds | ( | void |  | ) | const

Gets the bounds of this patch, only valid after calling defineSurface.

## getControlPointBuffer()

void* Ogre::PatchSurface::getControlPointBuffer | ( | void |  | ) | const

Definition at line 169 of file OgrePatchSurface.h.

## getCurrentIndexCount()

size_t Ogre::PatchSurface::getCurrentIndexCount | ( | void |  | ) | const

Gets the current index count based on the current subdivision level.

## getIndexOffset()

size_t Ogre::PatchSurface::getIndexOffset | ( | void |  | ) | const

Returns the index offset used by this buffer to write data into the buffer.

Definition at line 128 of file OgrePatchSurface.h.

## getRequiredIndexCount()

size_t Ogre::PatchSurface::getRequiredIndexCount | ( | void |  | ) | const

Based on a previous call to defineSurface, establishes the number of indexes required to hold this patch at the maximum detail level.

Remarks
  This is useful when you wish to build the patch into external vertex / index buffers.

## getRequiredVertexCount()

size_t Ogre::PatchSurface::getRequiredVertexCount | ( | void |  | ) | const

Based on a previous call to defineSurface, establishes the number of vertices required to hold this patch at the maximum detail level.

Remarks
  This is useful when you wish to build the patch into external vertex / index buffers.

## getSubdivisionFactor()

Real Ogre::PatchSurface::getSubdivisionFactor | ( | void |  | ) | const

Gets the current level of subdivision.

## getVertexOffset()

size_t Ogre::PatchSurface::getVertexOffset | ( | void |  | ) | const

Returns the vertex offset used by this buffer to write data into the buffer.

Definition at line 130 of file OgrePatchSurface.h.

## interpolateVertexData()

void Ogre::PatchSurface::interpolateVertexData | ( | void * | lockedBuffer,
|  | size_t | leftIndex,
|  | size_t | rightIndex,
|  | size_t | destIndex
| ) |  |

protected

## makeTriangles()

void Ogre::PatchSurface::makeTriangles | ( | void |  | ) |

protected

## notifyControlPointBufferDeallocated()

void Ogre::PatchSurface::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.

Definition at line 175 of file OgrePatchSurface.h.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

## operator new() [1/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  |

inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

## operator new[]() [1/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

## operator new[]() [2/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) |

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## setSubdivisionFactor()

void Ogre::PatchSurface::setSubdivisionFactor | ( | Real | factor | ) |

Alters the level of subdivision for this surface.

Remarks
  This method changes the proportionate detail level of the patch; since the U and V directions can have different subdivision levels, this method takes a single Real value where 0 is the minimum detail (the control points) and 1 is the maximum detail level as supplied to the original call to defineSurface.

## subdivideCurve()

void Ogre::PatchSurface::subdivideCurve | ( | void * | lockedBuffer,
|  | size_t | startIdx,
|  | size_t | stepSize,
|  | size_t | numSteps,
|  | size_t | iterations
| ) |  |

protected

## Member Data Documentation

## mAABB

AxisAlignedBox Ogre::PatchSurface::mAABB

protected

Definition at line 229 of file OgrePatchSurface.h.

## mBoundingSphere

Real Ogre::PatchSurface::mBoundingSphere

protected

Definition at line 230 of file OgrePatchSurface.h.

## mControlPointBuffer

void* Ogre::PatchSurface::mControlPointBuffer

protected

Buffer containing the system-memory control points.

Definition at line 182 of file OgrePatchSurface.h.

## mCtlCount

size_t Ogre::PatchSurface::mCtlCount

protected

TotalNumber of control points.

Definition at line 190 of file OgrePatchSurface.h.

## mCtlHeight

size_t Ogre::PatchSurface::mCtlHeight

protected

Height in control points.

Definition at line 188 of file OgrePatchSurface.h.

## mCtlWidth

size_t Ogre::PatchSurface::mCtlWidth

protected

Width in control points.

Definition at line 186 of file OgrePatchSurface.h.

## mCurrIndexCount

size_t Ogre::PatchSurface::mCurrIndexCount

protected

Definition at line 227 of file OgrePatchSurface.h.

## mDeclaration

VertexDeclaration* Ogre::PatchSurface::mDeclaration

protected

Vertex declaration describing the control point buffer.

Definition at line 180 of file OgrePatchSurface.h.

## mIndexBuffer

HardwareIndexBufferSharedPtr Ogre::PatchSurface::mIndexBuffer

protected

Definition at line 222 of file OgrePatchSurface.h.

## mIndexOffset

size_t Ogre::PatchSurface::mIndexOffset

protected

Definition at line 224 of file OgrePatchSurface.h.

## mMaxULevel

size_t Ogre::PatchSurface::mMaxULevel

protected

Max subdivision level.

Definition at line 196 of file OgrePatchSurface.h.

## mMaxVLevel

size_t Ogre::PatchSurface::mMaxVLevel

protected

Definition at line 197 of file OgrePatchSurface.h.

## mMeshHeight

size_t Ogre::PatchSurface::mMeshHeight

protected

Height of the subdivided mesh (big enough for max level)

Definition at line 201 of file OgrePatchSurface.h.

## mMeshWidth

size_t Ogre::PatchSurface::mMeshWidth

protected

Width of the subdivided mesh (big enough for max level)

Definition at line 199 of file OgrePatchSurface.h.

## mRequiredIndexCount

size_t Ogre::PatchSurface::mRequiredIndexCount

protected

Definition at line 226 of file OgrePatchSurface.h.

## mRequiredVertexCount

size_t Ogre::PatchSurface::mRequiredVertexCount

protected

Definition at line 225 of file OgrePatchSurface.h.

## mSubdivisionFactor

Real Ogre::PatchSurface::mSubdivisionFactor

protected

Definition at line 205 of file OgrePatchSurface.h.

## mType

PatchSurfaceType Ogre::PatchSurface::mType

protected

Type of surface.

Definition at line 184 of file OgrePatchSurface.h.

## mULevel

size_t Ogre::PatchSurface::mULevel

protected

U-direction subdivision level.

Definition at line 192 of file OgrePatchSurface.h.

## mVecCtlPoints

vector<Vector3>::type Ogre::PatchSurface::mVecCtlPoints

protected

Definition at line 207 of file OgrePatchSurface.h.

## mVertexBuffer

HardwareVertexBufferSharedPtr Ogre::PatchSurface::mVertexBuffer

protected

Definition at line 221 of file OgrePatchSurface.h.

## mVertexOffset

size_t Ogre::PatchSurface::mVertexOffset

protected

Definition at line 223 of file OgrePatchSurface.h.

## mVLevel

size_t Ogre::PatchSurface::mVLevel

protected

V-direction subdivision level.

Definition at line 194 of file OgrePatchSurface.h.

## mVSide

VisibleSide Ogre::PatchSurface::mVSide

protected

Which side is visible.

Definition at line 203 of file OgrePatchSurface.h.

The documentation for this class was generated from the following file:

- OgrePatchSurface.h

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