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

patch.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           patch.h  -  Patch surfaces
00003                              -------------------
00004     begin                : Thu May 2 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, patch.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 #ifndef __NEPATCH_H
00028 #define __NEPATCH_H
00029 
00030 
00031 
00038 #include "base.h"
00039 #include "nemath.h"
00040 #include "submesh.h"
00041 #include "vertex.h"
00042 #include "polygon.h"
00043 
00044 #include <string>
00045 
00046 
00047 namespace NeoEngine
00048 {
00049 
00050 
00051 //Forward declarations
00052 class PatchSurfaceTesselator;
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00065 class NEOENGINE_API PatchSurfaceData
00066 {
00067     public:
00068 
00073         enum PATCHSURFACETYPE
00074         {
00075           BEZIER                              = 0x00000001
00076         };
00077 
00082         enum PATCHSURFACEVISIBLE
00083         {
00084           VISIBLE_FRONT                       = 0x00000001,
00085           VISIBLE_BACK                        = 0x00000002,
00086           VISIBLE_BOTH                        = 0x00000003
00087         };
00088 
00089 
00090     public:
00091 
00093         PATCHSURFACETYPE                    m_ePatchType;
00094 
00096         PATCHSURFACEVISIBLE                 m_eVisibleSide;
00097 
00099         VertexBufferPtr                     m_pkControlPoints;
00100 
00102         int                                 m_iControlWidth;
00103 
00105         int                                 m_iControlHeight;
00106 
00108         int                                 m_iULevel;
00109 
00111         int                                 m_iVLevel;
00112 
00114         int                                 m_iTessWidth;
00115 
00117         int                                 m_iTessHeight;
00118 
00119 
00120 
00124                                             PatchSurfaceData();
00125 
00129         virtual                            ~PatchSurfaceData();
00130 
00136         const PatchSurfaceData             &operator =( const PatchSurfaceData &rkPatchData );
00137 };
00138 
00139 
00140 
00141 
00142 
00148 class NEOENGINE_API PatchSurfaceSubMesh : public SubMesh
00149 {
00150     friend class PatchSurfaceTesselator;
00151     friend class QuadraticBezierPatchTesselator;
00152     
00153     protected:
00154 
00156         PatchSurfaceData                  m_kPatchData;
00157 
00159         PatchSurfaceTesselator           *m_pkTesselator;
00160 
00164         virtual void                        UpdateData();
00165 
00166 
00167 
00168     public:
00169 
00173                                             PatchSurfaceSubMesh( const PatchSurfaceData &rkPatchData );
00174 
00178                                             PatchSurfaceSubMesh( const PatchSurfaceSubMesh &rkSubMesh );
00179 
00182         virtual                            ~PatchSurfaceSubMesh();
00183 
00187         virtual VertexBufferPtr             GetControlVertexBuffer() { return m_kPatchData.m_pkControlPoints; }
00188 
00192         const virtual PatchSurfaceData     &GetPatchData() const { return m_kPatchData; }
00193 
00198         virtual void                        SetVertexBuffer( VertexBufferPtr pkVertices ) {}
00199 
00204         virtual void                        SetPolygonBuffer( PolygonBufferPtr pkPolygons ) {}
00205 
00209         virtual SubMesh                    *Duplicate() const;
00210 
00214         virtual unsigned int                GetType() const { return PATCHSURFACE; }
00215 };
00216 
00217 
00218 
00219 
00225 class NEOENGINE_API PatchSurfaceTesselator
00226 {
00227     public:
00228 
00231                                             PatchSurfaceTesselator();
00232 
00235         virtual                            ~PatchSurfaceTesselator();
00236 
00243         void                                SetSubdivisionLevel( PatchSurfaceData *pkPatchData, int iULevel = -1, int iVLevel = -1 );
00244 
00250         virtual void                        Tesselate( PatchSurfaceData *pkPatchData, PatchSurfaceSubMesh *pkShard );
00251 
00257         virtual void                        InterpolateVertices( PatchSurfaceData *pkPatchData, VertexBufferPtr pkVertexBuffer );
00258 };
00259 
00260 
00261 
00262 
00263 
00269 class NEOENGINE_API QuadraticBezierPatchTesselator : public PatchSurfaceTesselator
00270 {
00271     public:
00272 
00275                                             QuadraticBezierPatchTesselator();
00276 
00279         virtual                            ~QuadraticBezierPatchTesselator();
00280 
00286         virtual void                        InterpolateVertices( PatchSurfaceData *pkPatchData, VertexBufferPtr pkVertexBuffer );
00287 };
00288 
00289 
00290 }; // namespace NeoEngine
00291 
00292 
00293 
00294 #endif // __NEPATCH_H

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5