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

OgrePatchSurface.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __PatchSurface_H__
00026 #define __PatchSurface_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 #include "OgreVector3.h"
00031 #include "OgreString.h"
00032 #include "OgreRenderOperation.h"
00033 #include "OgreAxisAlignedBox.h"
00034 
00035 namespace Ogre {
00036 
00043     class _OgreExport PatchSurface
00044     {
00045     public:
00046         PatchSurface();
00047         ~PatchSurface();
00048 
00049         enum PatchSurfaceType
00050         {
00052             PST_BEZIER
00053         };
00054 
00056         enum
00057         {
00058             AUTO_LEVEL = -1
00059         };
00060 
00061         enum VisibleSide {
00063             VS_FRONT,
00065             VS_BACK,
00067             VS_BOTH
00068         };
00096         void defineSurface(void* controlPointBuffer, 
00097             VertexDeclaration *declaration, size_t width, size_t height,
00098             PatchSurfaceType pType = PST_BEZIER, 
00099             size_t uMaxSubdivisionLevel = AUTO_LEVEL, size_t vMaxSubdivisionLevel = AUTO_LEVEL,
00100             VisibleSide visibleSide = VS_FRONT);
00101 
00107         size_t getRequiredVertexCount(void) const;
00113         size_t getRequiredIndexCount(void) const;
00114 
00116         size_t getCurrentIndexCount(void) const;
00118         size_t getIndexOffset(void) const { return mIndexOffset; }
00120         size_t getVertexOffset(void) const { return mVertexOffset; }
00121 
00122 
00124         const AxisAlignedBox& getBounds(void) const;
00127         Real getBoundingSphereRadius(void) const;
00143         void build(HardwareVertexBufferSharedPtr destVertexBuffer, size_t vertexStart,
00144             HardwareIndexBufferSharedPtr destIndexBuffer, size_t indexStart);
00145 
00154         void setSubdivisionFactor(Real factor);
00155 
00157         Real getSubdivisionFactor(void) const;
00158 
00159         void* getControlPointBuffer(void) const
00160         {
00161             return mControlPointBuffer;
00162         }
00165         void notifyControlPointBufferDeallocated(void) { 
00166             mControlPointBuffer = 0;
00167         }
00168     protected:
00170         VertexDeclaration* mDeclaration;
00172         void* mControlPointBuffer;
00174         PatchSurfaceType mType;
00176         size_t mCtlWidth;
00178         size_t mCtlHeight;
00180         size_t mCtlCount;
00182         size_t mULevel;
00184         size_t mVLevel;
00186         size_t mMaxULevel;
00187         size_t mMaxVLevel;
00189         size_t mMeshWidth;
00191         size_t mMeshHeight;
00193         VisibleSide mVSide;
00194 
00195         Real mSubdivisionFactor;
00196 
00197         std::vector<Vector3> mVecCtlPoints;
00198 
00201         size_t findLevel( Vector3& a, Vector3& b, Vector3& c);
00202 
00203         void distributeControlPoints(void* lockedBuffer);
00204         void subdivideCurve(void* lockedBuffer, size_t startIdx, size_t stepSize, size_t numSteps, size_t iterations);
00205         void interpolateVertexData(void* lockedBuffer, size_t leftIndex, size_t rightIndex, size_t destIndex);
00206         void makeTriangles(void);
00207 
00208         size_t getAutoULevel(bool forMax = false);
00209         size_t getAutoVLevel(bool forMax = false);
00210 
00211         HardwareVertexBufferSharedPtr mVertexBuffer;
00212         HardwareIndexBufferSharedPtr mIndexBuffer;
00213         size_t mVertexOffset;
00214         size_t mIndexOffset;
00215         size_t mRequiredVertexCount;
00216         size_t mRequiredIndexCount;
00217         size_t mCurrIndexCount;
00218 
00219         AxisAlignedBox mAABB;
00220         Real mBoundingSphere;
00221 
00222 
00223 
00224     };
00225 
00226 
00227 } // namespace
00228 
00229 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:46 2006