Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

physics/Torus

Go to the documentation of this file.
00001 /* **-*-c++-*-**************************************************************
00002   Copyright (C)1996 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   
00018   $Id: Torus 1031 2004-02-11 20:46:36Z jungd $
00019   $Revision: 1.4 $
00020   $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _PHYSICS_TORUS_
00026 #define _PHYSICS_TORUS_
00027 
00028 #include <base/base>
00029 #include <physics/ComplexShape>
00030 #include <base/Dimension3>
00031 
00032 
00033 
00034 
00035 namespace physics {
00036 
00037 
00038 class Torus : virtual public ComplexShape
00039 {
00040 public:
00041   explicit Torus(Real innerRadius=0.5, Real outerRadius=1.0);
00042   Torus(const Torus& t);
00043   virtual ~Torus();
00044   
00045   virtual String className() const { return String("Torus"); }
00046 
00047   Real innerRadius() const { return _innerRadius; }
00048   Real outerRadius() const { return _outerRadius; }
00049   
00050   // Shape
00051   virtual base::Object& clone() const { return *NewNamedObj(className()) Torus(*this); }
00052   virtual BoundingBox getBoundingBox() const
00053     {
00054       Real minor = (_outerRadius-_innerRadius)/2.0;
00055       return BoundingBox(-gfx::Point3(_outerRadius,minor,_outerRadius),gfx::Point3(_outerRadius,minor,_outerRadius)); 
00056     }
00057   virtual BoundingSphere getBoundingSphere() const { return BoundingSphere(gfx::Point3(),_outerRadius); }
00058   
00059   virtual const MassProperties& getMassProperties(ref<const Material> material) const;
00060 
00061   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const Point3& p) const;
00062   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Segment3& s) const;
00063   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Triangle3& tri) const;
00064   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t, const gfx::Quad3& q) const;
00065   virtual gfx::Segment3 shortestSegmentBetween(const base::Transform& t1, ref<const Shape> s, const base::Transform& t2) const;
00066 
00067   // CollisionModelProvider
00068   virtual ref<CollisionModel> getCollisionModel(CollisionModel::CollisionModelType modelType) const;
00069 
00070   // Visual
00071   virtual bool visualTypeSupported(VisualType type) const { return (type==OSGVisual); }
00072   virtual osg::Node* createOSGVisual(Attributes visualAttributes=0) const;
00073 
00074   virtual void serialize(base::Serializer& s);
00075 
00076 protected:
00077   osg::Node* createOSGTorus(Visual::Attributes visualAttributes, Int sides, Int rings) const;
00078 
00079 
00080 private:
00081   Real _innerRadius;
00082   Real _outerRadius;
00083 
00084   mutable bool massPropertiesCached;
00085   mutable Real density;
00086   mutable MassProperties massProperties;
00087 
00088   mutable Visual::Attributes attributes;
00089   mutable ref_ptr<osg::Node> node;
00090 
00091   mutable ref<CollisionModel> collisionModel;
00092   mutable CollisionModel::CollisionModelType modelType;
00093 };
00094 
00095 
00096 } // physics
00097 
00098 #endif

Generated on Thu Jul 29 15:56:30 2004 for OpenSim by doxygen 1.3.6