00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00118
00119
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 );
00125 virtual void fillCSGFace ( GeometryIterator *gi, CSG_IFace *face );
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
00132 public: list<Vertex*> vertices;
00133 protected: Vector normal;
00134 };
00135
00136
00137 };
00138 };
00139
00140
00141 #endif // TEDDY__MODELS__ELEMENT__H
00142