Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::PatchSurface Class Reference

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

#include <OgrePatchSurface.h>

List of all members.

Public Types

enum  PatchSurfaceType { PST_BEZIER }
enum  { AUTO_LEVEL = -1 }
 Constant for indicating automatic determination of subdivision level for patches. More...

enum  VisibleSide { VS_FRONT, VS_BACK, VS_BOTH }

Public Methods

 PatchSurface ()
 ~PatchSurface ()
void defineSurface (String meshName, const GeometryData &controlPoints, int width, PatchSurfaceType pType=PST_BEZIER, int subdivisionLevel=AUTO_LEVEL, VisibleSide visibleSide=VS_FRONT)
 Sets up the surface by defining it's control points, type and initial subdivision level. More...

void build (void)
 Tells the system to build the mesh relating to the surface. More...

void setSubdivisionLevel (int level=AUTO_LEVEL)
 Alters the level of subdivision for this surface. More...

MeshgetMesh (void)
 Retrieves a pointer to the mesh which has been built for this surface. More...


Protected Methods

int findLevel (Vector3 &a, Vector3 &b, Vector3 &c)
 Internal method for finding the subdivision level given 3 control points. More...

void allocateMemory (void)
void deallocateMemory (void)
void distributeControlPoints (void)
void subdivideCurve (int startIdx, int stepSize, int numSteps, int iterations)
void interpolateVertexData (int leftIndex, int rightIndex, int destIndex)
void makeTriangles (void)

Protected Attributes

String mMeshName
 MeshManager registered name. More...

GeometryData mCtlPointData
 Control points. More...

MeshmMesh
 The mesh. More...

bool mNeedsBuild
 Flag indicating build required. More...

PatchSurfaceType mType
 Type of surface. More...

int mCtlWidth
 Width in control points. More...

int mCtlHeight
 Height in control points. More...

int mULevel
 U-direction subdivision level. More...

int mVLevel
 V-direction subdivision level. More...

int mMeshWidth
 Width of the subdivided mesh. More...

int mMeshHeight
 Height of the subdivided mesh. More...

VisibleSide mVSide
 Which side is visible. More...

bool mSharedVertexData
bool mMemoryAllocated
std::vector< Vector3mVecCtlPoints
int mBufPosStep
int mBufNormStep
int mBufColourStep
int mBufTexCoordStep [OGRE_MAX_TEXTURE_COORD_SETS]


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.


Member Enumeration Documentation

anonymous enum
 

Constant for indicating automatic determination of subdivision level for patches.

Enumeration values:
AUTO_LEVEL 

enum Ogre::PatchSurface::PatchSurfaceType
 

Enumeration values:
PST_BEZIER  A patch defined by a set of bezier curves.

enum Ogre::PatchSurface::VisibleSide
 

Enumeration values:
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.


Constructor & Destructor Documentation

Ogre::PatchSurface::PatchSurface  
 

Ogre::PatchSurface::~PatchSurface  
 


Member Function Documentation

void Ogre::PatchSurface::allocateMemory void    [protected]
 

void Ogre::PatchSurface::build void   
 

Tells the system to build the mesh relating to the surface.

Remarks:
Calling getMesh will automatically do this if the mesh is out of date, however if you wish to force this to happen during a non-critical period then call this.

void Ogre::PatchSurface::deallocateMemory void    [protected]
 

void Ogre::PatchSurface::defineSurface String    meshName,
const GeometryData   controlPoints,
int    width,
PatchSurfaceType    pType = PST_BEZIER,
int    subdivisionLevel = 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 (in the form of a GeometryData object, since there are many optional components). 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:
meshName  The name to give to the mesh which is created, for MeshManager registration purposes (this allows you to create entities from this at a later time if you wish)
controlPoints  A set of vertex data which defines control points of the curves rather than actual vertices.
width  Specifies the width of the patch in control points. It is assumed that controlPoints.numVertices / width is the height.
pType  The type of surface - currently only PST_BEZIER is supported
subdivisionLevel  If you want to manually set the level of subdivision, do it here, otherwise let the system decide.
visibleSide  Determines which side of the patch (or both) triangles are generated for.

void Ogre::PatchSurface::distributeControlPoints void    [protected]
 

int Ogre::PatchSurface::findLevel Vector3   a,
Vector3   b,
Vector3   c
[protected]
 

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

Mesh * Ogre::PatchSurface::getMesh void   
 

Retrieves a pointer to the mesh which has been built for this surface.

Remarks:
If PatchSurface::build has not already been called, this method calls it for you to ensure the mesh is up to date.
Note:
The mesh geometry data will be produced in the same format (vertex components, data strides etc) as the control point data passed in using PatchSurface::defineSurface.
See also:
PatchSurface::defineSurface

void Ogre::PatchSurface::interpolateVertexData int    leftIndex,
int    rightIndex,
int    destIndex
[protected]
 

void Ogre::PatchSurface::makeTriangles void    [protected]
 

void Ogre::PatchSurface::setSubdivisionLevel int    level = AUTO_LEVEL
 

Alters the level of subdivision for this surface.

Remarks:
This method is provided to alter the subdivision level of the surface at some point after defineSurface has been called. Overrides any automatic determination of the subdivision level. Takes effect next time PatchSurface::build or PatchSurface::getMesh is called.
See also:
PatchSurface::build, PatchSurface::getMesh

void Ogre::PatchSurface::subdivideCurve int    startIdx,
int    stepSize,
int    numSteps,
int    iterations
[protected]
 


Member Data Documentation

int Ogre::PatchSurface::mBufColourStep [protected]
 

int Ogre::PatchSurface::mBufNormStep [protected]
 

int Ogre::PatchSurface::mBufPosStep [protected]
 

int Ogre::PatchSurface::mBufTexCoordStep[OGRE_MAX_TEXTURE_COORD_SETS] [protected]
 

int Ogre::PatchSurface::mCtlHeight [protected]
 

Height in control points.

GeometryData Ogre::PatchSurface::mCtlPointData [protected]
 

Control points.

int Ogre::PatchSurface::mCtlWidth [protected]
 

Width in control points.

bool Ogre::PatchSurface::mMemoryAllocated [protected]
 

Mesh* Ogre::PatchSurface::mMesh [protected]
 

The mesh.

int Ogre::PatchSurface::mMeshHeight [protected]
 

Height of the subdivided mesh.

String Ogre::PatchSurface::mMeshName [protected]
 

MeshManager registered name.

int Ogre::PatchSurface::mMeshWidth [protected]
 

Width of the subdivided mesh.

bool Ogre::PatchSurface::mNeedsBuild [protected]
 

Flag indicating build required.

bool Ogre::PatchSurface::mSharedVertexData [protected]
 

PatchSurfaceType Ogre::PatchSurface::mType [protected]
 

Type of surface.

int Ogre::PatchSurface::mULevel [protected]
 

U-direction subdivision level.

std::vector<Vector3> Ogre::PatchSurface::mVecCtlPoints [protected]
 

int Ogre::PatchSurface::mVLevel [protected]
 

V-direction subdivision level.

VisibleSide Ogre::PatchSurface::mVSide [protected]
 

Which side is visible.

Copyright © 2002 by The OGRE Team