00001
00002
00003
00004
00005
00006
00007 #ifndef _CYLINDER_H
00008 #define _CYLINDER_H
00009
00010 #include <Physsim/Primitive.h>
00011
00012 namespace Physsim {
00013
00015 class Cylinder : public Primitive
00016 {
00017 public:
00018 Cylinder();
00019 Cylinder(Real radius, Real height);
00020 Cylinder(Real radius, Real height, unsigned recursion_level, const Matrix4& T);
00021 Cylinder(Real radius, Real height, const Matrix4& T);
00022 void set_radius(Real radius);
00023 void set_height(Real height);
00024 void set_recursion_level(unsigned level);
00025 virtual void load_from_xml(XMLTreeConstPtr node, std::map<std::string, BasePtr>& id_map);
00026 virtual void save_to_xml(XMLTreePtr node, std::list<BaseConstPtr>& shared_objects) const;
00027 virtual Matrix3 calc_inertia();
00028 virtual Real calc_mass();
00029 virtual SoNode* create_visualization();
00030
00032 Real get_radius() const { return _radius; }
00033
00035 Real get_height() const { return _height; }
00036
00038
00042 unsigned get_recursion_level() const { return _rlevel; }
00043
00045 virtual Vector3 calc_com() { return _T.get_translation(); }
00046
00047 private:
00048 void recompute_mesh();
00049 static void triangulate(std::vector<TriangleConstPtr>& mesh, const std::vector<Vector3ConstPtr>& vertices);
00050
00051 Real _radius;
00052 Real _height;
00053 unsigned _rlevel;
00054 };
00055
00056 }
00057
00058 #endif