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

physics/Solid

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: Solid 1031 2004-02-11 20:46:36Z jungd $
00019   $Revision: 1.7 $
00020   $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _PHYSICS_SOLID_
00026 #define _PHYSICS_SOLID_
00027 
00028 #include <physics/physics>
00029 
00030 #include <base/ref>
00031 #include <gfx/Visual>
00032 
00033 #include <physics/Body>
00034 #include <physics/Material>
00035 #include <physics/MassProperties>
00036 #include <physics/CollidableBody>
00037 #include <physics/CollidableProvider>
00038 
00039 #include <osg/MatrixTransform>
00040 #include <osg/Node>
00041 
00042 
00043 namespace physics {
00044 
00045 
00046 class Solid : public Body, public gfx::Visual, public CollidableProvider
00047 {
00048 public:
00049   Solid(const Solid& s);
00050   virtual ~Solid();
00051 
00052   virtual String className() const { return String("Solid"); }
00053 
00054   virtual void setName(const String& name) { base::Named::setName(name); }
00055 
00056   virtual MassProperties massProperties() const;
00057   virtual ref<const Material> getMaterial() const { return material; }
00058 
00059   virtual void setEnabled(bool enable) = 0;
00060   virtual bool isEnabled() const = 0;
00061 
00062   // Force/Torque accumulator functions
00063   //  (accumulated forces are zero'd before each step)
00064   virtual void addForce(const Vector3& f) = 0;
00065   virtual void addTorque(const Vector3& t) = 0;
00066   virtual void addRelForce(const Vector3& f) = 0;
00067   virtual void addRelTorque(const Vector3& t) = 0;
00068   virtual void addForceAtPos(const Vector3& f, const Point3& p) = 0;
00069   virtual void addForceAtRelPos(const Vector3& f, const Point3& p) = 0;
00070   virtual void addRelForceAtPos(const Vector3& f, const Point3& p) = 0;
00071   virtual void addRelForceAtRelPos(const Vector3& f, const Point3& p) = 0;
00072 
00073   virtual Vector3 getForce() const = 0;
00074   virtual Vector3 getTorque() const = 0;
00075 
00076   
00077   // CollidableProvider
00078   static const CollidableProvider::CollidableFlag SolidNotConnected = 1;
00079   /// create CollidableBody (not connected to Solid if flags contains SolidNotConnected - i.e. not SolidConnectedCollidableBody)
00080   virtual ref<Collidable> createCollidable(CollidableFlags flags = 0) { return createCollidable(getShape(), flags); }
00081   virtual ref<Collidable> createCollidable(ref<const Shape> collisionShape, CollidableFlags flags = 0) = 0;
00082 
00083   // Visual
00084   virtual bool visualTypeSupported(VisualType type) const { return (type==OSGVisual); }
00085   virtual osg::Node* createOSGVisual(Visual::Attributes visualAttributes=0) const;
00086 
00087 protected:
00088   Solid() {}
00089   Solid(ref<const Shape> shape, ref<const Material> material);
00090 
00091   virtual void updateVisual(); ///< update the visual to the current position & orientation state (does nothing if no Visual requested)
00092 
00093   ref<const Material> material;
00094   
00095   mutable Visual::Attributes attributes;
00096   mutable ref_ptr<osg::Node> node;
00097 
00098   // !!! maybe this should be an osg::PositionAttitudeTransform instead??
00099   mutable osg::MatrixTransform* worldTransform; ///< transforms visual to current solid position/orientation
00100 
00101   friend class SolidSystem;
00102 
00103 };
00104 
00105 
00106 } // physics
00107 
00108 #endif

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