OgrePatchSurface.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __PatchSurface_H__
#define __PatchSurface_H__
#include "OgrePrerequisites.h"
#include "OgreVector3.h"
#include "OgreString.h"
#include "OgreRenderOperation.h"
#include "OgreAxisAlignedBox.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport PatchSurface : public PatchAlloc
{
public:
PatchSurface();
~PatchSurface();
enum PatchSurfaceType
{
PST_BEZIER
};
enum
{
AUTO_LEVEL = -1
};
enum VisibleSide {
VS_FRONT,
VS_BACK,
VS_BOTH
};
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);
size_t getRequiredVertexCount(void) const;
size_t getRequiredIndexCount(void) const;
size_t getCurrentIndexCount(void) const;
size_t getIndexOffset(void) const { return mIndexOffset; }
size_t getVertexOffset(void) const { return mVertexOffset; }
const AxisAlignedBox& getBounds(void) const;
Real getBoundingSphereRadius(void) const;
void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
void setSubdivisionFactor(Real factor);
Real getSubdivisionFactor(void) const;
void* getControlPointBuffer(void) const
{
return mControlPointBuffer;
}
void notifyControlPointBufferDeallocated(void) {
mControlPointBuffer = 0;
}
protected:
VertexDeclaration* mDeclaration;
void* mControlPointBuffer;
PatchSurfaceType mType;
size_t mCtlWidth;
size_t mCtlHeight;
size_t mCtlCount;
size_t mULevel;
size_t mVLevel;
size_t mMaxULevel;
size_t mMaxVLevel;
size_t mMeshWidth;
size_t mMeshHeight;
VisibleSide mVSide;
Real mSubdivisionFactor;
vector<Vector3>::type mVecCtlPoints;
size_t findLevel( Vector3& a, Vector3& b, Vector3& c);
void distributeControlPoints(void* lockedBuffer);
void subdivideCurve(void* lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations);
void interpolateVertexData(void* lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex);
void makeTriangles(void);
size_t getAutoULevel(bool forMax = false);
size_t getAutoVLevel(bool forMax = false);
HardwareVertexBufferSharedPtr mVertexBuffer;
HardwareIndexBufferSharedPtr mIndexBuffer;
size_t mVertexOffset;
size_t mIndexOffset;
size_t mRequiredVertexCount;
size_t mRequiredIndexCount;
size_t mCurrIndexCount;
AxisAlignedBox mAABB;
Real mBoundingSphere;
};
} // namespace
#include "OgreHeaderSuffix.h"
#endif
Ogre::PatchSurface::mBoundingSphere
Real mBoundingSphere
Definition: OgrePatchSurface.h:230
OgreAxisAlignedBox.h
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:79
Ogre::PatchSurface::mCtlHeight
size_t mCtlHeight
Height in control points.
Definition: OgrePatchSurface.h:188
Ogre::PatchSurface::mMaxULevel
size_t mMaxULevel
Max subdivision level.
Definition: OgrePatchSurface.h:196
Ogre::PatchSurface::VS_FRONT
The side from which u goes right and v goes up (as in texture coords)
Definition: OgrePatchSurface.h:73
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
OgreString.h
Ogre::PatchSurface::mMaxVLevel
size_t mMaxVLevel
Definition: OgrePatchSurface.h:197
Ogre::PatchSurface::mRequiredIndexCount
size_t mRequiredIndexCount
Definition: OgrePatchSurface.h:226
Ogre::PatchSurface::mMeshWidth
size_t mMeshWidth
Width of the subdivided mesh (big enough for max level)
Definition: OgrePatchSurface.h:199
Ogre::PatchSurface::getControlPointBuffer
void * getControlPointBuffer(void) const
Definition: OgrePatchSurface.h:169
Ogre::PatchSurface::mType
PatchSurfaceType mType
Type of surface.
Definition: OgrePatchSurface.h:184
Ogre::PatchSurface::mVertexBuffer
HardwareVertexBufferSharedPtr mVertexBuffer
Definition: OgrePatchSurface.h:221
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::PatchSurface::mVecCtlPoints
vector< Vector3 >::type mVecCtlPoints
Definition: OgrePatchSurface.h:207
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:337
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:86
Ogre::PatchSurface::PatchSurfaceType
PatchSurfaceType
Definition: OgrePatchSurface.h:59
OgrePrerequisites.h
Ogre::PatchSurface::mRequiredVertexCount
size_t mRequiredVertexCount
Definition: OgrePatchSurface.h:225
Ogre::PatchSurface::mSubdivisionFactor
Real mSubdivisionFactor
Definition: OgrePatchSurface.h:205
Ogre::PatchSurface::notifyControlPointBufferDeallocated
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.
Definition: OgrePatchSurface.h:175
OgreRenderOperation.h
Ogre::PatchSurface::mAABB
AxisAlignedBox mAABB
Definition: OgrePatchSurface.h:229
Ogre::PatchSurface::mMeshHeight
size_t mMeshHeight
Height of the subdivided mesh (big enough for max level)
Definition: OgrePatchSurface.h:201
Ogre::PatchSurface::mVSide
VisibleSide mVSide
Which side is visible.
Definition: OgrePatchSurface.h:203
Ogre::PatchSurface::mControlPointBuffer
void * mControlPointBuffer
Buffer containing the system-memory control points.
Definition: OgrePatchSurface.h:182
OgreHeaderSuffix.h
Ogre::PatchSurface::mIndexOffset
size_t mIndexOffset
Definition: OgrePatchSurface.h:224
Ogre::PatchSurface::VS_BACK
The side from which u goes right and v goes down (reverse of texture coords)
Definition: OgrePatchSurface.h:75
Ogre::PatchSurface::mVLevel
size_t mVLevel
V-direction subdivision level.
Definition: OgrePatchSurface.h:194
Ogre::PatchSurface::mVertexOffset
size_t mVertexOffset
Definition: OgrePatchSurface.h:223
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::PatchSurface::mDeclaration
VertexDeclaration * mDeclaration
Vertex declaration describing the control point buffer.
Definition: OgrePatchSurface.h:180
OgreHeaderPrefix.h
Ogre::PatchSurface::VisibleSide
VisibleSide
Definition: OgrePatchSurface.h:71
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::PatchSurface
A surface which is defined by curves of some kind to form a patch, e.g.
Definition: OgrePatchSurface.h:53
Ogre::PatchSurface::mCtlCount
size_t mCtlCount
TotalNumber of control points.
Definition: OgrePatchSurface.h:190
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
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::mIndexBuffer
HardwareIndexBufferSharedPtr mIndexBuffer
Definition: OgrePatchSurface.h:222
Ogre::PatchSurface::mCurrIndexCount
size_t mCurrIndexCount
Definition: OgrePatchSurface.h:227
Ogre::PatchSurface::mULevel
size_t mULevel
U-direction subdivision level.
Definition: OgrePatchSurface.h:192
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::PatchSurface::mCtlWidth
size_t mCtlWidth
Width in control points.
Definition: OgrePatchSurface.h:186

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