From: <a-...@us...> - 2009-12-08 07:56:59
|
Revision: 116 http://simspark.svn.sourceforge.net/simspark/?rev=116&view=rev Author: a-held Date: 2009-12-08 07:56:49 +0000 (Tue, 08 Dec 2009) Log Message: ----------- updated ccyluinder to capsule removed some unnecessary includes in interfaces prepared bridge pattern for Collider class provided bridge pattern for Compound-, Concave- and EmptyCollider Modified Paths: -------------- branches/multiphys/spark/lib/oxygen/CMakeLists.txt branches/multiphys/spark/lib/oxygen/oxygen.cpp branches/multiphys/spark/lib/oxygen/oxygen.h branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/collider.h branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.h branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.h branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.h branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/physicsobjectint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/spaceint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/worldint.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.h branches/multiphys/spark/plugin/rosimporter/rosimporter.cpp Added Paths: ----------- branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.h branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider_c.cpp branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/compoundcolliderint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/concavecolliderint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/emptycolliderint.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeconcavecollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeconcavecollider.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeemptycollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeemptycollider.h Removed Paths: ------------- branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.h branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider_c.cpp Modified: branches/multiphys/spark/lib/oxygen/CMakeLists.txt =================================================================== --- branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-12-08 07:56:49 UTC (rev 116) @@ -22,7 +22,7 @@ physicsserver/softbody.h physicsserver/bodycontroller.h physicsserver/boxcollider.h - physicsserver/ccylindercollider.h + physicsserver/capsulecollider.h physicsserver/cylindercollider.h physicsserver/collider.h physicsserver/compoundcollider.h @@ -55,7 +55,11 @@ #interfaces physicsserver/int/bodyint.h + physicsserver/int/colliderint.h + physicsserver/int/compoundcolliderint.h + physicsserver/int/concavecolliderint.h physicsserver/int/dynamicbodyint.h + physicsserver/int/emptycolliderint.h physicsserver/int/physicsobjectint.h physicsserver/int/physicsserverint.h physicsserver/int/rigidbodyint.h @@ -67,6 +71,10 @@ #ode-specific files physicsserver/ode/odebody.h physicsserver/ode/odedynamicbody.h + physicsserver/ode/odecollider.h + physicsserver/ode/odecompoundcollider.h + physicsserver/ode/odeconcavecollider.h + physicsserver/ode/odeemptycollider.h physicsserver/ode/odephysicsobject.h physicsserver/ode/odephysicsserver.h physicsserver/ode/oderigidbody.h @@ -153,12 +161,14 @@ physicsserver/transformcollider_c.cpp physicsserver/boxcollider.cpp physicsserver/boxcollider_c.cpp - physicsserver/ccylindercollider.cpp - physicsserver/ccylindercollider_c.cpp + physicsserver/capsulecollider.cpp + physicsserver/capsulecollider_c.cpp physicsserver/cylindercollider_c.cpp physicsserver/collider.cpp physicsserver/collider_c.cpp + physicsserver/compoundcollider.cpp physicsserver/compoundcollider_c.cpp + physicsserver/concavecollider.cpp physicsserver/concavecollider_c.cpp physicsserver/conecollider_c.cpp physicsserver/convexcollider_c.cpp @@ -166,6 +176,7 @@ physicsserver/collisionhandler_c.cpp physicsserver/contactjointhandler.cpp physicsserver/contactjointhandler_c.cpp + physicsserver/emptycollider.cpp physicsserver/emptycollider_c.cpp physicsserver/physicsserver.cpp physicsserver/physicsserver_c.cpp @@ -206,7 +217,11 @@ #ODE-specific files physicsserver/ode/odebody.cpp + physicsserver/ode/odecompoundcollider.cpp + physicsserver/ode/odeconcavecollider.cpp + physicsserver/ode/odecollider.cpp physicsserver/ode/odedynamicbody.cpp + physicsserver/ode/odeemptycollider.cpp physicsserver/ode/odephysicsobject.cpp physicsserver/ode/odephysicsserver.cpp physicsserver/ode/oderigidbody.cpp Modified: branches/multiphys/spark/lib/oxygen/oxygen.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/oxygen.cpp 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/oxygen.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -83,7 +83,7 @@ zg.GetCore()->RegisterClassObject(new CLASS(EmptyCollider), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(TransformCollider), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(BoxCollider), "oxygen/"); - zg.GetCore()->RegisterClassObject(new CLASS(CCylinderCollider), "oxygen/"); + zg.GetCore()->RegisterClassObject(new CLASS(CapsuleCollider), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(CylinderCollider), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(PlaneCollider), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(RayCollider), "oxygen/"); Modified: branches/multiphys/spark/lib/oxygen/oxygen.h =================================================================== --- branches/multiphys/spark/lib/oxygen/oxygen.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/oxygen.h 2009-12-08 07:56:49 UTC (rev 116) @@ -46,7 +46,7 @@ #include <oxygen/physicsserver/velocitycontroller.h> #include <oxygen/physicsserver/transformcollider.h> #include <oxygen/physicsserver/boxcollider.h> -#include <oxygen/physicsserver/ccylindercollider.h> +#include <oxygen/physicsserver/capsulecollider.h> #include <oxygen/physicsserver/cylindercollider.h> #include <oxygen/physicsserver/collider.h> #include <oxygen/physicsserver/compoundcollider.h> Added: branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,89 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id: ccylindercollider.cpp 108 2009-11-25 10:20:10Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include <oxygen/physicsserver/capsulecollider.h> + +using namespace oxygen; +using namespace salt; + +CapsuleCollider::CapsuleCollider() : ConvexCollider() +{ +} + +void CapsuleCollider::SetParams(float radius, float length) +{ + dGeomCCylinderSetParams (mODEGeom, radius, length); +} + +void CapsuleCollider::SetRadius(float radius) +{ + SetParams(radius,GetLength()); +} + +void CapsuleCollider::SetLength(float length) +{ + SetParams(GetRadius(),length); +} + +void CapsuleCollider::GetParams(float& radius, float& length) +{ + dReal r,l; + dGeomCCylinderGetParams(mODEGeom,&r,&l); + radius = r; + length = l; +} + +float CapsuleCollider::GetRadius() +{ + float length; + float radius; + GetParams(radius,length); + return radius; +} + +float CapsuleCollider::GetLength() +{ + float radius; + float length; + GetParams(radius,length); + return length; +} + +bool CapsuleCollider::ConstructInternal() +{ + if (! Collider::ConstructInternal()) + { + return false; + } + + // create a unit capped cylinder + mODEGeom = dCreateCCylinder(0, 1.0f, 1.0f); + + return (mODEGeom != 0); +} + +float CapsuleCollider::GetPointDepth(const Vector3f& pos) +{ + Vector3f worldPos(GetWorldTransform() * pos); + return dGeomCCylinderPointDepth + (mODEGeom,worldPos[0],worldPos[1],worldPos[2]); +} + Added: branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,83 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: ccylindercollider.h 108 2009-11-25 10:20:10Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef OXYGEN_CAPSULECOLLIDER_H +#define OXYGEN_CAPSULECOLLIDER_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/convexcollider.h> + +namespace oxygen +{ + +/** CapsuleCollider encapsulates an ODE capsule geometry + object. A capsule is like a cylinder except it has + half-sphere caps at its ends. This feature makes the internal + collision detection code particularly fast and accurate. + */ +class OXYGEN_API CapsuleCollider : public ConvexCollider +{ + // + // Functions + // +public: + CapsuleCollider(); + + /** sets the parameters of the capsule. + + \param radius is the radius of the caps, and of the cylinder itself + \param length is the height of the cylinder, not counting the caps + */ + void SetParams(float radius, float length); + + /** sets the radius of the capsule */ + void SetRadius(float radius); + + /** sets the length of the capsule */ + void SetLength(float length); + + /** gets the radius and the length of the capsule */ + void GetParams(float& radius, float& length); + + /** returns the radius of the capsule */ + float GetRadius(); + + /** return the length of the capsule */ + float GetLength(); + + /** returns the depth of the given relative position in the + managed capsule geom. Points inside the geom will have + positive depth, points outside it will have negative depth, and + points on the surface will have zero depth. + */ + float GetPointDepth(const salt::Vector3f& pos); + +protected: + /** constructs a default capsule with an radius of 1 and a + length of 1 */ + virtual bool ConstructInternal(); +}; + +DECLARE_CLASS(CapsuleCollider); + +} //namespace oxygen + +#endif //OXYGEN_CAPSULECOLLIDER_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider_c.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider_c.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/capsulecollider_c.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,112 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id: ccylindercollider_c.cpp 108 2009-11-25 10:20:10Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include <oxygen/physicsserver/capsulecollider.h> + +using namespace oxygen; +using namespace boost; +using namespace salt; + +FUNCTION(CapsuleCollider,setParams) +{ + float inRadius; + float inLength; + + if ( + (in.GetSize() != 2) || + (! in.GetValue(in[0],inRadius)) || + (! in.GetValue(in[1],inLength)) + ) + { + return false; + } + + obj->SetParams(inRadius,inLength); + return true; +} + +FUNCTION(CapsuleCollider,setRadius) +{ + float inRadius; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in[0],inRadius)) + ) + { + return false; + } + + obj->SetRadius(inRadius); + return true; +} + +FUNCTION(CapsuleCollider,setLength) +{ + float inLength; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in[0],inLength)) + ) + { + return false; + } + + obj->SetLength(inLength); + return true; +} + +FUNCTION(CapsuleCollider,getRadius) +{ + return obj->GetRadius(); +} + +FUNCTION(CapsuleCollider,getLength) +{ + return obj->GetLength(); +} + +FUNCTION(CapsuleCollider,getPointDepth) +{ + Vector3f inPos; + + if ( + (in.GetSize() == 0) || + (! in.GetValue(in.begin(), inPos)) + ) + { + return 0; + } + + return obj->GetPointDepth(inPos); +} + +void CLASS(CapsuleCollider)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/ConvexCollider); + DEFINE_FUNCTION(setParams); + DEFINE_FUNCTION(setRadius); + DEFINE_FUNCTION(setLength); + DEFINE_FUNCTION(getRadius); + DEFINE_FUNCTION(getLength); + DEFINE_FUNCTION(getPointDepth); +} Deleted: branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.cpp 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -1,94 +0,0 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- - - this file is part of rcssserver3D - Fri May 9 2003 - Copyright (C) 2003 Koblenz University - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include <oxygen/physicsserver/ccylindercollider.h> - -using namespace oxygen; -using namespace salt; - -CCylinderCollider::CCylinderCollider() : ConvexCollider() -{ -} - -void CCylinderCollider::SetParams(float radius, float length) -{ - dGeomCCylinderSetParams (mODEGeom, radius, length); -} - -void CCylinderCollider::SetRadius(float radius) -{ - SetParams(radius,GetLength()); -} - -void CCylinderCollider::SetLength(float length) -{ - SetParams(GetRadius(),length); -} - -void -CCylinderCollider::GetParams(float& radius, float& length) -{ - dReal r,l; - dGeomCCylinderGetParams(mODEGeom,&r,&l); - radius = r; - length = l; -} - -float -CCylinderCollider::GetRadius() -{ - float length; - float radius; - GetParams(radius,length); - return radius; -} - -float -CCylinderCollider::GetLength() -{ - float radius; - float length; - GetParams(radius,length); - return length; -} - -bool -CCylinderCollider::ConstructInternal() -{ - if (! Collider::ConstructInternal()) - { - return false; - } - - // create a unit capped cylinder - mODEGeom = dCreateCCylinder(0, 1.0f, 1.0f); - - return (mODEGeom != 0); -} - -float -CCylinderCollider::GetPointDepth(const Vector3f& pos) -{ - Vector3f worldPos(GetWorldTransform() * pos); - return dGeomCCylinderPointDepth - (mODEGeom,worldPos[0],worldPos[1],worldPos[2]); -} - Deleted: branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -1,83 +0,0 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- - - this file is part of rcssserver3D - Fri May 9 2003 - Copyright (C) 2002,2003 Koblenz University - Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef OXYGEN_CCYLINDERCOLLIDER_H -#define OXYGEN_CCYLINDERCOLLIDER_H - -#include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/convexcollider.h> - -namespace oxygen -{ - -/** CCylinderCollider encapsulates an ODE capped cylinder geometry - object. A capped cylinder is like a normal cylinder except it has - half-sphere caps at its ends. This feature makes the internal - collision detection code particularly fast and accurate. - */ -class OXYGEN_API CCylinderCollider : public ConvexCollider -{ - // - // Functions - // -public: - CCylinderCollider(); - - /** sets the parameters of the capped cylinder. - - \param radius is the radius of the caps, and of the cylinder itself - \param length is the height of the cylinder, not counting the caps - */ - void SetParams(float radius, float length); - - /** sets the radius of the capped cylinder */ - void SetRadius(float radius); - - /** sets the length of the capped cylinder */ - void SetLength(float length); - - /** gets the radius and the length of the capped cylinder */ - void GetParams(float& radius, float& length); - - /** returns the radius of the capped cylinder */ - float GetRadius(); - - /** return the length of the capped cylinder */ - float GetLength(); - - /** returns the depth of the given relative position in the - managed capped cylinder geom. Points inside the geom will have - positive depth, points outside it will have negative depth, and - points on the surface will have zero depth. - */ - float GetPointDepth(const salt::Vector3f& pos); - -protected: - /** constructs a default capped cylinder with an radius of 1 and a - length of 1 */ - virtual bool ConstructInternal(); -}; - -DECLARE_CLASS(CCylinderCollider); - -} //namespace oxygen - -#endif //OXYGEN_CCYLINDERCOLLIDER_H Deleted: branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider_c.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider_c.cpp 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ccylindercollider_c.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -1,112 +0,0 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- - - this file is part of rcssserver3D - Fri May 9 2003 - Copyright (C) 2003 Koblenz University - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include <oxygen/physicsserver/ccylindercollider.h> - -using namespace oxygen; -using namespace boost; -using namespace salt; - -FUNCTION(CCylinderCollider,setParams) -{ - float inRadius; - float inLength; - - if ( - (in.GetSize() != 2) || - (! in.GetValue(in[0],inRadius)) || - (! in.GetValue(in[1],inLength)) - ) - { - return false; - } - - obj->SetParams(inRadius,inLength); - return true; -} - -FUNCTION(CCylinderCollider,setRadius) -{ - float inRadius; - - if ( - (in.GetSize() != 1) || - (! in.GetValue(in[0],inRadius)) - ) - { - return false; - } - - obj->SetRadius(inRadius); - return true; -} - -FUNCTION(CCylinderCollider,setLength) -{ - float inLength; - - if ( - (in.GetSize() != 1) || - (! in.GetValue(in[0],inLength)) - ) - { - return false; - } - - obj->SetLength(inLength); - return true; -} - -FUNCTION(CCylinderCollider,getRadius) -{ - return obj->GetRadius(); -} - -FUNCTION(CCylinderCollider,getLength) -{ - return obj->GetLength(); -} - -FUNCTION(CCylinderCollider,getPointDepth) -{ - Vector3f inPos; - - if ( - (in.GetSize() == 0) || - (! in.GetValue(in.begin(), inPos)) - ) - { - return 0; - } - - return obj->GetPointDepth(inPos); -} - -void CLASS(CCylinderCollider)::DefineClass() -{ - DEFINE_BASECLASS(oxygen/ConvexCollider); - DEFINE_FUNCTION(setParams); - DEFINE_FUNCTION(setRadius); - DEFINE_FUNCTION(setLength); - DEFINE_FUNCTION(getRadius); - DEFINE_FUNCTION(getLength); - DEFINE_FUNCTION(getPointDepth); -} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <oxygen/physicsserver/collider.h> +#include <oxygen/physicsserver/ode/odecollider.h> #include <oxygen/physicsserver/collisionhandler.h> #include <oxygen/physicsserver/space.h> #include <oxygen/physicsserver/transformcollider.h> @@ -34,6 +35,7 @@ Collider::Collider() : PhysicsObject(), mODEGeom(0) { + mColliderImp = boost::shared_ptr<ODECollider>(new ODECollider()); } Collider::~Collider() Modified: branches/multiphys/spark/lib/oxygen/physicsserver/collider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/collider.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/collider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -30,6 +30,7 @@ namespace oxygen { +class ColliderInt; /** \class Collider encapsulates an ODE geometry object- geom for short. Geoms are the fundamental objects in the collision @@ -158,6 +159,9 @@ protected: /** the ode collision geometry */ dGeomID mODEGeom; + +private: + boost::shared_ptr<ColliderInt> mColliderImp; protected: /** a set that store the colliders that I never collide with Added: branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,33 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: body.h 106 2009-11-19 10:10:50Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <oxygen/physicsserver/compoundcollider.h> +#include <oxygen/physicsserver/ode/odecompoundcollider.h> + +using namespace oxygen; + +CompoundCollider::CompoundCollider() : Collider(){ + mCompoundColliderImp = boost::shared_ptr<ODECompoundCollider>(new ODECompoundCollider()); +} + +CompoundCollider::~CompoundCollider(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/compoundcollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -27,6 +27,7 @@ namespace oxygen { +class CompoundColliderInt; /** CompoundCollider is not yet implemented. */ @@ -37,8 +38,11 @@ // Functions // public: - CompoundCollider() : Collider(){}; - virtual ~CompoundCollider(){}; + CompoundCollider(); + virtual ~CompoundCollider(); + +private: + boost::shared_ptr<CompoundColliderInt> mCompoundColliderImp; }; DECLARE_CLASS(CompoundCollider); Added: branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,33 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: body.h 106 2009-11-19 10:10:50Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <oxygen/physicsserver/concavecollider.h> +#include <oxygen/physicsserver/ode/odeconcavecollider.h> + +using namespace oxygen; + +ConcaveCollider::ConcaveCollider() : Collider(){ + mConcaveColliderImp = boost::shared_ptr<ODEConcaveCollider>(new ODEConcaveCollider()); +} + +ConcaveCollider::~ConcaveCollider(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/concavecollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -27,6 +27,7 @@ namespace oxygen { +class ConcaveColliderInt; /** ConcaveCollider is not yet implemented. */ @@ -37,8 +38,11 @@ // Functions // public: - ConcaveCollider() : Collider(){}; - virtual ~ConcaveCollider(){}; + ConcaveCollider(); + virtual ~ConcaveCollider(); + +private: + boost::shared_ptr<ConcaveColliderInt> mConcaveColliderImp; }; DECLARE_CLASS(ConcaveCollider); Added: branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,33 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: body.h 106 2009-11-19 10:10:50Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <oxygen/physicsserver/emptycollider.h> +#include <oxygen/physicsserver/ode/odeemptycollider.h> + +using namespace oxygen; + +EmptyCollider::EmptyCollider() : Collider(){ + mEmptyColliderImp = boost::shared_ptr<ODEEmptyCollider>(new ODEEmptyCollider()); +} + +EmptyCollider::~EmptyCollider(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/emptycollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -27,6 +27,7 @@ namespace oxygen { +class EmptyColliderInt; /** EmptyCollider is not yet implemented. */ @@ -37,8 +38,11 @@ // Functions // public: - EmptyCollider() : Collider(){}; - virtual ~EmptyCollider(){}; + EmptyCollider(); + virtual ~EmptyCollider(); + +private: + boost::shared_ptr<EmptyColliderInt> mEmptyColliderImp; }; DECLARE_CLASS(EmptyCollider); Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,72 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: space.h 102 2009-11-18 07:24:29Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef OXYGEN_COLLIDERINT_H +#define OXYGEN_COLLIDERINT_H + +#include <oxygen/physicsserver/ode/odewrapper.h> +#include <oxygen/oxygen_defines.h> +#include <set> +#include <string> + +namespace oxygen +{ +class Collider; + +class OXYGEN_API ColliderInt +{ + +public: + enum ECollisionType + { + CT_DIRECT, + CT_SYMMETRIC + }; + + typedef std::set<std::string> TColliderNameSet; + + static boost::shared_ptr<Collider> GetCollider(long GeomID){}; + + virtual void OnCollision(boost::shared_ptr<Collider> collidee, dContact& contact, ECollisionType type) = 0; + virtual bool AddCollisionHandler(const std::string& handlerName) = 0; + virtual long GetGeomID() = 0; + virtual void SetPosition(const salt::Vector3f& pos) = 0; + virtual void SetLocalPosition(const salt::Vector3f& pos) = 0; + virtual salt::Vector3f GetPosition() const = 0; + virtual void SetRotation(const salt::Matrix& rot) = 0; + virtual bool Intersects(boost::shared_ptr<Collider> collider) = 0; + virtual long GetParentSpaceID() = 0; + virtual void AddNotCollideWithColliderName(const std::string& colliderName, bool isAdd) = 0; + virtual const TColliderNameSet& GetNotCollideWithSet() const = 0; + virtual void OnLink() = 0; + virtual void OnUnlink() = 0; + virtual void PrePhysicsUpdateInternal(float deltaTime) = 0; + virtual void DestroyPhysicsObject() = 0; + +protected: + dGeomID mODEGeom; + TColliderNameSet mNotCollideWithSet; +}; + +} //namespace oxygen + +#endif //OXYGEN_COLLIDERINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/compoundcolliderint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/compoundcolliderint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/compoundcolliderint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,38 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: space.h 102 2009-11-18 07:24:29Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef OXYGEN_COMPOUNDCOLLIDERINT_H +#define OXYGEN_COMPOUNDCOLLIDERINT_H + +#include <oxygen/oxygen_defines.h> + +namespace oxygen +{ + +class OXYGEN_API CompoundColliderInt +{ + +}; + +} //namespace oxygen + +#endif //OXYGEN_COMPOUNDCOLLIDERINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/concavecolliderint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/concavecolliderint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/concavecolliderint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,38 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: space.h 102 2009-11-18 07:24:29Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef OXYGEN_CONCAVECOLLIDERINT_H +#define OXYGEN_CONCAVECOLLIDERINT_H + +#include <oxygen/oxygen_defines.h> + +namespace oxygen +{ + +class OXYGEN_API ConcaveColliderInt +{ + +}; + +} //namespace oxygen + +#endif //OXYGEN_CONCAVECOLLIDERINT_H Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -24,7 +24,6 @@ #define OXYGEN_DYNAMICBODYINT_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odebody.h> namespace oxygen { Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/emptycolliderint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/emptycolliderint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/emptycolliderint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,38 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: space.h 102 2009-11-18 07:24:29Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef OXYGEN_EMPTYCOLLIDERINT_H +#define OXYGEN_EMPTYCOLLIDERINT_H + +#include <oxygen/oxygen_defines.h> + +namespace oxygen +{ + +class OXYGEN_API EmptyColliderInt +{ + +}; + +} //namespace oxygen + +#endif //OXYGEN_EMPTYCOLLIDERINT_H Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/physicsobjectint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/physicsobjectint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/physicsobjectint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -24,8 +24,7 @@ #define OXYGEN_PHYSICSOBJECTINT_H #include <boost/smart_ptr/shared_ptr.hpp> -#include <oxygen/physicsserver/ode/odewrapper.h> -#include <oxygen/sceneserver/basenode.h> +#include <salt/salt.h> #include <oxygen/oxygen_defines.h> namespace oxygen Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -24,8 +24,6 @@ #define OXYGEN_RIGIDBODYINT_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odebody.h> -#include <iostream> namespace oxygen { Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -24,7 +24,6 @@ #define OXYGEN_SOFTBODYINT_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odebody.h> namespace oxygen { Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/spaceint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/spaceint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/spaceint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -23,7 +23,6 @@ #ifndef OXYGEN_SPACEINT_H #define OXYGEN_SPACEINT_H -#include <oxygen/physicsserver/ode/odephysicsobject.h> #include <set> #include <oxygen/oxygen_defines.h> @@ -32,6 +31,7 @@ class Transform; class RigidBody; class Collider; +class Scene; class OXYGEN_API SpaceInt { Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -24,7 +24,6 @@ #define OXYGEN_STATICBODYINT_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odebody.h> namespace oxygen { Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/worldint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/worldint.h 2009-12-07 08:43:40 UTC (rev 115) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/worldint.h 2009-12-08 07:56:49 UTC (rev 116) @@ -22,8 +22,8 @@ #ifndef OXYGEN_WORLDINT_H #define OXYGEN_WORLDINT_H +#include <salt/salt.h> #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odephysicsobject.h> namespace oxygen { Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,305 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id: collider.cpp 115 2009-12-07 08:43:40Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <oxygen/physicsserver/collider.h> +#include <oxygen/physicsserver/ode/odecollider.h> +#include <oxygen/physicsserver/collisionhandler.h> +#include <oxygen/physicsserver/space.h> +#include <oxygen/physicsserver/transformcollider.h> +#include <oxygen/physicsserver/rigidbody.h> +#include <oxygen/sceneserver/basenode.h> +#include <oxygen/sceneserver/scene.h> +#include <zeitgeist/leaf.h> +#include <zeitgeist/logserver/logserver.h> + +using namespace oxygen; +using namespace salt; +using namespace zeitgeist; +using namespace boost; +using namespace std; + +ODECollider::ODECollider() : ODEPhysicsObject(), mODEGeom(0) +{ +} + +ODECollider::~ODECollider() +{ +} + +void ODECollider::OnLink() +{/* + //PhysicsObject::OnLink(); + + + //weak_ptr<Node> parent = GetParent(); + if ( + (mODEGeom == 0) //|| + //(parent.expired()) + ) + { + return; + } + + // shared_ptr<TransformCollider> tcParent = + // shared_dynamic_cast<TransformCollider>(parent.lock()); + + if (tcParent.get() != 0) + { + // our parent is an ODE transform geom that encapsulates + // this geom, so register ourself to it. This geom must + // not directly register to a space or a body. + dGeomTransformSetGeom((dGeomID) tcParent->GetGeomID(), mODEGeom); + return; + } + + // this geom is independent, so register to space and body + // if we have a space add the geom to it + //long spaceID = FindSpaceID(); + if ( + (spaceID) && + (! dSpaceQuery((dSpaceID) spaceID, mODEGeom)) + ) + { + dGeomSetData(mODEGeom, this); + dSpaceAdd((dSpaceID) spaceID, mODEGeom); + } + // if there is a Body below our parent, link to it + shared_ptr<RigidBody> body = shared_static_cast<RigidBody> + (parent.lock()->GetChildOfClass("RigidBody")); + + if (body.get() != 0) + { + dGeomSetBody (mODEGeom, (dBodyID) body->GetBodyID()); + } else + { + // no body node found, setup initial position and + // orientation identical to the parent node + SetRotation(GetWorldTransform()); + SetPosition(Vector3f(0,0,0)); + } +*/} + +void ODECollider::OnUnlink() +{ + //PhysicsObject::OnUnlink(); + + // remove collision geometry from space + long space = GetParentSpaceID(); + + if ( + (mODEGeom == 0) || + (space == 0) + ) + { + return; + } + + if (space) + { + dSpaceRemove((dSpaceID) space, mODEGeom); + } +} + +void ODECollider::PrePhysicsUpdateInternal(float /*deltaTime*/) +{ + // if (FindChildSupportingClass<CollisionHandler>(false).get() == 0) + // { + // for convenience we add a ContactJointHandler if no + // other handler is registered. This behaviour covers the + // majority of all use cases and eases the creation of + // Colliders. + AddCollisionHandler("oxygen/ContactJointHandler"); + // } +} + +long ODECollider::GetGeomID() +{ + return (long) mODEGeom; +} + +bool ODECollider::AddCollisionHandler(const std::string& handlerName) +{/* + shared_ptr<CollisionHandler> handler = + shared_dynamic_cast<CollisionHandler>(GetCore()->New(handlerName)); + + if (handler.get() == 0) + { + GetLog()->Error() + << "ERROR: (Collider) Cannot create CollisionHandler " + << handlerName << "\n"; + return false; + } + + return AddChildReference(handler); +*/} + +void ODECollider::OnCollision (boost::shared_ptr<Collider> collidee, + dContact& contact, ECollisionType type) + +{/* + TLeafList handlers; + ListChildrenSupportingClass<CollisionHandler>(handlers); + + for ( + TLeafList::iterator iter = handlers.begin(); + iter != handlers.end(); + ++iter + ) + { + shared_ptr<CollisionHandler> handler = + shared_static_cast<CollisionHandler>(*iter); + + if ( + (type == CT_SYMMETRIC) && + (! handler->IsSymmetricHandler()) + ) + { + continue; + } + + handler->HandleCollision(collidee, contact); + } +*/} + +/*shared_ptr<Collider> ODECollider::GetCollider(long geomID) +{ + if (geomID == 0) + { + return shared_ptr<Collider>(); + } + + Collider* collPtr = + static_cast<Collider*>(dGeomGetData((dGeomID) geomID)); + + if (collPtr == 0) + { + // we cannot use the logserver here + cerr << "ERROR: (Collider) no Collider found for GeomID " + << geomID << "\n"; + return shared_ptr<Collider>(); + } + + shared_ptr<Collider> collider = shared_static_cast<Collider> + (collPtr->GetSelf().lock()); + + if (collider.get() == 0) + { + // we cannot use the logserver here + cerr << "ERROR: (Collider) got no shared_ptr for GeomID " + << geomID << "\n"; + } + + return collider; +}*/ + +void ODECollider::SetRotation(const Matrix& rot) +{ + dMatrix3 ODEMatrix; + void* matrixPtr = (void*) &ODEMatrix; + ConvertRotationMatrix(rot, matrixPtr); + dGeomSetRotation(mODEGeom, ODEMatrix); +} + +void ODECollider::SetPosition(const Vector3f& pos) +{ + //Vector3f globalPos(GetWorldTransform() * pos); + //dGeomSetPosition (mODEGeom, globalPos[0], globalPos[1], globalPos[2]); +} + +void ODECollider::SetLocalPosition(const Vector3f& pos) +{ + dGeomSetPosition (mODEGeom, pos[0], pos[1], pos[2]); +} + +Vector3f ODECollider::GetPosition() const +{ + const dReal* pos = dGeomGetPosition(mODEGeom); + return Vector3f(pos[0],pos[1],pos[2]); +} + +long ODECollider::GetParentSpaceID() +{ + if (mODEGeom == 0) + { + return 0; + } + + return (long) dGeomGetSpace(mODEGeom); +} + +bool ODECollider::Intersects(boost::shared_ptr<Collider> collider) +{ + if ( + (mODEGeom == 0) || + (collider.get() == 0) + ) + { + return false; + } + + dContactGeom contact; + + return dCollide + ( + mODEGeom, + (dGeomID) collider->GetGeomID(), + 1, /* ask for at most one collision point */ + &contact, + sizeof(contact) + ) > 0; +} + +void ODECollider::DestroyPhysicsObject() +{ + if (! mODEGeom) + { + return; + } + + dGeomDestroy(mODEGeom); + mODEGeom = 0; +} + +void ODECollider::AddNotCollideWithColliderName(const std::string & colliderName, bool isAdd) +{ + TColliderNameSet::iterator it = mNotCollideWithSet.find(colliderName); + + if (isAdd) + { + if (it == mNotCollideWithSet.end()) + { + //I'm not have this one + mNotCollideWithSet.insert(colliderName); + } + } + else + { + if (it != mNotCollideWithSet.end()) + { + //Remove + mNotCollideWithSet.erase(it); + } + } +} + +const ODECollider::TColliderNameSet& ODECollider::GetNotCollideWithSet() const +{ + return mNotCollideWithSet; +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,62 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: space.h 102 2009-11-18 07:24:29Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef OXYGEN_ODECOLLIDER_H +#define OXYGEN_ODECOLLIDER_H + +#include <oxygen/physicsserver/ode/odephysicsobject.h> +#include <oxygen/physicsserver/int/colliderint.h> + +namespace oxygen +{ + +class OXYGEN_API ODECollider : public ColliderInt, public ODEPhysicsObject +{ + +public: + ODECollider(); + virtual ~ODECollider(); + + void OnCollision(boost::shared_ptr<Collider> collidee, dContact& contact, ECollisionType type); + bool AddCollisionHandler(const std::string& handlerName); + long GetGeomID(); + void SetPosition(const salt::Vector3f& pos); + void SetLocalPosition(const salt::Vector3f& pos); + salt::Vector3f GetPosition() const; + void SetRotation(const salt::Matrix& rot); + bool Intersects(boost::shared_ptr<Collider> collider); + long GetParentSpaceID(); + void AddNotCollideWithColliderName(const std::string& colliderName, bool isAdd); + const TColliderNameSet& GetNotCollideWithSet() const; + void OnLink(); + void OnUnlink(); + void PrePhysicsUpdateInternal(float deltaTime); + void DestroyPhysicsObject(); + +protected: + dGeomID mODEGeom; + TColliderNameSet mNotCollideWithSet; +}; + +} //namespace oxygen + +#endif //OXYGEN_ODECOLLIDER_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.cpp 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,28 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: odeobject.cpp 3 2008-11-21 02:38:08Z hedayat $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <oxygen/physicsserver/ode/odecompoundcollider.h> + +using namespace oxygen; + +ODECompoundCollider::ODECompoundCollider() : ODECollider(){ + +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecompoundcollider.h 2009-12-08 07:56:49 UTC (rev 116) @@ -0,0 +1,39 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: odeobject.cpp 3 2008-11-21 02:38:08Z hedayat $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef OXYGEN_ODECOMPOUNDCOLLIDER_H +#define OXYGEN_ODECOMPOUNDCOLLIDER_H + +#include <oxygen/physicsserver/ode/odecollider.h> +#include <oxygen/physicsserver/int/compoundcolliderint.h> + +namespace oxygen +{ + +class OXYGEN_API ODECompoundCollider : public CompoundColliderInt, public ODECollider +{ +public: + ODECompoundCollider(); +}; + +} //namespace oxygen + +#endif //OXYGEN_ODECOMPOUNDCOLLIDER_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeconcavecollider.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeconcavecollider.cpp (rev 0) +++ br... [truncated message content] |