00001 /* **-*-c++-*-************************************************************** 00002 Copyright (C)2003 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: Collidable 1065 2004-02-27 19:52:50Z jungd $ 00019 $Revision: 1.2 $ 00020 $Date: 2004-02-27 14:52:50 -0500 (Fri, 27 Feb 2004) $ 00021 $Author: jungd $ 00022 00023 ****************************************************************************/ 00024 00025 #ifndef _PHYSICS_COLLIDABLE_ 00026 #define _PHYSICS_COLLIDABLE_ 00027 00028 #include <physics/physics> 00029 00030 #include <base/ReferencedObject> 00031 #include <base/Named> 00032 #include <physics/BoundingBox> 00033 00034 00035 namespace physics { 00036 00037 00038 class Collidable : virtual public base::Named, virtual public base::ReferencedObject 00039 { 00040 public: 00041 virtual BoundingBox getBoundingBox() const = 0; 00042 00043 virtual void setName(const String& name) { Named::setName(name); } 00044 00045 virtual void setInterpenetrationIsNormal(bool interpenetrationIsNormal) { interpenetrationNormal=interpenetrationIsNormal; } 00046 virtual bool isInterpenetrationNormal() const { return interpenetrationNormal; } 00047 00048 virtual ref<const Collidable> findNamed(const String& name, bool recurse=true) const 00049 { if (getName() == name) return ref<const Collidable>(this); else return ref<const Collidable>(0); } 00050 00051 virtual ref<Collidable> findNamed(const String& name, bool recurse=true) 00052 { if (getName() == name) return ref<Collidable>(this); else return ref<Collidable>(0); } 00053 00054 virtual void setUserData(ref<base::ReferencedObject> data) { userData = data; } 00055 virtual ref<base::ReferencedObject> getUserData() const { return userData; } 00056 00057 /// Collisions between Collidables of the same class number (>0) are culled 00058 virtual void setUserClass(Int userClass = 0) { this->userClass = userClass; } 00059 virtual Int getUserClass() const { return userClass; } 00060 00061 protected: 00062 Collidable(bool interpenetrationNormal=false) : interpenetrationNormal(interpenetrationNormal), userClass(0) {} 00063 Collidable(const Collidable& c) : interpenetrationNormal(interpenetrationNormal), userData(c.userData) {} 00064 00065 /// if under normal circumstances this Collidable is expected to sometimes be interpenetrating another Collidable, this is true 00066 bool interpenetrationNormal; 00067 00068 ref<base::ReferencedObject> userData; 00069 Int userClass; 00070 }; 00071 00072 00073 00074 } // physics 00075 00076 #endif