/usr/include/OGRE/OgrePatchSurface.h is in libogre-dev 1.7.4+dfsg1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 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"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup LOD
* @{
*/
/** 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.
*/
class _OgreExport PatchSurface : public PatchAlloc
{
public:
PatchSurface();
~PatchSurface();
enum PatchSurfaceType
{
/// A patch defined by a set of bezier curves
PST_BEZIER
};
/// Constant for indicating automatic determination of subdivision level for patches
enum
{
AUTO_LEVEL = -1
};
enum VisibleSide {
/// The side from which u goes right and v goes up (as in texture coords)
VS_FRONT,
/// The side from which u goes right and v goes down (reverse of texture coords)
VS_BACK,
/// Both sides are visible - warning this creates 2x the number of triangles and adds extra overhead for calculating normals
VS_BOTH
};
/** 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)
@param
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
@param
declaration VertexDeclaration describing the contents of the buffer.
Note this declaration must _only_ draw on buffer source 0!
@param
width Specifies the width of the patch in control points.
@param
height Specifies the height of the patch in control points.
@param
pType The type of surface - currently only PST_BEZIER is supported
@param
uMaxSubdivisionLevel,vMaxSubdivisionLevel If you want to manually set the top level of subdivision,
do it here, otherwise let the system decide.
@param
visibleSide Determines which side of the patch (or both) triangles are generated for.
*/
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);
/** 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.
*/
size_t getRequiredVertexCount(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.
*/
size_t getRequiredIndexCount(void) const;
/** Gets the current index count based on the current subdivision level. */
size_t getCurrentIndexCount(void) const;
/// Returns the index offset used by this buffer to write data into the buffer
size_t getIndexOffset(void) const { return mIndexOffset; }
/// Returns the vertex offset used by this buffer to write data into the buffer
size_t getVertexOffset(void) const { return mVertexOffset; }
/** Gets the bounds of this patch, only valid after calling defineSurface. */
const AxisAlignedBox& getBounds(void) const;
/** Gets the radius of the bounding sphere for this patch, only valid after defineSurface
has been called. */
Real getBoundingSphereRadius(void) const;
/** 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.
@param destVertexBuffer The destination vertex buffer in which to build the patch.
@param vertexStart The offset at which to start writing vertices for this patch
@param destIndexBuffer The destination index buffer in which to build the patch.
@param vertexStart The offset at which to start writing indexes for this patch
*/
void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
/** 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.
*/
void setSubdivisionFactor(Real factor);
/** Gets the current level of subdivision. */
Real getSubdivisionFactor(void) const;
void* getControlPointBuffer(void) const
{
return mControlPointBuffer;
}
/** Convenience method for telling the patch that the control points have been
deleted, since once the patch has been built they are not required. */
void notifyControlPointBufferDeallocated(void) {
mControlPointBuffer = 0;
}
protected:
/// Vertex declaration describing the control point buffer
VertexDeclaration* mDeclaration;
/// Buffer containing the system-memory control points
void* mControlPointBuffer;
/// Type of surface
PatchSurfaceType mType;
/// Width in control points
size_t mCtlWidth;
/// Height in control points
size_t mCtlHeight;
/// TotalNumber of control points
size_t mCtlCount;
/// U-direction subdivision level
size_t mULevel;
/// V-direction subdivision level
size_t mVLevel;
/// Max subdivision level
size_t mMaxULevel;
size_t mMaxVLevel;
/// Width of the subdivided mesh (big enough for max level)
size_t mMeshWidth;
/// Height of the subdivided mesh (big enough for max level)
size_t mMeshHeight;
/// Which side is visible
VisibleSide mVSide;
Real mSubdivisionFactor;
vector<Vector3>::type mVecCtlPoints;
/** Internal method for finding the subdivision level given 3 control points.
*/
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
#endif
|