00001 /**************************************************************************** 00002 * Copyright 2005 Evan Drumwright 00003 * This library is distributed under the terms of the GNU General Public 00004 * License (found in COPYING). 00005 ****************************************************************************/ 00006 00007 #ifndef _SPHERE_H 00008 #define _SPHERE_H 00009 00010 #include <Physsim/Primitive.h> 00011 00012 namespace Physsim { 00013 00015 class Sphere : public Primitive 00016 { 00017 public: 00018 Sphere(); 00019 Sphere(Real radius); 00020 Sphere(const Matrix4& T); 00021 Sphere(Real radius, unsigned recursion_level); 00022 Sphere(Real radius, const Matrix4& T); 00023 Sphere(Real radius, unsigned recursion_level, const Matrix4& T); 00024 virtual Real calc_mass(); 00025 virtual Matrix3 calc_inertia(); 00026 void set_radius(Real radius); 00027 void set_recursion_level(unsigned level); 00028 virtual void load_from_xml(XMLTreeConstPtr node, std::map<std::string, BasePtr>& id_map); 00029 virtual void save_to_xml(XMLTreePtr node, std::list<BaseConstPtr>& shared_objects) const; 00030 virtual SoNode* create_visualization(); 00031 00033 Real get_radius() const { return _radius; } 00034 00036 00040 unsigned get_recursion_level() const { return _rlevel; } 00041 00043 virtual Vector3 calc_com() { return _T.get_translation(); } 00044 00045 private: 00046 void recompute_mesh(); 00047 00048 Real _radius; 00049 unsigned _rlevel; 00050 }; // end class 00051 00052 } // end namespace 00053 00054 #endif
1.5.1