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

Element.h

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Element.h,v 1.7 2002/02/16 12:41:39 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__MODELS__ELEMENT__H
00026 #define TEDDY__MODELS__ELEMENT__H
00027 
00028 
00029 #include "Teddy/Maths/Vector.h"
00030 #include "Teddy/SysSupport/StdList.h"
00031 #include "Teddy/MixIn/Options.h"
00032 #if defined( TEDDY_INCLUDE_COLDET )
00033 # include "Teddy/ColDet/ColDet.h"
00034 #endif
00035 #if 0
00036 # include "Teddy/Bsp/CSG_BooleanOps.h"
00037 #endif
00038 
00039 
00040 //  Forward declarations
00041 namespace Teddy {
00042     namespace Maths              { class Matrix;     };
00043     namespace PhysicalComponents { class Projection; };
00044 };
00045 using namespace Teddy::Maths;
00046 using namespace Teddy::PhysicalComponents;
00047 using namespace Teddy::MixIn;
00048 
00049 
00050 namespace Teddy  {
00051 namespace Models {
00052 
00053 
00054 class  Vertex;
00055 class  GeometryIterator;
00056 
00057 
00061 class Element : public Options {
00062 public:
00063     static const unsigned long EL_HAS_ELEMENT_NORMAL;
00064     static const unsigned long EL_USE_ELEMENT_NORMAL;
00065     static const unsigned long EL_USE_VERTEX_NORMALS;
00066 
00067     static const unsigned long VX_HAS_PARENT;        
00068     static const unsigned long VX_HAS_VERTEX;        
00069     static const unsigned long VX_HAS_NORMAL;        
00070     static const unsigned long VX_HAS_COLOR;         
00071     static const unsigned long VX_HAS_TEXTURE;       
00072 
00073     static const unsigned long VX_USE_THIS_VERTEX;   
00074     static const unsigned long VX_USE_THIS_NORMAL;   
00075     static const unsigned long VX_USE_THIS_COLOR;    
00076     static const unsigned long VX_USE_THIS_TEXTURE;  
00077 
00078     static const unsigned long VX_USE_PARENT_VERTEX; 
00079     static const unsigned long VX_USE_PARENT_NORMAL; 
00080     static const unsigned long VX_USE_PARENT_COLOR;  
00081     static const unsigned long VX_USE_PARENT_TEXTURE;
00082      
00083     static const unsigned long VX_TRAVERSAL_VISITED; 
00084 
00085     static const unsigned long VX_USE_PARENT_ALL;
00086 
00087 public:
00088     Element( unsigned long options = 0 );
00089     virtual ~Element();
00090 
00091     virtual void        draw        ( Projection *p ) = 0;
00092     virtual void        debug       ();
00093 
00094     virtual void        add         ( const float x, const float y, const float z );
00095     virtual void        add         ( Vertex *v );
00096     virtual void        append      ( const float x, const float y, const float z );
00097     virtual void        append      ( Vertex *v );
00098     virtual void        reverse     ();
00099     virtual bool        contains    ( const Vertex *v ) const;
00100 
00101     virtual void        makeNormal  ();
00102     virtual void        makeConvexNormal();
00103 
00104     virtual void        smooth      ( float max_smoothing_angle );
00105 
00106     void                setNormal   ( const Vector &normal );
00107     void                setNormal   ( const float x, const float y, const float z );
00108     const Vector       &getNormal   () const;
00109     virtual double      getMaxVector() const;
00110 
00111     void                clearTraversal     ();
00112     virtual void        transformVertices  ( const Matrix &m, const Matrix &normal_matrix, const bool reverse );
00113 
00114 #if defined( TEDDY_INCLUDE_COLDET )
00115     virtual int         addToCollisionModel( Teddy::ColDet::CollisionModel3D *collision_model );
00116 #endif
00117     //  virtual GtsSurface *makeSurface        (){ return NULL; }
00118 
00119     //  CSG
00120 #if 0
00121     virtual unsigned long countCSGFaceElements  ();
00122     virtual unsigned long countCSGVertexElements();
00123     virtual void          initCSGFace           ( GeometryIterator *gi );
00124     virtual bool          stepCSGFace           ( GeometryIterator *gi );  //  = 0
00125     virtual void          fillCSGFace           ( GeometryIterator *gi, CSG_IFace *face );  // = 0
00126     virtual void          initCSGVertex         ( GeometryIterator *gi );
00127     virtual bool          stepCSGVertex         ( GeometryIterator *gi );
00128     virtual void          fillCSGVertex         ( GeometryIterator *gi, CSG_IVertex *vertex );
00129 #endif
00130 
00131     //  vertices -member is public for easy access from Model texture coordinate code
00132     public:    list<Vertex*> vertices;
00133     protected: Vector        normal;
00134 };
00135 
00136 
00137 };  //  namespace Models
00138 };  //  namespace Teddy
00139 
00140 
00141 #endif  //  TEDDY__MODELS__ELEMENT__H
00142