arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

subdivPlanarQuadS.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 8/14/02      Aaron Lefohn    Scientific Computing and Imaging Institute
00003 // School of Computing          University of Utah
00004 //
00005 //  This library is free software; you can redistribute it and/or
00006 //  modify it under the terms of the GNU Lesser General Public
00007 //  License as published by the Free Software Foundation; either
00008 //  version 2.1 of the License, or (at your option) any later version.
00009 //
00010 //  This library is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 //  Lesser General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU Lesser General Public
00016 //  License along with this library; if not, write to the Free Software
00017 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 #if !defined(AFX_SUBDIVPLANARQUAD_H__3B8C720A_3269_439D_B67D_27B68936C7E8__INCLUDED_)
00020 #define AFX_SUBDIVPLANARQUAD_H__3B8C720A_3269_439D_B67D_27B68936C7E8__INCLUDED_
00021 
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025 
00026 #include <mathGutz.h>
00027 #include <arrayGutz.h>
00028 #include "planarQuadZ.h"
00029 #include "../texCoordGen/scaleTexGen2D.h"
00030 //#include "pixelTile.h"
00031 
00032 namespace glift {
00033 
00034 typedef std::vector<gutz::vec3f> Vecvec3f;
00035 typedef std::vector<gutz::vec2i> Vecvec2i;
00036 
00037 /////////////////////////////////////////////////////////////////////////
00038 ///
00039 /// subdivPlanarQuad.h: interface for the SubdivPlanarQuadS class.
00040 ///
00041 /// - A subdivided planar quad. 
00042 /// - Currently 'primType' can ONLY be GL_QUADS. \n
00043 ///    (Need different indices generators for GL_TRIANGLES)
00044 /// - Lowerleft and upperRight are assumed to be in the XY plane \n
00045 ///    (only the x,y components are read). 
00046 ///   The quad is therefore always orthogonal to the Z axis with a normal = <0,0,1>
00047 /// - If 'genTexCoords' is true, but no 'altTexGen' is given, the ScaleTexGen2D texCoord
00048 ///   generator is used. The 'altTexGen' parameter is used for alternate tex coord generation.
00049 /// - Generates a SINGLE  primitive using vertex arrays and indices (hence the S in the name)
00050 /// - 'sharedVerts' specifies if the shared-vertex or redundant-vertex subdiv
00051 ///    quad is built.
00052 /// - Patch numbering begins at lower-left and reads right and then up \n
00053 ///    (OpenGL coord convention)
00054 ///////////////////////////////////////////////////////////////////////
00055 
00056 class _export_ SubdivPlanarQuadS : public PlanarQuadZ
00057 {
00058 public:
00059    SubdivPlanarQuadS( GLenum primType, const gutz::vec2i& subDiv,
00060       const gutz::vec2f& lowerLeft, const gutz::vec2f& upperRight, /// z=0.0
00061       bool genTexCoords=false, bool genNorms=false, bool sharedVerts=true,
00062       TexCoordGen* altTexGen=NULL);
00063 
00064    SubdivPlanarQuadS( GLenum primType, const gutz::vec2i& subDiv,
00065       const gutz::vec2f& lowerLeft, const gutz::vec2f& upperRight, float z=0.0f, 
00066       bool genTexCoords=false, bool genNorms=false, bool sharedVerts=true,
00067       TexCoordGen* altTexGen=NULL);
00068 
00069    virtual ~SubdivPlanarQuadS();
00070 
00071    virtual gutz::vec2f lowerLeft()  const {return m_lowerLeft;}
00072    virtual gutz::vec2f upperRight() const {return m_upperRight;}
00073    virtual gutz::vec2i subDiv()  const {return m_subDiv;}
00074    gutz::vec2i lgSubDiv()        const {return m_lgSubDiv;}
00075    virtual float z()                             const {return m_z;}
00076    virtual int   numActivePatches() const {return m_numActivePatches;}
00077    PrimGL* prim()                        const {return m_prim;}
00078 
00079    void bindQuads( const gutz::arrayw1ui& patchIndices );/// Specify which patches are to be drawn by their patch indices
00080    void bindQuads( const Vecvec2i& patches );                     /// Specify which patches are to be drawn by their subdiv coords
00081    void releaseQuads() {releaseIndices();}                                /// Draw all quads
00082 
00083    //   gutz::arrayWrap2<PixelTile*> tiles() const {return gutz::arrayWrap2<PixelTile*>(m_tiles);}
00084 
00085 private:                
00086    gutz::vec2f          m_lowerLeft;
00087    gutz::vec2f          m_upperRight;
00088    float                        m_z;
00089    int                          m_numActivePatches;
00090    gutz::vec2i          m_subDiv;               /// Number of subdivisions in each dimension
00091    gutz::vec2i          m_lgSubDiv;             /// log (base 2) of subDiv. Only valid if m_subDiv components are powers of two.
00092 
00093    gutz::arrayo1ui m_indices;
00094    bool                 m_useShared;    /// Shared or redundant vertex version?
00095    //   gutz::arrayOwn2<PixelTile*> m_tiles;
00096    PrimGL*                      m_prim;
00097    //gutz::arrayo1ui m_curIndices;      /// Current indices
00098 
00099    SubdivPlanarQuadS();/// Disallow default construction, copy, and assignment
00100 
00101    /// Create subDivQuad with shared or redundant vertices (m_useShared controls which)
00102    void init( GLenum primType, const gutz::vec2i& subDiv,
00103       const gutz::vec2f& lowerLeft, const gutz::vec2f& upperRight, 
00104       float z, bool genTexCoords, bool genNorms,
00105       TexCoordGen* texGen );
00106 
00107    // Create the tiles 
00108    //   void initTiles( const gutz::arrayo2f& vert, const gutz::arrayo2f& texCoord, 
00109    //                                   gutz::arrayo1ui& indices );
00110 
00111    /// Create subDivQuad with shared vertices (minimum number of possible verts)
00112    void initShared( const gutz::vec2i& subDiv, const gutz::vec3f& quadScale, float z, const gutz::vec3f& normVec,
00113       gutz::arrayo2f& vert, gutz::arrayo2f& norm, gutz::arrayo1ui& indices );
00114 
00115    /// Create subDivQuad with redundant vertices. Eeach one gets own texCoords and colors
00116    void initRedundant( const gutz::vec2i& subDiv, const gutz::vec3f& quadScale, float z, const gutz::vec3f& normVec, 
00117       gutz::arrayo2f& vert, gutz::arrayo2f& norm, gutz::arrayo1ui& indices );
00118 };
00119 
00120 } /// End of namespace glift
00121 
00122 #endif /// !defined(AFX_SUBDIVPLANARQUAD_H__3B8C720A_3269_439D_B67D_27B68936C7E8__INCLUDED_)

Send questions, comments, and bug reports to:
jmk