Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 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 "OgreGeometryData.h"
00032 #include "OgreString.h"
00033 
00034 namespace Ogre {
00035 
00042     class _OgreExport PatchSurface
00043     {
00044     public:
00045         PatchSurface();
00046         ~PatchSurface();
00047 
00048         enum PatchSurfaceType
00049         {
00051             PST_BEZIER
00052         };
00053 
00055         enum
00056         {
00057             AUTO_LEVEL = -1
00058         };
00059 
00060         enum VisibleSide {
00062             VS_FRONT,
00064             VS_BACK,
00066             VS_BOTH
00067         };
00090         void defineSurface(String meshName, const GeometryData& controlPoints, int width,
00091             PatchSurfaceType pType = PST_BEZIER, int subdivisionLevel = AUTO_LEVEL,
00092             VisibleSide visibleSide = VS_FRONT);
00093 
00099         void build(void);
00100 
00109         void setSubdivisionLevel(int level = AUTO_LEVEL);
00110 
00121         Mesh* getMesh(void);
00122     protected:
00124         String mMeshName;
00126         GeometryData mCtlPointData;
00128         Mesh* mMesh;
00130         bool mNeedsBuild;
00132         PatchSurfaceType mType;
00134         int mCtlWidth;
00136         int mCtlHeight;
00138         int mULevel;
00140         int mVLevel;
00142         int mMeshWidth;
00144         int mMeshHeight;
00146         VisibleSide mVSide;
00147 
00148         bool mSharedVertexData;
00149         bool mMemoryAllocated;
00150 
00151         std::vector<Vector3> mVecCtlPoints;
00152 
00153         // Steps for use in buffers
00154         int mBufPosStep, mBufNormStep, mBufColourStep, mBufTexCoordStep[OGRE_MAX_TEXTURE_COORD_SETS] ;
00155 
00158         int findLevel( Vector3& a, Vector3& b, Vector3& c);
00159 
00160         void allocateMemory(void);
00161         void deallocateMemory(void);
00162         void distributeControlPoints(void);
00163         void subdivideCurve(int startIdx, int stepSize, int numSteps, int iterations);
00164         void interpolateVertexData(int leftIndex, int rightIndex, int destIndex);
00165         void makeTriangles(void);
00166 
00167 
00168 
00169     };
00170 
00171 
00172 } // namespace
00173 
00174 #endif

Copyright © 2002 by The OGRE Team