gee_lines.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /* COPYRIGHT
00004  *
00005  * This file is part of the Visual Effects Engine - VEE
00006  *
00007  * Read the "VEE-LICENSE" file for the license.
00008  *
00009  * Authors & Copyright:   
00010  *
00011  * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 
00012  * Janne Kontkanen 2001-2004
00013  *
00014  * Additional copyrights: Tekes 2003-2004
00015  *
00016  * firstname.lastname@hut.fi
00017  *
00018  */
00019 
00020 #ifndef GEE_LINES_H
00021 #define GEE_LINES_H
00022 
00023 #include <gee_geometry.h>
00024 
00025 #include <vee_bounding_box.h>
00026 #include <vee_vector4.h>
00027 
00028 #include <map>
00029 
00030 class GEE_LineVertex3D
00031 {
00032 public:
00033   GEE_LineVertex3D(const VEE_Vector3 & location = VEE_Vector3ZERO,
00034        const VEE_Vector4 & rgba = VEE_Vector4ONE,
00035        bool continues = true) 
00036     : m_location(location), m_rgba(rgba), 
00037       m_mixture(0.0), m_continues(continues) {}
00038 
00039   bool read(GEE_Io *);
00040   bool write(GEE_Io *);
00041 
00042   VEE_Vector3 m_location;
00043   VEE_Vector4 m_rgba;
00044   float       m_mixture;
00046   bool        m_continues;
00047 };
00048 
00051 
00059 class GEE_Lines3D : public GEE_Geometry
00060 {
00061 public:
00062 
00063   typedef std::map<int, GEE_LineVertex3D> container;
00064   typedef container::iterator iterator;
00065 
00066   GEE_Lines3D();
00067   virtual ~GEE_Lines3D();
00068   
00069   static GEE_Geometry * create();
00070   virtual GEE_Geometry * clone() const;
00071   virtual bool eraseData(GEE_Containment *);
00072   virtual bool intersects(GEE_Containment *);
00073   virtual bool colorData(GEE_ReColor *);
00074   virtual bool moveData(GEE_Mover *);
00075   virtual void setMaterial(const GEE_Material &m);
00076   virtual bool getBoundingBox(VEE_BoundingBox *);
00077   virtual void render(GEE_Renderer *);
00078 
00079   virtual bool read(GEE_Io *);
00080   virtual bool write(GEE_Io *);
00081 
00082   void addVertex(int index, const GEE_LineVertex3D &vertex);
00083   void addVertex(const GEE_LineVertex3D &vertex)
00084   { addVertex(newIndex(), vertex); }
00085   
00086   void addVertex(int index, float x, float y, float z, bool continues = true)
00087   { 
00088     addVertex(index, GEE_LineVertex3D(VEE_Vector3(x, y, z), 
00089              VEE_Vector4ONE, 
00090              continues));
00091   }
00092 
00093   void addVertex(float x, float y, float z, bool continues = true)
00094   { addVertex(newIndex(), x, y, z, continues); }
00095 
00096   iterator begin() { return m_vertices.begin(); }
00097   iterator end()   { return m_vertices.end(); }
00098 
00099   uint vertexCount() const { return m_vertices.size(); }
00100 
00101   static GEE_LineVertex3D & getVertex(iterator & it) { return (*it).second; }
00102   static VEE_Vector3 & getVertexLocation(iterator & it) 
00103   { return (*it).second.m_location; }
00104 
00105   float width() const { return m_lineWidth; }
00106   void setWidth(float w) { m_lineWidth = w; }
00107 
00108   int newIndex()
00109   {
00110     if(!m_vertices.size())
00111       return 0;
00112 
00113     iterator it = m_vertices.end();
00114     it--;
00115     return (*it).first + 1;
00116   }
00117 
00118 protected:
00119   container       m_vertices;
00120 
00121   float           m_lineWidth;
00122   VEE_BoundingBox m_bbox;
00123 };
00124 
00125 #endif

Generated on Mon Mar 12 21:09:00 2007 for VEE - The Visual Effects Engine by  doxygen 1.4.6