From: <a-...@us...> - 2009-11-30 08:31:13
|
Revision: 110 http://simspark.svn.sourceforge.net/simspark/?rev=110&view=rev Author: a-held Date: 2009-11-30 08:31:04 +0000 (Mon, 30 Nov 2009) Log Message: ----------- provided bridge pattern for all non-implemented body classes prepared bridge pattern for RigidBody class Modified Paths: -------------- branches/multiphys/spark/lib/oxygen/CMakeLists.txt branches/multiphys/spark/lib/oxygen/physicsserver/body.h branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.h branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.h branches/multiphys/spark/lib/oxygen/physicsserver/softbody.h branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.h Added Paths: ----------- branches/multiphys/spark/lib/oxygen/physicsserver/body.cpp branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/int/bodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.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/staticbodyint.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.h branches/multiphys/spark/lib/oxygen/physicsserver/softbody.cpp branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.cpp Modified: branches/multiphys/spark/lib/oxygen/CMakeLists.txt =================================================================== --- branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-11-30 08:31:04 UTC (rev 110) @@ -54,15 +54,25 @@ physicsserver/angularmotor.h #interfaces + physicsserver/int/bodyint.h + physicsserver/int/dynamicbodyint.h physicsserver/int/physicsobjectint.h physicsserver/int/physicsserverint.h + physicsserver/int/rigidbodyint.h + physicsserver/int/softbodyint.h physicsserver/int/spaceint.h + physicsserver/int/staticbodyint.h physicsserver/int/worldint.h #ode-specific files + physicsserver/ode/odebody.h + physicsserver/ode/odedynamicbody.h physicsserver/ode/odephysicsobject.h physicsserver/ode/odephysicsserver.h + physicsserver/ode/oderigidbody.h + physicsserver/ode/odesoftbody.h physicsserver/ode/odespace.h + physicsserver/ode/odestaticbody.h physicsserver/ode/odeworld.h physicsserver/ode/odewrapper.h @@ -127,11 +137,15 @@ oxygen.cpp physicsserver/physicsobject.cpp physicsserver/physicsobject_c.cpp + physicsserver/body.cpp physicsserver/body_c.cpp physicsserver/rigidbody.cpp physicsserver/rigidbody_c.cpp + physicsserver/staticbody.cpp physicsserver/staticbody_c.cpp + physicsserver/dynamicbody.cpp physicsserver/dynamicbody_c.cpp + physicsserver/softbody.cpp physicsserver/softbody_c.cpp physicsserver/bodycontroller.cpp physicsserver/bodycontroller_c.cpp @@ -191,9 +205,14 @@ physicsserver/angularmotor_c.cpp #ODE-specific files + physicsserver/ode/odebody.cpp + physicsserver/ode/odedynamicbody.cpp physicsserver/ode/odephysicsobject.cpp physicsserver/ode/odephysicsserver.cpp + physicsserver/ode/oderigidbody.cpp + physicsserver/ode/odesoftbody.cpp physicsserver/ode/odespace.cpp + physicsserver/ode/odestaticbody.cpp physicsserver/ode/odeworld.cpp sceneserver/basenode.cpp Added: branches/multiphys/spark/lib/oxygen/physicsserver/body.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/body.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/body.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -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 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/body.h> +#include <oxygen/physicsserver/ode/odebody.h> + +using namespace oxygen; + +Body::Body() : PhysicsObject(){ + mBodyImp = boost::shared_ptr<ODEBody>(new ODEBody()); +} + +Body::~Body(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/body.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/body.h 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/body.h 2009-11-30 08:31:04 UTC (rev 110) @@ -26,6 +26,8 @@ namespace oxygen { +class BodyInt; + /** This is currently a placeholder class to comply with the inheritance tree. Once a Body class other than RigidBody has been implemented, common functionality should be moved to this @@ -35,8 +37,10 @@ class OXYGEN_API Body : public PhysicsObject { public: - Body() : PhysicsObject(){}; - virtual ~Body (){}; + Body(); + virtual ~Body(); + + boost::shared_ptr<BodyInt> mBodyImp; }; DECLARE_CLASS(Body); Added: branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -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/dynamicbody.h> +#include <oxygen/physicsserver/ode/odedynamicbody.h> + +using namespace oxygen; + +DynamicBody::DynamicBody() : Body(){ + mDynamicBodyImp = boost::shared_ptr<ODEDynamicBody>(new ODEDynamicBody()); +} + +DynamicBody::~DynamicBody(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.h 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/dynamicbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -27,6 +27,7 @@ namespace oxygen { +class DynamicBodyInt; /** DynamicBody is not yet implemented. */ @@ -37,8 +38,10 @@ // Functions // public: - DynamicBody() : Body(){}; - virtual ~DynamicBody(){}; + DynamicBody(); + virtual ~DynamicBody(); + + boost::shared_ptr<DynamicBodyInt> mDynamicBodyImp; }; DECLARE_CLASS(DynamicBody); Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/bodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/bodyint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/bodyint.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,42 @@ +/* -*- 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_BODYINT_H +#define OXYGEN_BODYINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odephysicsobject.h> + +namespace oxygen +{ + +class OXYGEN_API BodyInt : public ODEPhysicsObject +{ + +public: + BodyInt() : ODEPhysicsObject(){}; + virtual ~BodyInt(){}; +}; + +} //namespace oxygen + +#endif //OXYGEN_BODYINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/dynamicbodyint.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,42 @@ +/* -*- 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_DYNAMICBODYINT_H +#define OXYGEN_DYNAMICBODYINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odebody.h> + +namespace oxygen +{ + +class OXYGEN_API DynamicBodyInt : public ODEBody +{ + +public: + DynamicBodyInt() : ODEBody(){}; + virtual ~DynamicBodyInt(){}; +}; + +} //namespace oxygen + +#endif //OXYGEN_DYNAMICBODYINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,105 @@ +/* -*- 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_RIGIDBODYINT_H +#define OXYGEN_RIGIDBODYINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odebody.h> + +namespace oxygen +{ + +class OXYGEN_API RigidBodyInt : public ODEBody +{ + +public: + RigidBodyInt() : ODEBody(){}; + virtual ~RigidBodyInt(){}; + + virtual dBodyID GetODEBody() const = 0; + virtual void Enable() = 0; + virtual void Disable() = 0; + virtual bool IsEnabled() const = 0; + virtual void UseGravity(bool f) = 0; + virtual bool UsesGravity() const = 0; + virtual void SetMass(float mass) = 0; + virtual void SetMassParameters(const dMass& mass) = 0; + virtual float GetMass() const = 0; + virtual void GetMassParameters(dMass& mass) const = 0; + virtual void SetSphere(float density, float radius) = 0; + virtual void AddSphere(float density, float radius, const salt::Matrix& matrix) = 0; + virtual void SetSphereTotal(float total_mass, float radius) = 0; + virtual void AddSphereTotal(float total_mass, float radius, const salt::Matrix& matrix) = 0; + virtual void SetBox(float density, const salt::Vector3f& size) = 0; + virtual void AddBox(float density, const salt::Vector3f& size, const salt::Matrix& matrix) = 0; + virtual void SetBoxTotal(float total_mass, const salt::Vector3f& size) = 0; + virtual void AddBoxTotal(float total_mass, const salt::Vector3f& size, const salt::Matrix& matrix) = 0; + virtual void SetCylinder(float density, float radius, float length) = 0; + virtual void AddCylinder(float density, float radius, float length, const salt::Matrix& matrix) = 0; + virtual void SetCylinderTotal(float total_mass, float radius, float length) = 0; + virtual void AddCylinderTotal(float total_mass, float radius, float length, const salt::Matrix& matrix) = 0; + virtual void SetCapsule(float density, float radius, float length) = 0; + virtual void AddCapsule(float density, float radius, float length, const salt::Matrix& matrix) = 0; + virtual void SetCapsuleTotal(float total_mass, float radius, float length) = 0; + virtual void AddCapsuleTotal(float total_mass, float radius, float length, const salt::Matrix& matrix) = 0; + virtual void TranslateMass(const salt::Vector3f& v) = 0; + virtual salt::Vector3f GetVelocity() const = 0; + virtual void SetVelocity(const salt::Vector3f& vel) = 0; + virtual void SetRotation(const salt::Matrix& rot) = 0; + virtual salt::Matrix GetRotation() const = 0; + virtual salt::Vector3f GetAngularVelocity() const = 0; + virtual void SetAngularVelocity(const salt::Vector3f& vel) = 0; + virtual void AddForce(const salt::Vector3f& force) = 0; + virtual void AddTorque(const salt::Vector3f& torque) = 0; + virtual void SetPosition(const salt::Vector3f& pos) = 0; + virtual salt::Vector3f GetPosition() const = 0; + virtual void DestroyPhysicsObject() = 0; + virtual void SynchronizeParent() const = 0; + virtual void AddMass(const dMass& mass, const salt::Matrix& matrix) = 0; + //virtual salt::Vector3f GetMassCenter() const = 0; + +protected: + virtual void OnLink() = 0; + virtual bool CreateBody() = 0; + virtual void PrepareBoxTotal(dMass& mass, float total_mass, const salt::Vector3f& size) const = 0; + virtual void PrepareBox(dMass& mass, float density, const salt::Vector3f& size) const = 0; + virtual void PrepareSphere(dMass& mass, float density, float radius) const = 0; + virtual void PrepareSphereTotal(dMass& mass, float total_mass, float radius) const = 0; + virtual void PrepareCylinder(dMass& mass, float density, float radius, float length) const = 0; + virtual void PrepareCylinderTotal(dMass& mass, float total_mass, float radius, float length) const = 0; + virtual void PrepareCapsule(dMass& mass, float density, float radius, float length) const = 0; + virtual void PrepareCapsuleTotal(dMass& mass, float total_mass, float radius, float length) const = 0; + +private: + virtual void PrePhysicsUpdateInternal(float deltaTime) = 0; + virtual void PostPhysicsUpdateInternal() = 0; + +protected: + dBodyID mODEBody; + salt::Vector3f mMassTrans; + bool mMassTransformed; +}; + +} //namespace oxygen + +#endif //OXYGEN_RIGIDBODYINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/softbodyint.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,42 @@ +/* -*- 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_SOFTBODYINT_H +#define OXYGEN_SOFTBODYINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odebody.h> + +namespace oxygen +{ + +class OXYGEN_API SoftBodyInt : public ODEBody +{ + +public: + SoftBodyInt() : ODEBody(){}; + virtual ~SoftBodyInt(){}; +}; + +} //namespace oxygen + +#endif //OXYGEN_SOFTBODYINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/staticbodyint.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,42 @@ +/* -*- 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_STATICBODYINT_H +#define OXYGEN_STATICBODYINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odebody.h> + +namespace oxygen +{ + +class OXYGEN_API StaticBodyInt : public ODEBody +{ + +public: + StaticBodyInt() : ODEBody(){}; + virtual ~StaticBodyInt(){}; +}; + +} //namespace oxygen + +#endif //OXYGEN_STATICBODYINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,32 @@ +/* -*- 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/odebody.h> + +using namespace oxygen; + +ODEBody::ODEBody() : BodyInt(){ + +} + +ODEBody::~ODEBody(){ + +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odebody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -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_ODEBODY_H +#define OXYGEN_ODEBODY_H + +#include <oxygen/physicsserver/int/bodyint.h> + +namespace oxygen +{ + +class OXYGEN_API ODEBody : public BodyInt +{ +public: + ODEBody(); + virtual ~ODEBody(); +}; + +} //namespace oxygen + +#endif //OXYGEN_ODEBODY_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,32 @@ +/* -*- 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/odedynamicbody.h> + +using namespace oxygen; + +ODEDynamicBody::ODEDynamicBody() : DynamicBodyInt(){ + +} + +ODEDynamicBody::~ODEDynamicBody(){ + +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odedynamicbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -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_ODEDYNAMICBODY_H +#define OXYGEN_ODEDYNAMICBODY_H + +#include <oxygen/physicsserver/int/dynamicbodyint.h> + +namespace oxygen +{ + +class OXYGEN_API ODEDynamicBody : public DynamicBodyInt +{ +public: + ODEDynamicBody(); + virtual ~ODEDynamicBody(); +}; + +} //namespace oxygen + +#endif //OXYGEN_ODEDYNAMICBODY_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,532 @@ +/* -*- 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/rigidbody.h> +#include <oxygen/physicsserver/transformcollider.h> +#include <oxygen/physicsserver/world.h> +#include <oxygen/physicsserver/ode/oderigidbody.h> +#include <oxygen/sceneserver/scene.h> +#include <oxygen/sceneserver/transform.h> +#include <zeitgeist/logserver/logserver.h> + +using namespace oxygen; +using namespace boost; +using namespace salt; +using namespace std; + +ODERigidBody::ODERigidBody() : RigidBodyInt(){ + +} + +ODERigidBody::~ODERigidBody(){ + +} + +dBodyID ODERigidBody::GetODEBody() const +{ + return mODEBody; +} + +void ODERigidBody::Enable() +{ + dBodyEnable(mODEBody); +} + +void ODERigidBody::Disable() +{ + dBodyDisable(mODEBody); +} + +bool ODERigidBody::IsEnabled() const +{ + return (dBodyIsEnabled(mODEBody) != 0); +} + +void ODERigidBody::UseGravity(bool f) +{ + if (f == true) + { + // body is affected by gravity + dBodySetGravityMode(mODEBody, 1); + } + else + { + // body is not affected by gravity + dBodySetGravityMode(mODEBody, 0); + } +} + +bool ODERigidBody::UsesGravity() const +{ + return (dBodyGetGravityMode(mODEBody) != 0); +} + +bool ODERigidBody::CreateBody() +{ + if (mODEBody != 0) + { + return true; + } + + dWorldID world = GetWorldID(); + if (world == 0) + { + return false; + } + + // create the managed body + mODEBody = dBodyCreate(world); + if (mODEBody == 0) + { + GetLog()->Error() + << "(Body) ERROR: could not create new ODE body\n"; + return false; + } + + return true; +} + +void ODERigidBody::DestroyPhysicsObject() +{ + if (mODEBody == 0) + { + return; + } + + dBodyDestroy(mODEBody); + mODEBody = 0; +} + +void ODERigidBody::OnLink() +{ + ODEPhysicsObject::OnLink(); + + if (! CreateBody()) + { + return; + } + + // let the body, take on the world space position of the parent + dBodySetData(mODEBody, this); + + shared_ptr<BaseNode> baseNode = shared_static_cast<BaseNode> + (GetParent().lock()); + + const Matrix& mat = baseNode->GetWorldTransform(); + SetRotation(mat); + SetPosition(mat.Pos()); +} + +void ODERigidBody::SetMass(float mass) +{ + dMass ODEMass; + dBodyGetMass(mODEBody, &ODEMass); + dMassAdjust(&ODEMass, mass); + dBodySetMass(mODEBody, &ODEMass); +} + +float ODERigidBody::GetMass() const +{ + dMass m; + dBodyGetMass(mODEBody, &m); + return m.mass; +} + +void ODERigidBody::GetMassParameters(dMass& mass) const +{ + dBodyGetMass(mODEBody, &mass); +} + +void ODERigidBody::SetMassParameters(const dMass& mass) +{ + dBodySetMass(mODEBody, &mass); +} + +void ODERigidBody::PrepareSphere(dMass& mass, float density, float radius) const +{ + dMassSetSphere(&mass, density, radius); +} + +void ODERigidBody::SetSphere(float density, float radius) +{ + dMass ODEMass; + PrepareSphere(ODEMass, density, radius); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddSphere(float density, float radius, const Matrix& matrix) +{ + dMass ODEMass; + PrepareSphere(ODEMass, density, radius); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareSphereTotal(dMass& mass, float total_mass, float radius) const +{ + dMassSetSphereTotal(&mass, total_mass, radius); +} + +void ODERigidBody::SetSphereTotal(float total_mass, float radius) +{ + dMass ODEMass; + PrepareSphereTotal(ODEMass, total_mass, radius); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddSphereTotal(float total_mass, float radius, const Matrix& matrix) +{ + dMass ODEMass; + PrepareSphereTotal(ODEMass, total_mass, radius); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareBox(dMass& mass, float density, const Vector3f& size) const +{ + dMassSetBox(&mass, density, size[0], size[1], size[2]); +} + +void ODERigidBody::SetBox(float density, const Vector3f& size) +{ + dMass ODEMass; + PrepareBox(ODEMass, density, size); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddBox(float density, const Vector3f& size, const Matrix& matrix) +{ + dMass ODEMass; + PrepareBox(ODEMass, density, size); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareBoxTotal(dMass& mass, float total_mass, const Vector3f& size) const +{ + dMassSetBoxTotal(&mass, total_mass, size[0], size[1], size[2]); +} + +void ODERigidBody::SetBoxTotal(float total_mass, const Vector3f& size) +{ + dMass ODEMass; + PrepareBoxTotal(ODEMass, total_mass, size); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddBoxTotal(float total_mass, const Vector3f& size, const Matrix& matrix) +{ + dMass ODEMass; + PrepareBoxTotal(ODEMass, total_mass, size); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::AddMass(const dMass& mass, const Matrix& matrix) +{ + dMass transMass(mass); + + dMatrix3 rot; + ConvertRotationMatrix(matrix, rot); + dMassRotate(&transMass,rot); + + const Vector3f& trans(matrix.Pos()); + dMassTranslate(&transMass,trans[0],trans[1],trans[2]); + + dMassTranslate(&transMass,mMassTrans[0],mMassTrans[1],mMassTrans[2]); + + dMass bodyMass; + dBodyGetMass(mODEBody, &bodyMass); + dMassAdd(&bodyMass, &transMass); + + /** ODE currently requires that the center mass is always in the + origin of the body + */ + Vector3f trans2(bodyMass.c[0], bodyMass.c[1], bodyMass.c[2]); + + dMassTranslate(&bodyMass, -trans2[0], -trans2[1], -trans2[2]); + bodyMass.c[0] = bodyMass.c[1] = bodyMass.c[2] = 0.0f; + dBodySetMass(mODEBody, (const dMass*)&bodyMass); + + // Move body so mass is at right position again + SetPosition(GetPosition() + trans2); + + // Keep track of total translation of mass + mMassTrans = mMassTrans - trans2; + + mMassTransformed = true; +} + +void ODERigidBody::PrepareCylinder (dMass& mass, float density, float radius, float length) const +{ + // direction: (1=x, 2=y, 3=z) + int direction = 3; + + dMassSetCylinder (&mass, density, direction, radius, length); +} + +void ODERigidBody::SetCylinder (float density, float radius, float length) +{ + dMass ODEMass; + PrepareCylinder(ODEMass, density, radius, length); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddCylinder (float density, float radius, float length, const Matrix& matrix) +{ + dMass ODEMass; + PrepareCylinder(ODEMass, density, radius, length); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareCylinderTotal(dMass& mass, float total_mass, float radius, float length) const +{ + // direction: (1=x, 2=y, 3=z) + int direction = 3; + + dMassSetCylinderTotal(&mass, total_mass, direction, radius, length); +} + +void ODERigidBody::SetCylinderTotal(float total_mass, float radius, float length) +{ + dMass ODEMass; + PrepareCylinderTotal(ODEMass, total_mass, radius, length); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddCylinderTotal(float total_mass, float radius, float length, const Matrix& matrix) +{ + dMass ODEMass; + PrepareCylinderTotal(ODEMass, total_mass, radius, length); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareCapsule (dMass& mass, float density, float radius, float length) const +{ + // direction: (1=x, 2=y, 3=z) + int direction = 3; + + dMassSetCapsule (&mass, density, direction, radius, length); +} + +void ODERigidBody::SetCapsule (float density, float radius, float length) +{ + dMass ODEMass; + PrepareCapsule(ODEMass, density, radius, length); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddCapsule (float density, float radius, float length, const Matrix& matrix) +{ + dMass ODEMass; + PrepareCapsule(ODEMass, density, radius, length); + AddMass(ODEMass, matrix); +} + +void ODERigidBody::PrepareCapsuleTotal(dMass& mass, float total_mass, float radius, float length) const +{ + // direction: (1=x, 2=y, 3=z) + int direction = 3; + + dMassSetCapsuleTotal(&mass, total_mass, direction, radius, length); +} + +void ODERigidBody::SetCapsuleTotal(float total_mass, float radius, float length) +{ + dMass ODEMass; + PrepareCapsuleTotal(ODEMass, total_mass, radius, length); + dBodySetMass(mODEBody, &ODEMass); +} + +void ODERigidBody::AddCapsuleTotal(float total_mass, float radius, float length, const salt::Matrix& matrix) +{ + dMass ODEMass; + PrepareCapsuleTotal(ODEMass, total_mass, radius, length); + AddMass(ODEMass, matrix); +} + +Vector3f ODERigidBody::GetVelocity() const +{ + const dReal* vel = dBodyGetLinearVel(mODEBody); + return Vector3f(vel[0], vel[1], vel[2]); +} + +void ODERigidBody::SetVelocity(const Vector3f& vel) +{ + dBodySetLinearVel(mODEBody, vel[0], vel[1], vel[2]); +} + +void ODERigidBody::SetRotation(const Matrix& rot) +{ + dMatrix3 m; + ConvertRotationMatrix(rot,m); + dBodySetRotation(mODEBody,m); +} + +salt::Matrix ODERigidBody::GetRotation() const +{ + const dReal* m = dBodyGetRotation(mODEBody); + salt::Matrix rot; + ConvertRotationMatrix(m,rot); + return rot; +} + +Vector3f ODERigidBody::GetAngularVelocity() const +{ + const dReal* vel = dBodyGetAngularVel(mODEBody); + return Vector3f(vel[0], vel[1], vel[2]); +} + +void ODERigidBody::SetAngularVelocity(const Vector3f& vel) +{ + dBodySetAngularVel(mODEBody, vel[0], vel[1], vel[2]); +} + +void ODERigidBody::SynchronizeParent() const +{ + const dReal* pos = dBodyGetPosition(mODEBody); + const dReal* rot = dBodyGetRotation(mODEBody); + + shared_ptr<BaseNode> baseNode = shared_static_cast<BaseNode> + (GetParent().lock()); + + + Matrix mat; + mat.m[0] = rot[0]; + mat.m[1] = rot[4]; + mat.m[2] = rot[8]; + mat.m[3] = 0; + mat.m[4] = rot[1]; + mat.m[5] = rot[5]; + mat.m[6] = rot[9]; + mat.m[7] = 0; + mat.m[8] = rot[2]; + mat.m[9] = rot[6]; + mat.m[10] = rot[10]; + mat.m[11] = 0; + mat.m[12] = pos[0]; + mat.m[13] = pos[1]; + mat.m[14] = pos[2]; + mat.m[15] = 1; + + baseNode->SetWorldTransform(mat); +} + +void ODERigidBody::PrePhysicsUpdateInternal(float /*deltaTime*/) +{ + // Check whether mass/body has been translated + if (mMassTransformed) + { + weak_ptr<Node> parent = GetParent(); + + // Update colliders (only those encapsulated in transform colliders) + TLeafList transformColliders; + parent.lock()->ListChildrenSupportingClass<TransformCollider>(transformColliders); + + for (TLeafList::iterator iter = transformColliders.begin(); iter != transformColliders.end(); ++iter) + { + // Only move non-transform colliders + shared_ptr<Collider> collider = shared_static_cast<TransformCollider>(*iter)->FindChildSupportingClass<Collider>(); + if (collider.get()) + { + Vector3f pos = collider->GetPosition(); + pos = pos + mMassTrans; + collider->SetLocalPosition(pos); + } + } + + // Update visuals (or other transforms in the tree) + TLeafList transforms; + parent.lock()->ListShallowChildrenSupportingClass<Transform>(transforms); + for (TLeafList::iterator iter = transforms.begin(); iter != transforms.end(); ++iter) + { + shared_ptr<Transform> transform = shared_dynamic_cast<Transform>(*iter); + Matrix worldTransform = transform->GetWorldTransform(); + worldTransform.Pos() = worldTransform.Pos() + mMassTrans; + transform->SetWorldTransform(worldTransform); + } + + mMassTrans = Vector3f(0,0,0); + mMassTransformed = false; + } +} + + +void ODERigidBody::PostPhysicsUpdateInternal() +{ + SynchronizeParent(); +} + +shared_ptr<RigidBody> ODERigidBody::GetBody(dBodyID id) +{ + if (id == 0) + { + return shared_ptr<RigidBody>(); + } + + RigidBody* bodyPtr = + static_cast<RigidBody*>(dBodyGetData(id)); + + if (bodyPtr == 0) + { + // we cannot use the logserver here + cerr << "ERROR: (ODERigidBody) no body found for dBodyID " + << id << "\n"; + return shared_ptr<RigidBody>(); + } + + shared_ptr<RigidBody> body = shared_static_cast<RigidBody> + (bodyPtr->GetSelf().lock()); + + if (body.get() == 0) + { + // we cannot use the logserver here + cerr << "ERROR: (ODERigidBody) got no shared_ptr for dBodyID " + << id << "\n"; + } + + return body; +} + +void ODERigidBody::AddForce(const Vector3f& force) +{ + dBodyAddForce(mODEBody, force.x(), force.y(), force.z()); +} + +void ODERigidBody::AddTorque(const Vector3f& torque) +{ + dBodyAddTorque(mODEBody, torque.x(), torque.y(), torque.z()); +} + +void ODERigidBody::SetPosition(const Vector3f& pos) +{ + dBodySetPosition(mODEBody, pos.x(), pos.y(), pos.z()); + // the parent node will be updated in the next physics cycle +} + +Vector3f ODERigidBody::GetPosition() const +{ + const dReal* pos = dBodyGetPosition(mODEBody); + return Vector3f(pos[0], pos[1], pos[2]); +} + +void ODERigidBody::TranslateMass(const Vector3f& v) +{ + dMass m; + dBodyGetMass(mODEBody, &m); + dMassTranslate(&m,v[0],v[1],v[2]); +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/oderigidbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,103 @@ +/* -*- 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_ODERIGIDBODY_H +#define OXYGEN_ODERIGIDBODY_H + +#include <oxygen/physicsserver/int/rigidbodyint.h> + +namespace oxygen +{ + +class OXYGEN_API ODERigidBody : public RigidBodyInt +{ +public: + ODERigidBody(); + virtual ~ODERigidBody(); + + dBodyID GetODEBody() const; + void Enable(); + void Disable(); + bool IsEnabled() const; + void UseGravity(bool f); + bool UsesGravity() const; + void SetMass(float mass); + void SetMassParameters(const dMass& mass); + float GetMass() const; + void GetMassParameters(dMass& mass) const; + void SetSphere(float density, float radius); + void AddSphere(float density, float radius, const salt::Matrix& matrix); + void SetSphereTotal(float total_mass, float radius); + void AddSphereTotal(float total_mass, float radius, const salt::Matrix& matrix); + void SetBox(float density, const salt::Vector3f& size); + void AddBox(float density, const salt::Vector3f& size, const salt::Matrix& matrix); + void SetBoxTotal(float total_mass, const salt::Vector3f& size); + void AddBoxTotal(float total_mass, const salt::Vector3f& size, const salt::Matrix& matrix); + void SetCylinder(float density, float radius, float length); + void AddCylinder(float density, float radius, float length, const salt::Matrix& matrix); + void SetCylinderTotal(float total_mass, float radius, float length); + void AddCylinderTotal(float total_mass, float radius, float length, const salt::Matrix& matrix); + void SetCapsule(float density, float radius, float length); + void AddCapsule(float density, float radius, float length, const salt::Matrix& matrix); + void SetCapsuleTotal(float total_mass, float radius, float length); + void AddCapsuleTotal(float total_mass, float radius, float length, const salt::Matrix& matrix); + void TranslateMass(const salt::Vector3f& v); + salt::Vector3f GetVelocity() const; + void SetVelocity(const salt::Vector3f& vel); + void SetRotation(const salt::Matrix& rot); + salt::Matrix GetRotation() const; + salt::Vector3f GetAngularVelocity() const; + void SetAngularVelocity(const salt::Vector3f& vel); + void AddForce(const salt::Vector3f& force); + void AddTorque(const salt::Vector3f& torque); + void SetPosition(const salt::Vector3f& pos); + salt::Vector3f GetPosition() const; + void DestroyPhysicsObject(); + void SynchronizeParent() const; + void AddMass(const dMass& mass, const salt::Matrix& matrix); + //salt::Vector3f GetMassCenter() const; + boost::shared_ptr<RigidBody> GetBody(dBodyID id); //static in rigidbody.h + +protected: + void OnLink(); + bool CreateBody(); + void PrepareBoxTotal(dMass& mass, float total_mass, const salt::Vector3f& size) const; + void PrepareBox(dMass& mass, float density, const salt::Vector3f& size) const; + void PrepareSphere(dMass& mass, float density, float radius) const; + void PrepareSphereTotal(dMass& mass, float total_mass, float radius) const; + void PrepareCylinder(dMass& mass, float density, float radius, float length) const; + void PrepareCylinderTotal(dMass& mass, float total_mass, float radius, float length) const; + void PrepareCapsule(dMass& mass, float density, float radius, float length) const; + void PrepareCapsuleTotal(dMass& mass, float total_mass, float radius, float length) const; + +private: + void PrePhysicsUpdateInternal(float deltaTime); + void PostPhysicsUpdateInternal(); + +protected: + dBodyID mODEBody; + salt::Vector3f mMassTrans; + bool mMassTransformed; +}; + +} //namespace oxygen + +#endif //OXYGEN_ODERIGIDBODY_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,32 @@ +/* -*- 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/odesoftbody.h> + +using namespace oxygen; + +ODESoftBody::ODESoftBody() : SoftBodyInt(){ + +} + +ODESoftBody::~ODESoftBody(){ + +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesoftbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -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_ODESOFTBODY_H +#define OXYGEN_ODESOFTBODY_H + +#include <oxygen/physicsserver/int/softbodyint.h> + +namespace oxygen +{ + +class OXYGEN_API ODESoftBody : public SoftBodyInt +{ +public: + ODESoftBody(); + virtual ~ODESoftBody(); +}; + +} //namespace oxygen + +#endif //OXYGEN_ODESOFTBODY_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -0,0 +1,32 @@ +/* -*- 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/odestaticbody.h> + +using namespace oxygen; + +ODEStaticBody::ODEStaticBody() : StaticBodyInt(){ + +} + +ODEStaticBody::~ODEStaticBody(){ + +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odestaticbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -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_ODESTATICBODY_H +#define OXYGEN_ODESTATICBODY_H + +#include <oxygen/physicsserver/int/staticbodyint.h> + +namespace oxygen +{ + +class OXYGEN_API ODEStaticBody : public StaticBodyInt +{ +public: + ODEStaticBody(); + virtual ~ODEStaticBody(); +}; + +} //namespace oxygen + +#endif //OXYGEN_ODESTATICBODY_H Modified: branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.cpp 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -17,13 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include <oxygen/physicsserver/rigidbody.h> #include <oxygen/physicsserver/transformcollider.h> #include <oxygen/physicsserver/world.h> +#include <oxygen/physicsserver/ode/oderigidbody.h> #include <oxygen/sceneserver/scene.h> -#include "zeitgeist/logserver/logserver.h" #include <oxygen/sceneserver/transform.h> +#include <zeitgeist/logserver/logserver.h> using namespace boost; using namespace oxygen; @@ -32,6 +32,7 @@ RigidBody::RigidBody() : Body(), mODEBody(0), mMassTrans(0,0,0), mMassTransformed(false) { + mRigidBodyImp = boost::shared_ptr<ODERigidBody>(new ODERigidBody()); } RigidBody::~RigidBody() Modified: branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.h 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -28,6 +28,7 @@ namespace oxygen { class World; +class RigidBodyInt; /** Body encapsulates an ODE rigid body object. A rigid body has various properties from the point of view of the simulation. Some @@ -318,6 +319,8 @@ // Members // protected: + boost::shared_ptr<RigidBodyInt> mRigidBodyImp; + /** the managed ode body */ dBodyID mODEBody; Added: branches/multiphys/spark/lib/oxygen/physicsserver/softbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/softbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/softbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -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/softbody.h> +#include <oxygen/physicsserver/ode/odesoftbody.h> + +using namespace oxygen; + +SoftBody::SoftBody() : Body(){ + mSoftBodyImp = boost::shared_ptr<ODESoftBody>(new ODESoftBody()); +} + +SoftBody::~SoftBody(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/softbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/softbody.h 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/softbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -27,6 +27,7 @@ namespace oxygen { +class SoftBodyInt; /** SoftBody is not yet implemented. */ @@ -37,8 +38,10 @@ // Functions // public: - SoftBody() : Body(){}; - virtual ~SoftBody(){}; + SoftBody(); + virtual ~SoftBody(); + + boost::shared_ptr<SoftBodyInt> mSoftBodyImp; }; DECLARE_CLASS(SoftBody); Added: branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.cpp 2009-11-30 08:31:04 UTC (rev 110) @@ -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/staticbody.h> +#include <oxygen/physicsserver/ode/odestaticbody.h> + +using namespace oxygen; + +StaticBody::StaticBody() : Body(){ + mStaticBodyImp = boost::shared_ptr<ODEStaticBody>(new ODEStaticBody()); +} + +StaticBody::~StaticBody(){ + +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.h 2009-11-26 10:30:24 UTC (rev 109) +++ branches/multiphys/spark/lib/oxygen/physicsserver/staticbody.h 2009-11-30 08:31:04 UTC (rev 110) @@ -27,6 +27,7 @@ namespace oxygen { +class StaticBodyInt; /** StaticBody is not yet implemented. */ @@ -37,8 +38,10 @@ // Functions // public: - StaticBody() : Body(){}; - virtual ~StaticBody(){}; + StaticBody(); + virtual ~StaticBody(); + + boost::shared_ptr<StaticBodyInt> mStaticBodyImp; }; DECLARE_CLASS(StaticBody); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |