From: <a-...@us...> - 2010-01-13 13:21:38
|
Revision: 142 http://simspark.svn.sourceforge.net/simspark/?rev=142&view=rev Author: a-held Date: 2010-01-13 13:21:31 +0000 (Wed, 13 Jan 2010) Log Message: ----------- Finished bridge pattern for ContactJointHandler class made the collisionperceptor plugin a little less ODE-specific added the rcsoccersim3d script that SVN "forgot" in the last update Changes to soccer.rsg are temporary Modified Paths: -------------- branches/multiphys/rcssserver3d/data/rsg/agent/nao/soccer.rsg branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.cpp branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.h branches/multiphys/spark/lib/oxygen/physicsserver/int/contactjointhandlerint.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.h branches/multiphys/spark/lib/oxygen/physicsserver/space.cpp branches/multiphys/spark/lib/oxygen/physicsserver/space.h branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.h branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.cpp branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.h Added Paths: ----------- branches/multiphys/rcssserver3d/rcssserver3d/rcsoccersim3d.in Modified: branches/multiphys/rcssserver3d/data/rsg/agent/nao/soccer.rsg =================================================================== --- branches/multiphys/rcssserver3d/data/rsg/agent/nao/soccer.rsg 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/rcssserver3d/data/rsg/agent/nao/soccer.rsg 2010-01-13 13:21:31 UTC (rev 142) @@ -81,6 +81,49 @@ ) ) +; create falling box + (nd AgentAspect + (setName fallBox) + (setLocalPos -4.9 -3.5 200) + (importScene rsg/boxspheres/box.rsg 1 1 1 100 matGrey) +) + + (nd AgentAspect + (setName 2Box) + (setLocalPos -4.9 -3.5 0.5) + (importScene rsg/boxspheres/box.rsg 1 0.1 2 1 matRed) +) + +(nd AgentAspect + (setName 3Box) + (setLocalPos -4.9 -2 0.5) + (importScene rsg/boxspheres/box.rsg 1 0.1 2 1 matRed) +) + +(nd AgentAspect + (setName 4Box) + (setLocalPos -4.9 -0.5 0.5) + (importScene rsg/boxspheres/box.rsg 1 0.1 2 2 matRed) +) + +(nd AgentAspect + (setName 5Box) + (setLocalPos -4.9 1 0.5) + (importScene rsg/boxspheres/box.rsg 1 0.1 2 2 matRed) +) + +(nd AgentAspect + (setName 6Box) + (setLocalPos -4.9 2.5 0.5) + (importScene rsg/boxspheres/box.rsg 1 0.1 2 3 matRed) +) + +(nd AgentAspect + (setName Sphere) + (setLocalPos -4.9 -4.2 0.5) + (importScene rsg/boxspheres/sphere.rsg 0.5 0.2 matYellow) +) + ; create skybox (nd Transform (setLocalPos 0 0 0) Added: branches/multiphys/rcssserver3d/rcssserver3d/rcsoccersim3d.in =================================================================== --- branches/multiphys/rcssserver3d/rcssserver3d/rcsoccersim3d.in (rev 0) +++ branches/multiphys/rcssserver3d/rcssserver3d/rcsoccersim3d.in 2010-01-13 13:21:31 UTC (rev 142) @@ -0,0 +1,72 @@ +#! /bin/sh + +bindir="@CMAKE_INSTALL_PREFIX@/@BINDIR@" +libdir="@CMAKE_INSTALL_PREFIX@/@LIBDIR@" + +LIBPATH="$libdir/simspark:$libdir/rcssserver3d" +if [ x"$LIBPATH" != x ] ; then + if [ x"$LD_LIBRARY_PATH" = x ] ; then + LD_LIBRARY_PATH=$LIBPATH + else + LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH + fi + export LD_LIBRARY_PATH +fi + +#-------------------------------------------------- +# option +# + +SERV="$bindir/rcssserver3d" +if [ ! -f $SERV ]; then + echo "Error: $SERV does not exist!" + echo "" + exit 1 +fi + +MON="$bindir/rcssmonitor3d" +if [ ! -f $MON ]; then + echo "Error: $MON does not exist!" + echo "" + exit 1 +fi + +AGT="$bindir/rcssagent3d" +if [ ! -f $AGT ]; then + echo "Error: $AGT does not exist!" + echo "" + exit 1 +fi + +#-------------------------------------------------- +# set handler +# + +trap kill_server INT + +#-------------------------------------------------- +# start server +# + +$SERV & +PID=$! + +#-------------------------------------------------- +# kill server +# +kill_server() +{ + kill -s INT $PID + echo "" + exit 0 +} + +#-------------------------------------------------- +# start monitor +# + +sleep 2 + +$MON & $AGT + +kill_server Property changes on: branches/multiphys/rcssserver3d/rcssserver3d/rcsoccersim3d.in ___________________________________________________________________ Added: svn:executable + * Modified: branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.cpp 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.cpp 2010-01-13 13:21:31 UTC (rev 142) @@ -32,135 +32,16 @@ ContactJointHandler::ContactJointHandler() : CollisionHandler() { mContactJointHandlerImp = boost::shared_ptr<ODEContactJointHandler>(new ODEContactJointHandler()); - - - // set up default contact surface parameters - mSurfaceParameter.mode = dContactBounce; - mSurfaceParameter.mu = dInfinity; - mSurfaceParameter.bounce = 0.8f; - mSurfaceParameter.bounce_vel = 2.0f; - - // In contactjointhandler_c.cpp, setContactSlip function, only - // accept one parameter, so two parameter is a mistake, and then - // these two value will be not initialized, but slipe mode is open - mSurfaceParameter.slip1 = 5e-3; - mSurfaceParameter.slip2 = 5e-3; - - - //mContactJointHandlerImp->Initialize(); + mContactJointHandlerImp->Initialize(); } ContactJointHandler::~ContactJointHandler() { } -float -ContactJointHandler::MixValues(const float v1, const float v2, const int n) const -{ - switch(n) - { - default: - case 0: - // undefined, default 0 - return 0.0f; - - case 1: - // first one defined - return v1; - - case 2: - // second one defined - return v2; - - case 3: - // both defined, return average - return (v1 + v2) / 2.0f; - } -} - void -ContactJointHandler::CalcSurfaceParam(dSurfaceParameters& surface, - const dSurfaceParameters& collideeParam) -{ - // init surface - surface.mode = 0; - - // calculate average mu; mu can be dInfinity, so first multiply with - // 0.5 and the sum up to avoid a range error - surface.mu = mSurfaceParameter.mu*0.5f + collideeParam.mu*0.5f; - - // soft cfm - const int nCfm = - ((mSurfaceParameter.mode & dContactSoftCFM) ? 1:0) + - ((collideeParam.mode & dContactSoftCFM) ? 2:0); - - if (nCfm>0) - { - surface.soft_cfm = MixValues - (mSurfaceParameter.soft_cfm, collideeParam.soft_cfm, nCfm); - surface.mode |= dContactSoftCFM; - } - - // soft_erp - const int nErp = - ((mSurfaceParameter.mode & dContactSoftERP) ? 1:0) + - ((collideeParam.mode & dContactSoftERP) ? 2:0); - - if (nErp>0) - { - surface.soft_erp = MixValues - (mSurfaceParameter.soft_erp, collideeParam.soft_erp, nErp); - surface.mode |= dContactSoftERP; - } - - // bounce - const int nBounce = - ((mSurfaceParameter.mode & dContactBounce) ? 1:0) + - ((collideeParam.mode & dContactBounce) ? 2:0); - - if (nBounce>0) - { - surface.bounce = MixValues - (mSurfaceParameter.bounce, collideeParam.bounce, nBounce); - - surface.bounce_vel = MixValues - (mSurfaceParameter.bounce_vel, collideeParam.bounce_vel, nBounce); - - surface.mode |= dContactBounce; - } - - // slip1 - const int nSlip1 = - ((mSurfaceParameter.mode & dContactSlip1) ? 1 : 0) + - ((collideeParam.mode & dContactSlip1) ? 2 : 0); - - if (nSlip1 > 0) - { - surface.slip1 = MixValues - (mSurfaceParameter.slip1, collideeParam.slip1, nSlip1); - - surface.mode |= dContactSlip1; - } - - // slip2 - const int nSlip2 = - ((mSurfaceParameter.mode & dContactSlip2) ? 1 : 0) + - ((collideeParam.mode & dContactSlip2) ? 2 : 0); - - if (nSlip2 > 0) - { - surface.slip2 = MixValues - (mSurfaceParameter.slip2, collideeParam.slip2, nSlip2); - - surface.mode |= dContactSlip2; - } -} - -void ContactJointHandler::HandleCollision(shared_ptr<Collider> collidee, GenericContact& contact) { - dContact& ODEContact = (dContact&) contact; - if ( (mCollider.get() == 0) || (mWorld.get() == 0) || @@ -172,8 +53,8 @@ // to create a contact joint it we must have at least one body to // attach it to. - dBodyID myBody = dGeomGetBody((dGeomID) mCollider->GetGeomID()); - dBodyID collideeBody = dGeomGetBody((dGeomID) collidee->GetGeomID()); + long myBody = mContactJointHandlerImp->RetrieveBody(mCollider->GetGeomID()); + long collideeBody = mContactJointHandlerImp->RetrieveBody(collidee->GetGeomID()); if ( (myBody == 0) && @@ -192,143 +73,134 @@ return; } - // calculate the resulting surface parameters - CalcSurfaceParam(ODEContact.surface,handler->mSurfaceParameter); + // calculate the resulting surface parameters + mContactJointHandlerImp->CalcSurfaceParam( + contact, handler->GetSurfaceParameter()); // create the contact joint and attach it to the body - dJointID joint = dJointCreateContact - ((dWorldID) mWorld->GetWorldID(), mSpace->GetODEJointGroup(), &ODEContact); + long joint = mContactJointHandlerImp->CreateContactJoint( + mWorld->GetWorldID(), mSpace->GetODEJointGroup(), contact); - dJointAttach (joint, myBody, collideeBody); + mContactJointHandlerImp->AttachContactJoint(joint, myBody, collideeBody); } void ContactJointHandler::SetSurfaceParameter(const GenericSurfaceParameter& surface) { - dSurfaceParameters& ODESurface = (dSurfaceParameters&) surface; - mSurfaceParameter = ODESurface; + mContactJointHandlerImp->SetSurfaceParameter(surface); } -const GenericSurfaceParameter& +GenericSurfaceParameter& ContactJointHandler::GetSurfaceParameter() const { - return (GenericSurfaceParameter&) mSurfaceParameter; + return mContactJointHandlerImp->GetSurfaceParameter(); } void ContactJointHandler::SetContactMode(int mode, bool set) { - if (set) - { - mSurfaceParameter.mode |= mode; - } else - { - mSurfaceParameter.mode &= ~mode; - } + mContactJointHandlerImp->SetContactMode(mode, set); } int ContactJointHandler::GetContactMode() const { - return mSurfaceParameter.mode; + return mContactJointHandlerImp->GetContactMode(); } void ContactJointHandler::SetContactBounceMode(bool set) { - SetContactMode(dContactBounce,set); + mContactJointHandlerImp->SetContactBounceMode(set); } void ContactJointHandler::SetMinBounceVel(float vel) { - mSurfaceParameter.bounce_vel = std::max<float>(0.0f,vel); + mContactJointHandlerImp->SetMinBounceVel(vel); } float ContactJointHandler::GetMinBounceVel() const { - return mSurfaceParameter.bounce_vel; + return mContactJointHandlerImp->GetMinBounceVel(); } void ContactJointHandler::SetBounceValue(float bounce) { - mSurfaceParameter.bounce = std::max<float>(0.0f,bounce); + mContactJointHandlerImp->SetBounceValue(bounce); } float ContactJointHandler::GetBounceValue() const { - return mSurfaceParameter.bounce; + return mContactJointHandlerImp->GetBounceValue(); } void ContactJointHandler::SetContactSoftERPMode(bool set) { - SetContactMode(dContactSoftERP,set); + mContactJointHandlerImp->SetContactSoftERPMode(set); } void ContactJointHandler::SetContactSoftERP(float erp) { - salt::gClamp(erp,0.0f,1.0f); - mSurfaceParameter.soft_erp = erp; + mContactJointHandlerImp->SetContactSoftERP(erp); } float ContactJointHandler::GetContactSoftERP() const { - return mSurfaceParameter.soft_erp; + return mContactJointHandlerImp->GetContactSoftERP(); } void ContactJointHandler::SetContactSoftCFMMode(bool set) { - SetContactMode(dContactSoftCFM,set); + mContactJointHandlerImp->SetContactSoftCFMMode(set); } void ContactJointHandler::SetContactSoftCFM(float cfm) { - mSurfaceParameter.soft_cfm = std::max<float>(0.0f,cfm); + mContactJointHandlerImp->SetContactSoftCFM(cfm); } float ContactJointHandler::GetContactSoftCFM() const { - return mSurfaceParameter.soft_cfm; + return mContactJointHandlerImp->GetContactSoftCFM(); } void ContactJointHandler::SetContactSlipMode (bool set) { - SetContactMode(dContactSlip1,set); - SetContactMode(dContactSlip2,set); + mContactJointHandlerImp->SetContactSlipMode(set); } void ContactJointHandler::SetContactSlip(float slip) { - mSurfaceParameter.slip1 = slip; - mSurfaceParameter.slip2 = slip; + mContactJointHandlerImp->SetContactSlip(slip); } float ContactJointHandler::GetContactSlip1() const { - return mSurfaceParameter.slip1; + return mContactJointHandlerImp->GetContactSlip1(); } float ContactJointHandler::GetContactSlip2() const { - return mSurfaceParameter.slip2; + return mContactJointHandlerImp->GetContactSlip2(); } void ContactJointHandler::SetContactMu(float mu) { - mSurfaceParameter.mu = mu; + mContactJointHandlerImp->SetContactMu(mu); } float ContactJointHandler::GetContactMu() const { - return mSurfaceParameter.mu; + return mContactJointHandlerImp->GetContactMu(); } Modified: branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/contactjointhandler.h 2010-01-13 13:21:31 UTC (rev 142) @@ -65,10 +65,10 @@ */ void SetSurfaceParameter(const GenericSurfaceParameter& surface); - /** returns the surface parameters for the contact joints taht the + /** returns the surface parameters for the contact joints that the CollisionHandler creates */ - const GenericSurfaceParameter& GetSurfaceParameter() const; + GenericSurfaceParameter& GetSurfaceParameter() const; /** sets or resets a contact mode flag in the surface parameter*/ void SetContactMode(int mode, bool set); @@ -139,16 +139,8 @@ /** returns the Coulomb friction coefficient */ float GetContactMu() const; - -protected: - f_inline float MixValues(const float v1, const float v2, const int n) const; - - void CalcSurfaceParam(dSurfaceParameters& surface, - const dSurfaceParameters& collideeParam); - dSurfaceParameters mSurfaceParameter; - -private: +protected: boost::shared_ptr<ContactJointHandlerInt> mContactJointHandlerImp; }; Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/contactjointhandlerint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/int/contactjointhandlerint.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/int/contactjointhandlerint.h 2010-01-13 13:21:31 UTC (rev 142) @@ -1,4 +1,4 @@ -/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- +/* -*- mode: c++= 0; c-basic-offset: 4= 0; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 @@ -6,24 +6,27 @@ 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 + This program is free software= 0; 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. + the Free Software Foundation= 0; 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 + but WITHOUT ANY WARRANTY= 0; 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 + along with this program= 0; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef OXYGEN_CONTACTJOINTHANDLERINT_H #define OXYGEN_CONTACTJOINTHANDLERINT_H +#include <oxygen/physicsserver/ode/odewrapper.h> + #include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/genericphysicsobjects.h> namespace oxygen { @@ -33,7 +36,35 @@ public: virtual float MixValues(const float v1, const float v2, const int n) const = 0; virtual void Initialize() = 0; + virtual long RetrieveBody(long geomID) = 0; + virtual long CreateContactJoint(long worldID, long jointGroupID, GenericContact& contact) = 0; + virtual void AttachContactJoint(long jointID, long bodyID1, long bodyID2) = 0; + virtual void CalcSurfaceParam(GenericContact& surface, GenericSurfaceParameter& collideeParam) = 0; + virtual void SetSurfaceParameter(const GenericSurfaceParameter& surface) = 0; + virtual GenericSurfaceParameter& GetSurfaceParameter() const = 0; + virtual void SetContactMode(int mode, bool set) = 0; + virtual int GetContactMode() const = 0; + virtual void SetContactBounceMode(bool set) = 0; + virtual void SetBounceValue(float bounce) = 0; + virtual float GetBounceValue() const = 0; + virtual void SetMinBounceVel(float vel) = 0; + virtual float GetMinBounceVel() const = 0; + virtual void SetContactSoftERPMode(bool set) = 0; + virtual void SetContactSoftERP(float erp) = 0; + virtual float GetContactSoftERP() const = 0; + virtual void SetContactSoftCFMMode(bool set) = 0; + virtual void SetContactSoftCFM(float cfm) = 0; + virtual float GetContactSoftCFM() const = 0; + virtual void SetContactSlipMode (bool set) = 0; + virtual void SetContactSlip(float slip) = 0; + virtual float GetContactSlip1() const = 0; + virtual float GetContactSlip2() const = 0; + virtual void SetContactMu(float mu) = 0; + virtual float GetContactMu() const = 0; + + /** the ODE surface parameters of the created contact joint */ + dSurfaceParameters mSurfaceParameter; }; } //namespace oxygen Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.cpp 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.cpp 2010-01-13 13:21:31 UTC (rev 142) @@ -39,6 +39,40 @@ mSurfaceParameter.slip2 = 5e-3; } +long ODEContactJointHandler::RetrieveBody(long geomID){ + dGeomID ODEGeom = (dGeomID) geomID; + dBodyID ODEBody = dGeomGetBody(ODEGeom); + return (long) ODEBody; +} + +long +ODEContactJointHandler::CreateContactJoint(long worldID, long jointGroupID, GenericContact& contact){ + dWorldID ODEWorld = (dWorldID) worldID; + dJointGroupID ODEJointGroup = (dJointGroupID) jointGroupID; + dContact& ODEContact = (dContact&) contact; + + dJointID ODEJoint = dJointCreateContact + (ODEWorld, ODEJointGroup, &ODEContact); + + return (long) ODEJoint; +} + +void ODEContactJointHandler::AttachContactJoint(long jointID, long bodyID1, long bodyID2){ + dJointID ODEJoint = (dJointID) jointID; + dBodyID ODEBody1 = (dBodyID) bodyID1; + dBodyID ODEBody2 = (dBodyID) bodyID2; + + dJointAttach (ODEJoint, ODEBody1, ODEBody2); +} + +void +ODEContactJointHandler::CalcSurfaceParam(GenericContact& surface, GenericSurfaceParameter& collideeParam){ + dContact& ODEContact = (dContact&) surface; + dSurfaceParameters& ODEParams = (dSurfaceParameters&) collideeParam; + + CalcSurfaceParamInternal(ODEContact.surface, ODEParams); +} + float ODEContactJointHandler::MixValues(const float v1, const float v2, const int n) const { @@ -64,8 +98,8 @@ } void -ODEContactJointHandler::CalcSurfaceParam(dSurfaceParameters& surface, - const dSurfaceParameters& collideeParam) +ODEContactJointHandler::CalcSurfaceParamInternal(dSurfaceParameters& surface, + const dSurfaceParameters& collideeParam) { // init surface surface.mode = 0; @@ -140,3 +174,134 @@ surface.mode |= dContactSlip2; } } + +void +ODEContactJointHandler::SetSurfaceParameter(const GenericSurfaceParameter& surface) +{ + dSurfaceParameters& ODESurface = (dSurfaceParameters&) surface; + mSurfaceParameter = ODESurface; +} + +GenericSurfaceParameter& +ODEContactJointHandler::GetSurfaceParameter() const +{ + return (GenericSurfaceParameter&) mSurfaceParameter; +} + +void +ODEContactJointHandler::SetContactMode(int mode, bool set) +{ + if (set) + { + mSurfaceParameter.mode |= mode; + } else + { + mSurfaceParameter.mode &= ~mode; + } +} + +int +ODEContactJointHandler::GetContactMode() const +{ + return mSurfaceParameter.mode; +} + +void +ODEContactJointHandler::SetContactBounceMode(bool set) +{ + SetContactMode(dContactBounce,set); +} + +void +ODEContactJointHandler::SetMinBounceVel(float vel) +{ + mSurfaceParameter.bounce_vel = std::max<float>(0.0f,vel); +} + +float +ODEContactJointHandler::GetMinBounceVel() const +{ + return mSurfaceParameter.bounce_vel; +} + +void +ODEContactJointHandler::SetBounceValue(float bounce) +{ + mSurfaceParameter.bounce = std::max<float>(0.0f,bounce); +} + +float +ODEContactJointHandler::GetBounceValue() const +{ + return mSurfaceParameter.bounce; +} + +void +ODEContactJointHandler::SetContactSoftERPMode(bool set) +{ + SetContactMode(dContactSoftERP,set); +} + +void +ODEContactJointHandler::SetContactSoftERP(float erp) +{ + salt::gClamp(erp,0.0f,1.0f); + mSurfaceParameter.soft_erp = erp; +} + +float +ODEContactJointHandler::GetContactSoftERP() const +{ + return mSurfaceParameter.soft_erp; +} + +void +ODEContactJointHandler::SetContactSoftCFMMode(bool set) +{ + SetContactMode(dContactSoftCFM,set); +} + +void +ODEContactJointHandler::SetContactSoftCFM(float cfm) +{ + mSurfaceParameter.soft_cfm = std::max<float>(0.0f,cfm); +} + +float ODEContactJointHandler::GetContactSoftCFM() const +{ + return mSurfaceParameter.soft_cfm; +} + +void ODEContactJointHandler::SetContactSlipMode (bool set) +{ + SetContactMode(dContactSlip1,set); + SetContactMode(dContactSlip2,set); +} + +void ODEContactJointHandler::SetContactSlip(float slip) +{ + mSurfaceParameter.slip1 = slip; + mSurfaceParameter.slip2 = slip; +} + +float +ODEContactJointHandler::GetContactSlip1() const +{ + return mSurfaceParameter.slip1; +} + +float +ODEContactJointHandler::GetContactSlip2() const +{ + return mSurfaceParameter.slip2; +} + +void ODEContactJointHandler::SetContactMu(float mu) +{ + mSurfaceParameter.mu = mu; +} + +float ODEContactJointHandler::GetContactMu() const +{ + return mSurfaceParameter.mu; +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odecontactjointhandler.h 2010-01-13 13:21:31 UTC (rev 142) @@ -32,15 +32,38 @@ { public: ODEContactJointHandler(); - float MixValues(const float v1, const float v2, const int n) const; void Initialize(); + long RetrieveBody(long geomID); + long CreateContactJoint(long worldID, long jointGroupID, GenericContact& contact); + void AttachContactJoint(long jointID, long bodyID1, long bodyID2); + void CalcSurfaceParam(GenericContact& surface, GenericSurfaceParameter& collideeParam); + + void SetSurfaceParameter(const GenericSurfaceParameter& surface); + GenericSurfaceParameter& GetSurfaceParameter() const; + void SetContactMode(int mode, bool set); + int GetContactMode() const; + void SetContactBounceMode(bool set); + void SetBounceValue(float bounce); + float GetBounceValue() const; + void SetMinBounceVel(float vel); + float GetMinBounceVel() const; + void SetContactSoftERPMode(bool set); + void SetContactSoftERP(float erp); + float GetContactSoftERP() const; + void SetContactSoftCFMMode(bool set); + void SetContactSoftCFM(float cfm); + float GetContactSoftCFM() const; + void SetContactSlipMode (bool set); + void SetContactSlip(float slip); + float GetContactSlip1() const; + float GetContactSlip2() const; + void SetContactMu(float mu); + float GetContactMu() const; -protected: - /** the ODE surface parameters of the created contact joint */ - dSurfaceParameters mSurfaceParameter; - - void CalcSurfaceParam(dSurfaceParameters& surface, - const dSurfaceParameters& collideeParam); +protected: + f_inline float MixValues(const float v1, const float v2, const int n) const; + void CalcSurfaceParamInternal(dSurfaceParameters& surface, + const dSurfaceParameters& collideeParam); }; } //namespace oxygen Modified: branches/multiphys/spark/lib/oxygen/physicsserver/space.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/space.cpp 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/space.cpp 2010-01-13 13:21:31 UTC (rev 142) @@ -52,9 +52,9 @@ return mSpaceImp->GetSpaceID(); } -dJointGroupID Space::GetODEJointGroup() const +long Space::GetODEJointGroup() const { - return mSpaceImp->GetODEJointGroup(); + return (long) mSpaceImp->GetODEJointGroup(); } void Space::Collide() Modified: branches/multiphys/spark/lib/oxygen/physicsserver/space.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/space.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/lib/oxygen/physicsserver/space.h 2010-01-13 13:21:31 UTC (rev 142) @@ -52,7 +52,7 @@ long GetSpaceID() const; /** retuns the ID of joint group for all created contact joints */ - dJointGroupID GetODEJointGroup() const; + long GetODEJointGroup() const; /** starts ODE's collision culling system. ODE will quickly identify which pairs of geoms are potentially Modified: branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp =================================================================== --- branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2010-01-13 13:21:31 UTC (rev 142) @@ -52,10 +52,11 @@ mBody.reset(); } -dJointFeedback *ForceResistancePerceptor::AddTouchInfo(dContact &contact) +GenericJointFeedback* ForceResistancePerceptor::AddTouchInfo(oxygen::GenericContact& contact) { - mContactList.push_front(make_pair(contact.geom, dJointFeedback())); - return &mContactList.front().second; + dContact& ODEContact = (dContact&) contact; + mContactList.push_front(make_pair(ODEContact.geom, dJointFeedback())); + return (GenericJointFeedback*) &mContactList.front().second; } bool ForceResistancePerceptor::Percept( Modified: branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.h =================================================================== --- branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/plugin/collisionperceptor/forceresistanceperceptor.h 2010-01-13 13:21:31 UTC (rev 142) @@ -24,6 +24,7 @@ #define FORCERESISTANCEPERCEPTOR_H_ #include <oxygen/agentaspect/perceptor.h> +#include <oxygen/physicsserver/genericphysicsobjects.h> #include <oxygen/physicsserver/ode/odewrapper.h> #include <oxygen/sceneserver/transform.h> #include <salt/vector.h> @@ -42,7 +43,7 @@ * feedback information. * \return the address of allocated memory */ - dJointFeedback *AddTouchInfo(dContact &contact); + oxygen::GenericJointFeedback* AddTouchInfo(oxygen::GenericContact& contact); /** adds touch information to predList \return true if data is available Modified: branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.cpp =================================================================== --- branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.cpp 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.cpp 2010-01-13 13:21:31 UTC (rev 142) @@ -22,7 +22,7 @@ #include "touchperceptorhandler.h" #include <oxygen/physicsserver/collider.h> -#include <oxygen/physicsserver/genericphysicsobjects.h> +#include <oxygen/physicsserver/ode/odecontactjointhandler.h> #include <oxygen/sceneserver/transform.h> #include <oxygen/physicsserver/world.h> #include <oxygen/physicsserver/space.h> @@ -59,15 +59,15 @@ } void TouchPerceptorHandler::HandleCollision( - boost::shared_ptr<Collider> collidee, dContact& contact) + boost::shared_ptr<Collider> collidee, GenericContact& contact) { if (mCollider.get() == 0 || mWorld.get() == 0 || mSpace.get() == 0) return; - // to create a contact joint it we must have at least one body to + // to create a contact joint we must have at least one body to // attach it to. - dBodyID myBody = dGeomGetBody((dGeomID) mCollider->GetGeomID()); - dBodyID collideeBody = dGeomGetBody((dGeomID) collidee->GetGeomID()); + long myBody = mContactJointHandlerImp->RetrieveBody(mCollider->GetGeomID()); + long collideeBody = mContactJointHandlerImp->RetrieveBody(collidee->GetGeomID()); if (myBody == 0 && collideeBody == 0) return; @@ -78,17 +78,19 @@ if (handler.get() == 0) return; - CalcSurfaceParam(contact.surface, (dSurfaceParameters&) handler->GetSurfaceParameter()); + mContactJointHandlerImp->CalcSurfaceParam( + contact, handler->GetSurfaceParameter()); - dJointID joint = dJointCreateContact((dWorldID) mWorld->GetWorldID(), - mSpace->GetODEJointGroup(), &contact); + // create the contact joint and attach it to the body + long joint = mContactJointHandlerImp->CreateContactJoint( + mWorld->GetWorldID(), mSpace->GetODEJointGroup(), contact); - dJointAttach (joint, myBody, collideeBody); - + mContactJointHandlerImp->AttachContactJoint(joint, myBody, collideeBody); + if (mForceResistancePercept.get() != 0) { - dJointFeedback *feedback = + GenericJointFeedback* feedback = mForceResistancePercept->AddTouchInfo(contact); - dJointSetFeedback(joint, feedback); + dJointSetFeedback( (dJointID) joint, (dJointFeedback*) feedback); } } Modified: branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.h =================================================================== --- branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.h 2010-01-13 06:28:54 UTC (rev 141) +++ branches/multiphys/spark/plugin/collisionperceptor/touchperceptorhandler.h 2010-01-13 13:21:31 UTC (rev 142) @@ -24,6 +24,7 @@ #define TOUCHPERCEPTORHANDLER_H_ #include <oxygen/physicsserver/contactjointhandler.h> +#include <oxygen/physicsserver/genericphysicsobjects.h> class ForceResistancePerceptor; @@ -34,7 +35,7 @@ { public: virtual void HandleCollision(boost::shared_ptr<oxygen::Collider> collidee, - dContact& contact); + oxygen::GenericContact& contact); protected: virtual void OnLink(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |