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_META_BALLS_H 00021 #define VEE_META_BALLS_H 00022 00023 #include <vee_vector3.h> 00024 00025 #include <di_types.h> 00026 00027 #include <vector> 00028 00029 class VEE_BoundingBox; 00030 00033 class VEE_MetaBalls 00034 { 00035 public: 00036 VEE_MetaBalls(); 00037 ~VEE_MetaBalls(); 00038 00039 class Ball 00040 { 00041 public: 00042 00043 VEE_Vector3 m_center; 00044 float m_radius; 00045 00046 inline float presence(const VEE_Vector3 &loc, float rfull) 00047 { 00048 float radius = (loc - m_center).length(); 00049 00050 if(radius > m_radius) 00051 return 0.0f; 00052 00053 if(radius / m_radius < rfull) 00054 return 1.0f; 00055 00056 float tmp1 = (m_radius - radius); 00057 float tmp2 = (m_radius * (1.0 - rfull)); 00058 return tmp1 / tmp2; 00059 } 00060 }; 00061 00062 unsigned nofBalls() const { return m_balls.size(); } 00063 00064 Ball & getBall(uint i) { return m_balls[i]; } 00065 00066 void addBall(const VEE_Vector3 & center, float radius) 00067 { 00068 Ball ball; 00069 ball.m_center = center; 00070 ball.m_radius = radius; 00071 00072 m_balls.push_back(ball); 00073 } 00074 00075 float presence(const VEE_Vector3 &loc, float rfull); 00076 00077 void getBoundingBox(VEE_BoundingBox *) const; 00078 00079 void clear() { m_balls.clear(); } 00080 00081 protected: 00082 00083 std::vector<Ball> m_balls; 00084 }; 00085 00086 00087 #endif