00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef VEE_FORCE_OBJECT_H
00022 #define VEE_FORCE_OBJECT_H
00023
00024 #include <vee_particle2.h>
00025 #include <vee_object_store.h>
00026
00027 class VEE_BoundingBox;
00028
00034 class VEE_ForceObject : public VEE_Particle2
00035 {
00036 public:
00038 VEE_ForceObject() : m_forceType(VEE_FORCE_GRAVITY), m_moved(false),
00039 m_renderAsForce(true),
00040 m_lastUpdateFrame(-1)
00041 { m_updateVelocity = false; m_objectType = VEE_OBJECT_FORCE; }
00042
00043 VEE_ForceObject(const VEE_Vector3 &location, const VEE_Vector3 &velocity,
00044 float ageLimit = 1e+10)
00045 : VEE_Particle2(location, velocity, ageLimit),
00046 m_forceType(VEE_FORCE_GRAVITY), m_moved(false),
00047 m_renderAsForce(true),
00048 m_lastUpdateFrame(-1)
00049 {m_updateVelocity = false; m_objectType = VEE_OBJECT_FORCE; }
00050
00051 VEE_ForceObject(const VEE_Vector3 &location,
00052 float ageLimit = 1e+10)
00053 : VEE_Particle2(location, VEE_Vector3ZERO, ageLimit),
00054 m_forceType(VEE_FORCE_GRAVITY), m_moved(false),
00055 m_renderAsForce(true),
00056 m_lastUpdateFrame(-1)
00057 {m_updateVelocity = false; m_objectType = VEE_OBJECT_FORCE; }
00058
00059 virtual ~VEE_ForceObject();
00060
00061 virtual bool setValue(const char *, VEE_Value *);
00062 virtual VEE_Variable getVariable(const char *) const;
00063
00064 virtual VEE_Vector3 *centralLocation() { return &m_location; }
00065
00066 virtual void setForceType(VEE_ForceType t) { m_forceType = t; }
00067 virtual VEE_ForceType getForceType() { return m_forceType; }
00068 virtual void getForce(VEE_Vector3 *force,
00069 const VEE_Vector3 &velocity,
00070 const VEE_Vector3 &location) = 0;
00071
00077 virtual void boundingBoxOfForce(VEE_BoundingBox *box) = 0;
00078
00079 virtual void render(VEE_Renderer *);
00080
00081 virtual void update(float dt);
00082
00083 void linkBox(VEE_SceneBox *);
00084 void unlinkBox(VEE_SceneBox *);
00085 void unlinkBoxes();
00086 void forgetLinks() { m_boxes.clear(); }
00087 bool isLinked(VEE_SceneBox *b) { return m_boxes.contains(b); }
00088 void updateSceneLocation(int frame);
00089
00090
00091 typedef VEE_PointerStoreSet<VEE_SceneBox> boxStore;
00092
00093 boxStore &boxes() { return m_boxes; }
00094
00095 bool renderAsForce() const { return m_renderAsForce; }
00096
00097 protected:
00098 VEE_ForceType m_forceType;
00099
00100 boxStore m_boxes;
00101
00102
00103 bool m_moved;
00104 bool m_renderAsForce;
00105 int m_lastUpdateFrame;
00106 };
00107
00108
00109 void VEE_calculateCubeBounds(VEE_BoundingBox *bb,
00110 const VEE_Matrix3 &rotation,
00111 const VEE_Vector3 &corner);
00112
00113 #endif