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

Geometry.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:  $
00022 */
00023 
00024 
00025 #ifndef TEDDY__MODELS__GEOMETRY__H
00026 #define TEDDY__MODELS__GEOMETRY__H
00027 
00028 
00029 #if defined( TEDDY_INCLUDE_COLDET )
00030 # include "Teddy/ColDet/ColDet.h"
00031 #endif
00032 #include "Teddy/Maths/Vector.h"
00033 #include "Teddy/SysSupport/StdList.h"
00034 #if 0
00035 # include "Teddy/Bsp/CSG_BooleanOps.h"
00036 #endif
00037 
00038 
00039 //  Forward declarations
00040 namespace Teddy {
00041     namespace Maths              { class Matrix;     };
00042     namespace PhysicalComponents { class Projection; };
00043 };
00044 using namespace Teddy::Maths;
00045 using namespace Teddy::PhysicalComponents;
00046 
00047 
00048 namespace Teddy  {
00049 namespace Models {
00050 
00051 
00052 class Element;
00053 class Vertex;
00054 
00055 
00056 #define TEXTURE_AXIS_X 0
00057 #define TEXTURE_AXIS_Y 1
00058 #define TEXTURE_AXIS_Z 2
00059 
00060 
00062 class Geometry {
00063 public:
00064     Geometry();
00065     virtual ~Geometry();
00066 
00067     void            insert           ( Element    *e );
00068     virtual void    beginElements    ( Projection *p );
00069     virtual void    drawElements     ( Projection *p );
00070     virtual void    endElements      ( Projection *p );
00071     virtual void    transformVertices( const Matrix &m, const Matrix &normal_matrix, const bool reverse );
00072     void            clearTraversal   ();
00073 
00074     //  Smoothing and texture mapping
00075     double          getMaxVector                     ();
00076     void            smooth                           ( float max_smoothing_angle );
00077     void            makePlanarTextureCoordinates     ( Vector center, Vector size, int axis );
00078     void            makeCylindricalTextureCoordinates( Vector center, Vector size, int axis );
00079     void            makeSphericalTextureCoordinates  ( Vector center, Vector size, int axis );
00080     void            makeCubicTextureCoordinates      ( Vector center, Vector size );
00081     void            setTextureCoordinate             ( Element *e, list<Vertex*>::iterator v_it, float u, float v );
00082 
00083 #if defined( TEDDY_INCLUDE_COLDET )
00084     int             addToCollisionModel              ( Teddy::ColDet::CollisionModel3D *collision_model );
00085 #endif
00086 
00087 public:
00088     list<Element*>  elements;
00089 
00090 //  This part will be splitted to Graphics::Renderable or something
00091 public:
00092     void            draw       ( Projection *p );  
00093     void            beginUpdate( Projection *p );  
00094     void            endUpdate  ( Projection *p );  
00095 
00096 protected:
00097     unsigned int    gl_list_id;     
00098     bool            dirty;          
00099 
00100 public:
00101     static int draw_count;
00102 };
00103 
00104 
00105 };  //  namespace Models
00106 };  //  namespace Teddy
00107 
00108 
00109 #endif  //  TEDDY__MODELS__GEOMETRY__H
00110