gee_particle_object.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_PARTICLE_OBJECT_H
00021 #define GEE_PARTICLE_OBJECT_H
00022 
00023 #include <gee_geometry.h>
00024 
00025 
00026 #include <vee_bounding_box.h>
00027 #include <vee_clonable_pointer.h>
00028 #include <vee_color.h>
00029 #include <vee_object.h>
00030 
00031 #include <list>
00032 
00038 class GEE_ParticleData
00039 {
00040 public:
00041   GEE_ParticleData(const VEE_Vector3 & location = VEE_Vector3ZERO,
00042        const VEE_Vector3 & velocity = VEE_Vector3ZERO,
00043        const VEE_Rgba    & color = VEE_Rgba::White,
00044        const std::string & textureName = "",
00045        float               size = 1.0)
00046     : m_location(location),
00047       m_velocity(velocity),
00048       m_color(color),
00049       m_textureName(textureName),
00050       m_texture(-1),
00051       m_size(size),
00052       m_rotation(0.0f)
00053   {}
00054 
00055   void setSize(float s)
00056   {
00057     m_size = s;
00058     if(m_particle.ptr())
00059       m_particle.ptr()->setSize(s);
00060   }
00061 
00062   void setRotation(float r)
00063   {
00064     m_rotation = r;
00065     if(m_particle.ptr())
00066       m_particle.ptr()->setRotation(r);
00067   }
00068 
00069   void setLocation(const VEE_Vector3 & loc)
00070   {
00071     m_location = loc;
00072     if(m_particle.ptr())
00073       m_particle.ptr()->setLocation(loc);
00074   }
00075 
00076   void setVelocity(const VEE_Vector3 & vel)
00077   {
00078     m_velocity = vel;
00079     if(m_particle.ptr())
00080       m_particle.ptr()->setVelocity(vel);
00081   }
00082 
00083   void setColor(const VEE_Rgba & c)
00084   {
00085     m_color = c;
00086     if(m_particle.ptr())
00087       m_particle.ptr()->setColor(c);
00088   }
00089 
00090   void setTexture(const std::string & texName, int t)
00091   {
00092     m_textureName = texName;
00093     setTexture(t);
00094   }
00095 
00096   void setTexture(int t)
00097   {
00098     m_texture = t;
00099     if(m_particle.ptr())
00100       m_particle.ptr()->setTexture(t);
00101   }
00102 
00103   void setObject(VEE_Object * obj)
00104   {
00105     if(obj) {
00106       obj->setLocation(m_location);
00107       obj->setVelocity(m_velocity);
00108       obj->setColor(m_color);
00109     }
00110     
00111     m_particle = obj;
00112   }
00113 
00114   void setRenderClass(const std::string & className, VEE_RenderClass * rc)
00115   {
00116     m_renderClassName = className;
00117     
00118     if(m_particle.ptr())
00119       m_particle.ptr()->setRenderClass(rc);
00120   }
00121 
00122   bool read(GEE_Io *);
00123   bool write(GEE_Io *);  
00124 
00125   VEE_Vector3 m_location;
00126   VEE_Vector3 m_velocity;
00127   VEE_Rgba    m_color;
00128   std::string m_textureName;
00129   int         m_texture;
00130   float       m_size;
00131   float       m_rotation;
00132 
00133   std::string m_renderClassName;
00134 
00135   VEE_ClonablePointer<VEE_Object> m_particle;
00136 };
00137 
00140 
00145 class GEE_ParticleObject : public GEE_Geometry
00146 {
00147 public:
00148 
00149   typedef std::list<GEE_ParticleData>::iterator iterator;
00150 
00151   GEE_ParticleObject();
00152   virtual ~GEE_ParticleObject();
00153   
00154   static GEE_Geometry * create();
00155   virtual GEE_Geometry * clone() const;
00156   virtual bool eraseData(GEE_Containment *);  
00157   virtual bool intersects(GEE_Containment *);
00158   virtual bool colorData(GEE_ReColor *);
00159   virtual bool moveData(GEE_Mover *);
00160   virtual void render(GEE_Renderer *);
00161   virtual bool getBoundingBox(VEE_BoundingBox *);
00162   virtual void setMaterial(const GEE_Material &m);
00163 
00164   virtual bool read(GEE_Io *);
00165   virtual bool write(GEE_Io *);
00166 
00167   GEE_Geometry * removeData(const VEE_Vector3 &loc, float radius);
00168   void addParticle(const GEE_ParticleData &);
00169 
00170   void retexture(GEE_Containment *, const std::string & texName, int texId);
00171 
00172   iterator begin() { return m_particles.begin(); }
00173   iterator end()   { return m_particles.end(); }
00174   uint particleCount() const { return m_particles.size(); }
00175 
00176   static GEE_ParticleData & getParticleData(iterator & it) { return *it; }
00177 
00178 protected:
00179 
00180   std::list<GEE_ParticleData> m_particles;
00181   VEE_BoundingBox             m_bbox;
00182 };
00183 
00184 #endif

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