vee_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 VEE_OBJECT_H
00021 #define VEE_OBJECT_H
00022 
00023 #include <vee_config.h> 
00024 #include <vee_has_values.h> 
00025 #include <vee_has_variables.h> 
00026 
00027 #include <sys/types.h> 
00028 
00029 class VEE_RenderClass;
00030 class VEE_Renderer;
00031 class VEE_SceneBox;
00032 
00033 enum VEE_ForceType {
00034   VEE_FORCE_GRAVITY,
00035   VEE_FORCE_DRAG,
00036   VEE_FORCE_HIDDEN,
00037   VEE_FORCE_SIZEOF
00038 };
00039 
00042 enum VEE_ObjectType {
00044   VEE_OBJECT_UNKNOWN,
00046   VEE_OBJECT_PARTICLE,
00048   VEE_OBJECT_RIGID_PARTICLE,
00050   VEE_OBJECT_TAIL_PARTICLE,
00052   VEE_OBJECT_CURVE_PARTICLE,
00054   VEE_OBJECT_FORCE,
00056   VEE_OBJECT_POLYGON,
00058   VEE_OBJECT_SOURCE,
00060   VEE_OBJECT_SIZEOF
00061 };
00062 
00065 class VEE_ParticleVisualInfo
00066 {
00067 public:
00068 
00069   VEE_ParticleVisualInfo() 
00070     : m_color(VEE_Rgba::White), m_texture(-1), m_size(0.0), 
00071       m_rotationRadians(0.0), m_omega(0.0), m_renderClass(0)
00072   { m_location.clear(); m_velocity.clear(); }
00073 
00074   VEE_ParticleVisualInfo(const VEE_Vector3 &location,  
00075        const VEE_Vector3 &velocity)
00076     : m_color(VEE_Rgba::White), m_location(location), m_velocity(velocity),
00077       m_texture(-1), m_size(0.0), 
00078       m_rotationRadians(0.0), m_omega(0.0), m_renderClass(0) {}
00079 
00080   ~VEE_ParticleVisualInfo() {}
00081   
00082   const VEE_Rgba & color() const { return m_color; }
00083   void setColor(const VEE_Rgba & c) { m_color = c; }
00084 
00085   VEE_Vector3 & location() { return m_location; }
00086   const VEE_Vector3 & location() const { return m_location; }
00087   VEE_Vector3 & velocity() { return m_velocity; }
00088   const VEE_Vector3 & velocity() const { return m_velocity; }
00089 
00090   void setLocation(const VEE_Vector3 &l) { m_location = l; }
00091   void setVelocity(const VEE_Vector3 &v) { m_velocity = v; }
00092   void setLocation3(float x, float y, float z) { m_location.make(x, y, z); }
00093   void setVelocity3(float x, float y, float z) { m_velocity.make(x, y, z); }
00094 
00095   int  texture() const { return m_texture; }
00096   void setTexture(int id) { m_texture = id; }
00097 
00098   float size() const { return m_size; }
00099   void setSize(float s) { m_size = s; }
00100 
00101   float rotation() const { return m_rotationRadians; }
00102   void setRotation(float radians) { m_rotationRadians = radians; }
00103 
00104   float omega() const { return m_omega; }
00105   void setOmega(float omega) { m_omega = omega; }
00106 
00107   void setRenderClass(VEE_RenderClass *renderClass) 
00108   { m_renderClass = renderClass; }
00109   VEE_RenderClass *renderClass() { return m_renderClass; }
00110 
00111 protected:
00112 
00113   VEE_Rgba m_color;
00114   VEE_Vector3 m_location;
00115   VEE_Vector3 m_velocity;
00116   int         m_texture;
00117   float       m_size;
00118   float       m_rotationRadians;
00119   float       m_omega;
00120   VEE_RenderClass *m_renderClass;
00121 };
00122 
00123 
00130 class VEE_Object : public VEE_HasValues, 
00131        public VEE_HasVariables,
00132        public VEE_ParticleVisualInfo
00133 {
00134 public:
00135 #ifdef VEE_FAST
00136   void addCheckCount() {}
00137   void subCheckCount() {}
00138 #else
00139   void addCheckCount() { m_count++; }  
00140   void subCheckCount() { m_count--; }  
00141   static long count() { return m_count; }
00142 #endif
00143 
00144   VEE_Object();
00145   VEE_Object(VEE_SceneBox *box);
00146   VEE_Object(const VEE_Object &);
00147   VEE_Object(const VEE_Vector3 &location,  
00148        const VEE_Vector3 &velocity, 
00149        float ageLimit = 1e+10);
00150   VEE_Object(const VEE_Vector3 &location,  
00151        float ageLimit = 1e+10);
00152 
00153   virtual ~VEE_Object() {subCheckCount();}
00154 
00155   virtual VEE_Object * clone() const = 0;
00156   
00157   virtual bool setValue(const char *, VEE_Value *);
00158   virtual VEE_Variable getVariable(const char *) const;
00159 
00160   VEE_SceneBox *sceneBox() { return m_sceneBox; }
00161   void setSceneBox(VEE_SceneBox *b) { m_sceneBox = b; }
00162 
00163   // virtual VEE_Vector3 *centralLocation() { return &m_location; }
00165   virtual void update(float);
00167   virtual void updateVelocity(float);
00168   virtual void collision(const VEE_Vector3 &);
00169 
00170   void setVelocityUpdate(bool p) { m_updateVelocity = p; }
00171 
00172   float age() { return m_age; }
00173   void setAge(float age) { m_age = age; }
00174 
00175   float ageLimit() { return m_ageLimit; }
00176   void setAgeLimit(float ageLimit) { m_ageLimit = ageLimit; }
00177 
00179   void setMass(float m) { m_mass = m; }
00180   void setArea(float a) { m_area = a; }
00181   float mass() const { return m_mass; }
00182   float area() const { return m_area; }
00183 
00184   virtual void render(VEE_Renderer *) = 0;
00185 
00186   bool done() const { return m_done; }
00187   void setDone(bool done) { m_done = done; }
00188 
00189   const char * className() const;
00190 
00192   int objectType() const { return m_objectType; }
00193 
00194 protected:
00196   VEE_SceneBox *m_sceneBox;
00197   // VEE_Vector3 m_location, m_velocity;
00198   bool  m_updateVelocity;
00199   float m_age;
00200   float m_ageLimit;
00201 
00203   float m_mass;
00205   float m_area;
00206 
00207   int   m_objectType;
00208 
00209   bool m_done;
00210 
00211 #ifndef VEE_FAST
00212   static long m_count;
00213 #endif
00214 };
00215 
00216 #endif

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