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: SolidSystem 1031 2004-02-11 20:46:36Z jungd $ 00019 $Revision: 1.9 $ 00020 $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $ 00021 $Author: jungd $ 00022 00023 ****************************************************************************/ 00024 00025 #ifndef _PHYSICS_SOLIDSYSTEM_ 00026 #define _PHYSICS_SOLIDSYSTEM_ 00027 00028 #include <physics/physics> 00029 00030 #include <base/Simulatable> 00031 00032 #include <physics/Solid> 00033 #include <physics/CollidableProvider> 00034 #include <physics/CollisionCuller> 00035 #include <physics/CollisionDetector> 00036 #include <physics/CollisionResponseHandler> 00037 #include <physics/ConstraintGroup> 00038 #include <physics/FixedConstraint> 00039 #include <physics/ContactConstraint> 00040 00041 #include <physics/BallJoint> 00042 #include <physics/HingeJoint> 00043 #include <physics/DoubleHingeJoint> 00044 #include <physics/SliderJoint> 00045 #include <physics/UniversalJoint> 00046 #include <physics/Motor> 00047 00048 #include <gfx/Visual> 00049 00050 #include <map> 00051 #include <list> 00052 00053 00054 namespace physics { 00055 00056 00057 class SolidSystem : virtual public base::Simulatable, public gfx::Visual, public physics::CollidableProvider 00058 { 00059 public: 00060 SolidSystem(); 00061 SolidSystem(const SolidSystem& ss); 00062 virtual ~SolidSystem(); 00063 00064 // factory methods 00065 virtual ref<Solid> createSolid(ref<const Shape> shape, ref<const Material> material) = 0; ///< create a new Solid 00066 virtual ref<ConstraintGroup> createConstraintGroup() = 0; ///< new ConstraintGroup 00067 00068 virtual ref<BallJoint> createBallJoint() = 0; ///< new Ball & Socket joint constraint 00069 virtual ref<HingeJoint> createHingeJoint() = 0; ///< new Hinge joint constraint 00070 virtual ref<DoubleHingeJoint> createDoubleHingeJoint() = 0; ///< new Double Hinge joint constraint 00071 virtual ref<SliderJoint> createSliderJoint() = 0; ///< new Slider joint constraint 00072 virtual ref<UniversalJoint> createUniversalJoint() = 0; ///< new Universal joint constraint 00073 00074 virtual ref<FixedConstraint> createFixedConstraint() = 0; ///< new FixedConstraint 00075 virtual ref<ContactConstraint> createContactConstraint() = 0;///< new ContactConstraint 00076 00077 virtual ref<Motor> createMotor() = 0; ///< new Joint Motor 00078 00079 virtual void setGround(ref<Solid> ground, const Point3& position) = 0; ///< Set the ground Solid (which is fixed to the world frame and doesn't move from position) 00080 virtual ref<Solid> getGround() const = 0; ///< Get the ground Solid 00081 virtual void setGravity(const Vector3& v) = 0; ///< set acceleration due to gravity (e.g. Vector3(0,0,-9.8)) 00082 00083 virtual void addSolid(ref<Solid> solid) = 0; ///< add solid to the system (Solid must be from createSolid() 00084 virtual void removeSolid(ref<const Solid> solid) = 0; ///< remove solid from the system 00085 00086 virtual void addConstraintGroup(ref<ConstraintGroup> group) = 0; ///< add a constraint group to the system 00087 virtual void removeConstraintGroup(ref<const ConstraintGroup> group) = 0; ///< remove constraint group from the system 00088 00089 virtual void setCollidable(ref<Collidable> collidable) = 0; 00090 00091 virtual void setCollisionCuller(ref<CollisionCuller> collisionCuller) = 0; ///< called to cull Collidables from collision detection 00092 virtual ref<CollisionCuller> getCollisionCuller() const = 0; ///< get the current CollisionCuller 00093 00094 virtual void setCollisionDetector(ref<CollisionDetector> collisionDetector) = 0; ///< called to detect collisions 00095 virtual ref<CollisionDetector> getCollisionDetector() const = 0; ///< get the current CollisionDetector (or null if none) 00096 00097 virtual void setCollisionResponseHandler(ref<CollisionResponseHandler> collisionResponseHandler) = 0; ///< called to handle collisions 00098 virtual ref<CollisionResponseHandler> getCollisionResponseHandler() const = 0; 00099 00100 /// Set implementation specific parameters. Unknown names will throw a std::invald_argument exception 00101 virtual void setParameter(const String& name, Real value) 00102 { throw std::invalid_argument(Exception("unknown parameter name")); } 00103 00104 }; 00105 00106 } // physics 00107 00108 #endif