[Opal-commits] opal/src testFixedJoint.cpp,NONE,1.1 testJoint.cpp,NONE,1.1 Joint.cpp,1.32,1.33 Joint
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3972/src Modified Files: Joint.cpp Joint.h JointData.h Makefile.am Makefile.in Quaternion.h testsolid.cpp Added Files: testFixedJoint.cpp testJoint.cpp Log Message: Implemented features to track Joint damage. --- NEW FILE: testFixedJoint.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library 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 files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; namespace testFixedJoint { class Fixture { public: Fixture() { sim = createSimulator(); sim->setGravity( Vec3r( 0, 0, 0 ) ); s1 = sim->createSolid(); s2 = sim->createSolid(); s1->setPosition( Point3r( 0, 0, 0 ) ); s2->setPosition( Point3r( 0, 10, 0 ) ); j = sim->createJoint(); } ~Fixture() { sim->destroy(); } Simulator * sim; Solid * s1; Solid * s2; Joint * j; }; QT_TEST( no_shapes ) { Fixture f; JointData jdata; jdata.setType( FIXED_JOINT ); jdata.solid0 = f.s1; jdata.solid1 = f.s2; f.j->init( jdata ); f.sim->simulate( 1 ); QT_CHECK_CLOSE( f.s1->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().y, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().z, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().y, 10 ); QT_CHECK_CLOSE( f.s2->getPosition().z, 0 ); } QT_TEST( with_shapes ) { Fixture f; SphereShapeData data; data.radius = 1; f.s1->addShape( data ); f.s2->addShape( data ); JointData jdata; jdata.setType( FIXED_JOINT ); jdata.solid0 = f.s1; jdata.solid1 = f.s2; f.j->init( jdata ); f.sim->simulate( 1 ); QT_CHECK_CLOSE( f.s1->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().y, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().z, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().y, 10 ); QT_CHECK_CLOSE( f.s2->getPosition().z, 0 ); } } Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.in 10 Dec 2005 05:18:35 -0000 1.10 --- Makefile.in 10 Dec 2005 22:41:06 -0000 1.11 *************** *** 73,77 **** testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) \ testMatrix44r.$(OBJEXT) testBlueprint.$(OBJEXT) \ ! testMath.$(OBJEXT) testVelocityMotor.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ --- 73,78 ---- testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) \ testMatrix44r.$(OBJEXT) testBlueprint.$(OBJEXT) \ ! testMath.$(OBJEXT) testVelocityMotor.$(OBJEXT) \ ! testFixedJoint.$(OBJEXT) testJoint.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ *************** *** 215,220 **** test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ --- 216,222 ---- test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp testFixedJoint.cpp \ ! testJoint.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ *************** *** 326,329 **** --- 328,333 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAccelerationSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testBlueprint.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFixedJoint.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testJoint.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMath.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatrix44r.Po@am__quote@ --- NEW FILE: testJoint.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library 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 files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; //! Testing generic Joint stuff namespace testJoint { QT_TEST( break_settings ) { Simulator * sim = createSimulator(); Joint * j = sim->createJoint(); JointData data; j->init( data ); QT_CHECK_EQUAL( j->getBreakingMode(), UNBREAKABLE_MODE ); sim->destroy(); } QT_TEST( breaking_threshhold ) { Simulator * sim = createSimulator(); Solid * s0 = sim->createSolid(); s0->setPosition( 0, 0, 0 ); Solid * s1 = sim->createSolid(); s1->setPosition( 0, 0, 10 ); { SphereShapeData data; data.radius = 1; s0->addShape( data ); s1->addShape( data ); } Joint * j = sim->createJoint(); { JointData data; data.setType( FIXED_JOINT ); data.breakMode = THRESHOLD_MODE; data.breakThresh = 100; data.solid0 = s0; data.solid1 = s1; j->init( data ); } sim->simulate( 1 ); QT_CHECK_EQUAL( j->isBroken(), false ); // apply a force that breaks the joint { Force f; f.type = GLOBAL_FORCE; f.duration = 1; f.singleStep = false; f.pos = Point3r( 0, 0, 0 ); f.vec = Vec3r( 0, 0, 100 ); s1->addForce( f ); } sim->simulate( 1 ); QT_CHECK_EQUAL( j->isBroken(), true ); sim->destroy(); } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** testsolid.cpp 1 Dec 2005 23:55:21 -0000 1.7 --- testsolid.cpp 10 Dec 2005 22:41:06 -0000 1.8 *************** *** 231,241 **** QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 1, 0, 0, 0 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 0, 0, 0, 1 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); } } --- 231,252 ---- QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 1, 0, 0, 0 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 0, 0, 0, 1 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! } ! ! QT_TEST( capsule_ODE_crash ) ! { ! SolidFixture f; ! CapsuleShapeData data; ! data.length = 70; ! data.radius = 10; ! f.s->addShape( data ); ! ! f.sim->simulate( 1 ); } } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.am 10 Dec 2005 05:18:35 -0000 1.10 --- Makefile.am 10 Dec 2005 22:41:06 -0000 1.11 *************** *** 15,20 **** bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode --- 15,21 ---- bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp testFixedJoint.cpp \ ! testJoint.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Joint.cpp 4 May 2005 21:04:00 -0000 1.32 --- Joint.cpp 10 Dec 2005 22:41:06 -0000 1.33 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library 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 files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Joint.h" --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library 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 files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Joint.h" *************** *** 31,393 **** namespace opal { ! Joint::Joint() ! { ! // "mData" is initialized in its own constructor. ! setJointBreakEventHandler(NULL); ! setUserData(NULL); ! mInitCalled = false; ! mNumAxes = 0; ! mAxisRotational[0] = false; ! mAxisRotational[1] = false; ! mAxisRotational[2] = false; ! } ! Joint::~Joint() ! { ! } ! void Joint::internal_destroy() ! { ! delete this; ! } ! void Joint::init(const JointData& data) ! { ! mData = data; ! } ! const JointData& Joint::getData() ! { ! // Update parameters that don't get updated automatically. ! for (int i=0; i<mNumAxes; ++i) ! { ! mData.axis[i] = getAxis(i); ! } ! mData.anchor = getAnchor(); ! return mData; ! } ! void Joint::setName(const std::string& name) ! { ! mData.name = name; ! } ! const std::string& Joint::getName()const ! { ! return mData.name; ! } ! void Joint::setContactsEnabled(bool e) ! { ! mData.contactsEnabled = e; ! } ! bool Joint::areContactsEnabled()const ! { ! return mData.contactsEnabled; ! } ! JointType Joint::getType()const ! { ! return mData.getType(); ! } ! void Joint::setBreakParams(JointBreakMode mode, real breakThresh, ! real accumThresh) ! { ! mData.breakMode = mode; ! mData.breakThresh = breakThresh; ! mData.accumThresh = accumThresh; ! } ! void Joint::repairAccumDamage() ! { ! mData.accumDamage = 0; ! //mIsBroken = false; ! } ! //bool Joint::internal_isBroken() ! //{ ! // return mIsBroken; ! //} ! void Joint::setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler) ! { ! mJointBreakEventHandler = eventHandler; ! } ! JointBreakEventHandler* Joint::getJointBreakEventHandler()const ! { ! return mJointBreakEventHandler; ! } ! void Joint::setLimitsEnabled(int axisNum, bool e) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limitsEnabled = e; ! } ! bool Joint::areLimitsEnabled(int axisNum) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limitsEnabled; ! } ! //void Joint::setLimits(int axisNum, JointLimits l) ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // assert(l.bounciness >= 0 && l.bounciness <= 1); ! // assert(l.hardness >= 0 && l.hardness <= 1); ! // mData.axis[axisNum].limits = l; ! //} ! //const Joint::JointLimits& getLimits(int axisNum)const ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // return mData.axis[axisNum].limits; ! //} ! void Joint::setLimitRange(int axisNum, real low, real high) ! { ! assert(high >= low); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.low = low; ! mData.axis[axisNum].limits.high = high; ! } ! real Joint::getLowLimit(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.low; ! } ! real Joint::getHighLimit(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.high; ! } ! void Joint::setLimitHardness(int axisNum, real h) ! { ! assert(h >= 0 && h <= 1); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.hardness = h; ! } ! real Joint::getLimitHardness(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.hardness; ! } ! void Joint::setLimitBounciness(int axisNum, real b) ! { ! assert(b >= 0 && b <= 1); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.bounciness = b; ! } ! real Joint::getLimitBounciness(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.bounciness; ! } ! void Joint::addForce(int axisNum, real magnitude, real duration, ! bool singleStep) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! if (mData.enabled) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if (!f.singleStep) ! { ! f.duration = duration; ! } ! f.type = LOCAL_FORCE; ! Vec3r direction = mData.axis[axisNum].direction; ! f.vec = magnitude * direction; ! if (mData.solid0) ! { ! mData.solid0->addForce(f); ! } ! f.vec *= (real)-1.0; ! if (mData.solid1) ! { ! mData.solid1->addForce(f); ! } ! } ! } ! void Joint::addTorque(int axisNum, real magnitude, real duration, ! bool singleStep) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! if (mData.enabled) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if (!f.singleStep) ! { ! f.duration = duration; ! } ! f.type = LOCAL_TORQUE; ! Vec3r axis = mData.axis[axisNum].direction; ! f.vec = magnitude * axis; ! if (mData.solid0) ! { ! mData.solid0->addForce(f); ! } ! f.vec *= (real)-1.0; ! if (mData.solid1) ! { ! mData.solid1->addForce(f); ! } ! } ! } ! void Joint::wakeSolids() ! { ! mData.solid0->setSleeping(false); ! mData.solid1->setSleeping(false); ! } ! void Joint::setSolids(Solid* s0, Solid* s1) ! { ! mData.solid0 = s0; ! mData.solid1 = s1; ! } ! Solid* Joint::getSolid0()const ! { ! return mData.solid0; ! } ! Solid* Joint::getSolid1()const ! { ! return mData.solid1; ! } ! void Joint::setAxis(int axisNum, const JointAxis& axis) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum] = axis; ! } ! int Joint::getNumAxes()const ! { ! return mNumAxes; ! } ! void Joint::setAnchor(const Point3r& anchor) ! { ! mData.anchor = anchor; ! } ! bool Joint::isEnabled()const ! { ! return mData.enabled; ! } ! void Joint::setEnabled(bool e) ! { ! if (!mInitCalled) ! { ! return; ! } ! mData.enabled = e; ! } ! bool Joint::isRotational(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mAxisRotational[axisNum]; ! } ! void Joint::setUserData(void* data) ! { ! mUserData = data; ! } ! void* Joint::getUserData() ! { ! return mUserData; ! } ! bool Joint::internal_dependsOnSolid(Solid* s) ! { ! if (s == mData.solid0 || s == mData.solid1) ! { ! return true; ! } ! else ! { ! return false; ! } ! } ! void Joint::updateDamage(real currentStress) ! { ! bool isBroken = false; ! switch(mData.breakMode) ! { ! case UNBREAKABLE_MODE: ! //nothing to do ! break; ! case THRESHOLD_MODE: ! { ! if (currentStress >= mData.breakThresh) ! { ! isBroken = true; ! } ! break; ! } ! case ACCUMULATED_MODE: ! { ! if (currentStress >= mData.accumThresh) ! { ! mData.accumDamage += currentStress; ! } ! if (mData.accumDamage >= mData.breakThresh) ! { ! isBroken = true; ! } ! break; ! } ! default: ! assert(false); ! } ! if (isBroken) ! { ! setEnabled(false); ! if (mJointBreakEventHandler) ! { ! mJointBreakEventHandler->handleJointBreakEvent(this); ! } ! } ! } } --- 31,415 ---- namespace opal { ! Joint::Joint() ! { ! // "mData" is initialized in its own constructor. ! setJointBreakEventHandler( NULL ); ! setUserData( NULL ); ! mInitCalled = false; ! mNumAxes = 0; ! mAxisRotational[ 0 ] = false; ! mAxisRotational[ 1 ] = false; ! mAxisRotational[ 2 ] = false; ! } ! Joint::~Joint() ! {} ! void Joint::internal_destroy() ! { ! delete this; ! } ! void Joint::init( const JointData& data ) ! { ! mData = data; ! } ! const JointData& Joint::getData() ! { ! // Update parameters that don't get updated automatically. ! for ( int i = 0; i < mNumAxes; ++i ) ! { ! mData.axis[ i ] = getAxis( i ); ! } ! mData.anchor = getAnchor(); ! return mData; ! } ! void Joint::setName( const std::string& name ) ! { ! mData.name = name; ! } ! const std::string& Joint::getName() const ! { ! return mData.name; ! } ! void Joint::setContactsEnabled( bool e ) ! { ! mData.contactsEnabled = e; ! } ! bool Joint::areContactsEnabled() const ! { ! return mData.contactsEnabled; ! } ! JointType Joint::getType() const ! { ! return mData.getType(); ! } ! void Joint::setBreakParams( JointBreakMode mode, real breakThresh, ! real accumThresh ) ! { ! mData.breakMode = mode; ! mData.breakThresh = breakThresh; ! mData.accumThresh = accumThresh; ! } ! bool Joint::isBroken() const ! { ! return mData.isBroken; ! } ! JointBreakMode Joint::getBreakingMode() const ! { ! return mData.breakMode; ! } ! real Joint::getBreakThresh() const ! { ! return mData.breakThresh; ! } ! real Joint::getAccumulatedDamage() const ! { ! return mData.accumDamage; ! } ! real Joint::getAccumulatedThresh() const ! { ! return mData.accumThresh; ! } ! void Joint::repairAccumDamage() ! { ! mData.accumDamage = 0; ! //mIsBroken = false; ! } ! //bool Joint::internal_isBroken() ! //{ ! // return mIsBroken; ! //} ! void Joint::setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler ) ! { ! mJointBreakEventHandler = eventHandler; ! } ! JointBreakEventHandler* Joint::getJointBreakEventHandler() const ! { ! return mJointBreakEventHandler; ! } ! void Joint::setLimitsEnabled( int axisNum, bool e ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limitsEnabled = e; ! } ! bool Joint::areLimitsEnabled( int axisNum ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limitsEnabled; ! } ! //void Joint::setLimits(int axisNum, JointLimits l) ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // assert(l.bounciness >= 0 && l.bounciness <= 1); ! // assert(l.hardness >= 0 && l.hardness <= 1); ! // mData.axis[axisNum].limits = l; ! //} ! //const Joint::JointLimits& getLimits(int axisNum)const ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // return mData.axis[axisNum].limits; ! //} ! void Joint::setLimitRange( int axisNum, real low, real high ) ! { ! assert( high >= low ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.low = low; ! mData.axis[ axisNum ].limits.high = high; ! } ! real Joint::getLowLimit( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.low; ! } ! real Joint::getHighLimit( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.high; ! } ! void Joint::setLimitHardness( int axisNum, real h ) ! { ! assert( h >= 0 && h <= 1 ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.hardness = h; ! } ! real Joint::getLimitHardness( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.hardness; ! } ! void Joint::setLimitBounciness( int axisNum, real b ) ! { ! assert( b >= 0 && b <= 1 ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.bounciness = b; ! } ! real Joint::getLimitBounciness( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.bounciness; ! } ! void Joint::addForce( int axisNum, real magnitude, real duration, ! bool singleStep ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! if ( mData.enabled ) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if ( !f.singleStep ) ! { ! f.duration = duration; ! } ! f.type = LOCAL_FORCE; ! Vec3r direction = mData.axis[ axisNum ].direction; ! f.vec = magnitude * direction; ! if ( mData.solid0 ) ! { ! mData.solid0->addForce( f ); ! } ! f.vec *= ( real ) - 1.0; ! if ( mData.solid1 ) ! { ! mData.solid1->addForce( f ); ! } ! } ! } ! void Joint::addTorque( int axisNum, real magnitude, real duration, ! bool singleStep ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! if ( mData.enabled ) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if ( !f.singleStep ) ! { ! f.duration = duration; ! } ! f.type = LOCAL_TORQUE; ! Vec3r axis = mData.axis[ axisNum ].direction; ! f.vec = magnitude * axis; ! if ( mData.solid0 ) ! { ! mData.solid0->addForce( f ); ! } ! f.vec *= ( real ) - 1.0; ! if ( mData.solid1 ) ! { ! mData.solid1->addForce( f ); ! } ! } ! } ! void Joint::wakeSolids() ! { ! mData.solid0->setSleeping( false ); ! mData.solid1->setSleeping( false ); ! } ! void Joint::setSolids( Solid* s0, Solid* s1 ) ! { ! mData.solid0 = s0; ! mData.solid1 = s1; ! } ! Solid* Joint::getSolid0() const ! { ! return mData.solid0; ! } ! Solid* Joint::getSolid1() const ! { ! return mData.solid1; ! } ! void Joint::setAxis( int axisNum, const JointAxis& axis ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ] = axis; ! } ! int Joint::getNumAxes() const ! { ! return mNumAxes; ! } ! void Joint::setAnchor( const Point3r& anchor ) ! { ! mData.anchor = anchor; ! } ! bool Joint::isEnabled() const ! { ! return mData.enabled; ! } ! void Joint::setEnabled( bool e ) ! { ! if ( !mInitCalled ) ! { ! return ; ! } ! mData.enabled = e; ! } ! bool Joint::isRotational( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mAxisRotational[ axisNum ]; ! } ! void Joint::setUserData( void* data ) ! { ! mUserData = data; ! } ! void* Joint::getUserData() ! { ! return mUserData; ! } ! ! bool Joint::internal_dependsOnSolid( Solid* s ) ! { ! if ( s == mData.solid0 || s == mData.solid1 ) ! { ! return true; ! } ! else ! { ! return false; ! } ! } ! ! void Joint::updateDamage( real currentStress ) ! { ! switch ( mData.breakMode ) ! { ! case UNBREAKABLE_MODE: ! //nothing to do ! break; ! case THRESHOLD_MODE: ! { ! if ( currentStress >= mData.breakThresh ) ! { ! mData.isBroken = true; ! } ! break; ! } ! case ACCUMULATED_MODE: ! { ! if ( currentStress >= mData.accumThresh ) ! { ! mData.accumDamage += currentStress; ! } ! ! if ( mData.accumDamage >= mData.breakThresh ) ! { ! mData.isBroken = true; ! } ! break; ! } ! default: ! assert( false ); ! } ! ! if ( mData.isBroken ) ! { ! setEnabled( false ); ! if ( mJointBreakEventHandler ) ! { ! mJointBreakEventHandler->handleJointBreakEvent( this ); ! } ! } ! } } Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Quaternion.h 4 Dec 2005 03:27:11 -0000 1.13 --- Quaternion.h 10 Dec 2005 22:41:06 -0000 1.14 *************** *** 60,66 **** OPAL_DECL real OPAL_CALL length() const; OPAL_DECL void OPAL_CALL normalize(); ! OPAL_DECL void OPAL_CALL getAngleAxis( real& angle, Vec3r& axis ) const; OPAL_DECL real OPAL_CALL getRoll() const; --- 60,74 ---- OPAL_DECL real OPAL_CALL length() const; + //! Length will be one. OPAL_DECL void OPAL_CALL normalize(); ! //! Returns the equivalent rotation. ! /*! ! * @param angle in degrees ! * @param axis axis of rotation ! * ! * @note Quaternion needs to be normalized first ! */ ! OPAL_DECL void OPAL_CALL getAngleAxis( real & angle, Vec3r & axis ) const; OPAL_DECL real OPAL_CALL getRoll() const; Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** Joint.h 4 May 2005 21:04:00 -0000 1.70 --- Joint.h 10 Dec 2005 22:41:06 -0000 1.71 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library 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 files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_JOINT_H --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library 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 files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #ifndef OPAL_JOINT_H *************** *** 35,275 **** namespace opal { ! /// A constraint between two Solids or between a Solid and the static ! /// environment. There is a variety of Joint types, each constraining ! /// Solid motion in different ways. There are 6 degrees of freedom ! /// for a Solid that can be constrained: 3 rotational and 3 linear. ! /// Each Joint type constrains a different subset of these 6. When ! /// specifying the two Solids ! /// affected by the Joint, if at least one Solid ! /// is non-NULL, the Joint will be enabled. If both Solids are ! /// NULL, the Joint will be disabled. If only one Solid is NULL, ! /// the Joint will attach the other Solid to the static environment. ! /// If both Solids are the same, the Joint's Solids will both be set ! /// to NULL and the Joint will be disabled. If either Solid is static, ! /// both will be set to NULL, and the Joint will be disabled. ! /// Note that some Joint types ! /// do not use all of the anchor and axis parameters. An unused anchor ! /// or axis will be ignored (see the JointType description for more ! /// details). Joints remain ineffective until they are initialized. ! class Joint ! { ! public: ! Joint(); ! /// Initializes the Joint with the given data structure. Calling ! /// this more than once will automatically detach the Joint from ! /// its old Solids first. ! virtual void OPAL_CALL init(const JointData& data); ! /// Returns all data describing the Joint. ! virtual const JointData& OPAL_CALL getData(); ! /// Sets the Joint's name. ! virtual void OPAL_CALL setName(const std::string& name); ! /// Returns the Joint's name. ! virtual const std::string& OPAL_CALL getName()const; ! /// Sets whether the Joint's two Solids are constrained by ! /// physical contacts. ! virtual void OPAL_CALL setContactsEnabled(bool e); ! /// Returns whether the Joint's two Solids are constrained by ! /// physical contacts. ! virtual bool OPAL_CALL areContactsEnabled()const; ! /// Returns the Joint type. ! virtual JointType OPAL_CALL getType()const; ! /// Sets the parameters that determine how this Joint will break, if ! /// at all. ! virtual void OPAL_CALL setBreakParams(JointBreakMode mode, ! real breakThresh, real accumThresh=0); ! /// Repairs accumulated damage to breakable Joints in accumulated ! /// damage mode. This does not reenable the Joint. ! virtual void OPAL_CALL repairAccumDamage(); ! /// Sets the Joint's break event handler. ! virtual void OPAL_CALL setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler); ! /// Returns the Joint's break event handler. If this returns ! /// NULL, the Joint is not using one. ! virtual JointBreakEventHandler* OPAL_CALL ! getJointBreakEventHandler()const; ! /// Enables or disables the given Joint axis' limits. ! virtual void OPAL_CALL setLimitsEnabled(int axisNum, bool e); ! /// Returns true if the given Joint axis' limits are enabled. ! virtual bool OPAL_CALL areLimitsEnabled(int axisNum); ! /// Sets the Joint's limit angles (in degrees for rotational axes, ! /// distance for translational axes). ! /// No limits are applied ! /// if this is not called. The Wheel Joint does not ! /// use limits for axis 1, so setting this will do nothing. ! virtual void OPAL_CALL setLimitRange(int axisNum, real low, ! real high); ! /// Returns the low limit for a given axis (angle in degrees for ! /// rotational axes, distance for translational axes). ! virtual real OPAL_CALL getLowLimit(int axisNum)const; ! /// Returns the high limit for a given axis (angle in degrees for ! /// rotational axes, distance for translational axes). ! virtual real OPAL_CALL getHighLimit(int axisNum)const; ! /// Sets the hardness for the given axis' limits. Hardness ! /// represents how "squishy" the limit is. Hardness must be ! /// between 0 and 1, inclusive. Setting the hardness for axis 1 ! /// of the Wheel Joint will adjust its suspension. ! virtual void OPAL_CALL setLimitHardness(int axisNum, real h); ! /// Returns the hardness for the given axis' limits. ! virtual real OPAL_CALL getLimitHardness(int axisNum)const; ! /// Sets the bounciness for the given axis' limits. Bounciness ! /// (i.e. restitution) represents how much the Joint will bounce ! /// when it hits a limit. Bounciness must be between 0 and 1, ! /// inclusive. ! virtual void OPAL_CALL setLimitBounciness(int axisNum, real b); ! /// Returns the bounciness for the given axis' limits. ! virtual real OPAL_CALL getLimitBounciness(int axisNum)const; ! /// For rotational axes, returns the current angle in degrees ! /// measured from the initial Joint configuration. For translational ! /// axes, simply returns 0. ! virtual real OPAL_CALL getAngle(int axisNum)const = 0; ! /// For translational axes, returns the distance from the initial ! /// Joint configuration. For rotational axes, simply returns 0. ! virtual real OPAL_CALL getDistance(int axisNum)const = 0; ! /// Returns the current rate (degrees per second for rotational ! /// axes, distance units per second for translational axes) for a ! /// given axis. ! virtual real OPAL_CALL getVelocity(int axisNum)const = 0; ! /// Applies a force to this Joint's Solid(s). To be used for ! /// translational axes. This does nothing if the Joint is disabled. ! virtual void OPAL_CALL addForce(int axisNum, real magnitude, ! real duration, bool singleStep=false); ! /// Applies a torque to this Joint's Solid(s). To be used for ! /// rotational Joints. This does nothing if the Joint is disabled. ! virtual void OPAL_CALL addTorque(int axisNum, real magnitude, ! real duration, bool singleStep=false); ! /// Wakes up this Joint's two Solids. ! virtual void OPAL_CALL wakeSolids(); ! /// Returns a pointer to Solid0. ! virtual Solid* OPAL_CALL getSolid0()const; ! /// Returns a pointer to Solid1. ! virtual Solid* OPAL_CALL getSolid1()const; ! /// Returns the current specified axis in global coordinates. ! /// Passing in an invalid axis number will return invalid data. ! virtual JointAxis OPAL_CALL getAxis(int axisNum)const = 0; ! /// Returns the current anchor point in global coordinates. ! /// Passing in an invalid axis number will return invalid data. ! virtual Point3r OPAL_CALL getAnchor()const = 0; ! /// Returns the number of axes used by this Joint. ! virtual int OPAL_CALL getNumAxes()const; ! /// Returns true if the Joint is enabled. ! virtual bool OPAL_CALL isEnabled()const; ! /// Set whether the Joint can affect its Solids. If both Solids are ! /// NULL, this will remain disabled. If the Joint has not yet ! /// been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled(bool e); ! /// Returns true if the given Joint axis is rotational, false if it ! /// is linear. ! virtual bool OPAL_CALL isRotational(int axisNum)const; ! /// Set the user data pointer to some external data. The user data ! /// is totally user-managed ! /// (i.e. it is not destroyed when the Joint is destroyed). ! virtual void OPAL_CALL setUserData(void* data); ! /// Returns the user data pointer (NULL if it has not been set). ! virtual void* OPAL_CALL getUserData(); ! /// Various things could be updated here, including damage values. ! /// If the Joint breaks during this update, it will automatically ! /// be disabled, and the event handler will be notified. ! virtual void OPAL_CALL internal_update() = 0; ! /// Set the desired linear or angular velocity for this Joint. ! /// This is to be used internally by Motors. ! virtual void OPAL_CALL internal_setDesiredVel(int axisNum, ! real value) = 0; ! /// Set the max force this Joint can use to attain its desired ! /// velocity. This is to be used internally by Motors. ! virtual void OPAL_CALL internal_setMaxTorque(int axisNum, ! real value) = 0; ! //virtual bool OPAL_CALL internal_isBroken(); ! /// Returns true if this Joint depends on the given Solid. ! virtual bool OPAL_CALL internal_dependsOnSolid(Solid* s); ! /// Internal function used to destroy this object. ! virtual void OPAL_CALL internal_destroy(); ! protected: ! virtual ~Joint(); ! /// Sets the Solids constrained by this Joint. ! void setSolids(Solid* s0, Solid* s1); ! /// Sets the anchor point for this Joint. Both Solids must be ! /// valid (non-NULL) before this is called for it to affect anything. ! /// This Joint's Solids must be positioned and attached ! /// before calling this function. ! virtual void setAnchor(const Point3r& anchor); ! /// Specifies the given axis for this Joint. Invalid axes numbers ! /// will be silently ignored. The axis direction vector will be ! /// normalized. This Joint's Solids must be positioned and ! /// attached before calling this function. ! virtual void setAxis(int axisNum, const JointAxis& axis); ! /// Updates this Joint's current damage status based on the current ! /// amount of stress. ! void updateDamage(real currentStress); ! /// Stores data describing the Joint. ! JointData mData; ! /// A pointer to the Joint's break event handler. ! JointBreakEventHandler* mJointBreakEventHandler; ! /// Pointer to user data. This is totally user-managed (i.e. OPAL ! /// will never delete it). ! void* mUserData; ! /// This is set to true when the Joint is initialized. ! bool mInitCalled; ! /// The number of axes used by the Joint. ! int mNumAxes; ! // This data stores which axes are rotational, as opposed to ! // translational, degrees of freedom. ! bool mAxisRotational[3]; ! private: ! }; } --- 35,293 ---- namespace opal { ! /// A constraint between two Solids or between a Solid and the static ! /// environment. There is a variety of Joint types, each constraining ! /// Solid motion in different ways. There are 6 degrees of freedom ! /// for a Solid that can be constrained: 3 rotational and 3 linear. ! /// Each Joint type constrains a different subset of these 6. When ! /// specifying the two Solids ! /// affected by the Joint, if at least one Solid ! /// is non-NULL, the Joint will be enabled. If both Solids are ! /// NULL, the Joint will be disabled. If only one Solid is NULL, ! /// the Joint will attach the other Solid to the static environment. ! /// If both Solids are the same, the Joint's Solids will both be set ! /// to NULL and the Joint will be disabled. If either Solid is static, ! /// both will be set to NULL, and the Joint will be disabled. ! /// Note that some Joint types ! /// do not use all of the anchor and axis parameters. An unused anchor ! /// or axis will be ignored (see the JointType description for more ! /// details). Joints remain ineffective until they are initialized. ! class Joint ! { ! public: ! Joint(); ! /// Initializes the Joint with the given data structure. Calling ! /// this more than once will automatically detach the Joint from ! /// its old Solids first. ! virtual void OPAL_CALL init( const JointData& data ); ! /// Returns all data describing the Joint. ! virtual const JointData& OPAL_CALL getData(); ! /// Sets the Joint's name. ! virtual void OPAL_CALL setName( const std::string& name ); ! /// Returns the Joint's name. ! virtual const std::string& OPAL_CALL getName() const; ! /// Sets whether the Joint's two Solids are constrained by ! /// physical contacts. ! virtual void OPAL_CALL setContactsEnabled( bool e ); ! /// Returns whether the Joint's two Solids are constrained by ! /// physical contacts. ! virtual bool OPAL_CALL areContactsEnabled() const; ! /// Returns the Joint type. ! virtual JointType OPAL_CALL getType() const; ! /// Sets the parameters that determine how this Joint will break, if ! /// at all. ! virtual void OPAL_CALL setBreakParams( JointBreakMode mode, ! real breakThresh, real accumThresh = 0 ); ! //! What is the mode of breaking? ! virtual JointBreakMode OPAL_CALL getBreakingMode() const; ! //! How much damage can a Joint take? ! virtual real OPAL_CALL getBreakThresh() const; ! //! How much damage has a Joint taken so far? ! virtual real OPAL_CALL getAccumulatedDamage() const; ! //! What is minimum amount of damage that will be recorded? ! /*! ! * @note if the damaga is lower than this value, that damage will be ignored ! */ ! virtual real OPAL_CALL getAccumulatedThresh() const; ! //! Returns true if the Joint has been broken ! virtual bool OPAL_CALL isBroken() const; ! /// Repairs accumulated damage to breakable Joints in accumulated ! /// damage mode. This does not reenable the Joint. ! virtual void OPAL_CALL repairAccumDamage(); ! /// Sets the Joint's break event handler. ! virtual void OPAL_CALL setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler ); ! /// Returns the Joint's break event handler. If this returns ! /// NULL, the Joint is not using one. ! virtual JointBreakEventHandler* OPAL_CALL ! getJointBreakEventHandler() const; ! /// Enables or disables the given Joint axis' limits. ! virtual void OPAL_CALL setLimitsEnabled( int axisNum, bool e ); ! /// Returns true if the given Joint axis' limits are enabled. ! virtual bool OPAL_CALL areLimitsEnabled( int axisNum ); ! /// Sets the Joint's limit angles (in degrees for rotational axes, ! /// distance for translational axes). ! /// No limits are applied ! /// if this is not called. The Wheel Joint does not ! /// use limits for axis 1, so setting this will do nothing. ! virtual void OPAL_CALL setLimitRange( int axisNum, real low, ! real high ); ! /// Returns the low limit for a given axis (angle in degrees for ! /// rotational axes, distance for translational axes). ! virtual real OPAL_CALL getLowLimit( int axisNum ) const; ! /// Returns the high limit for a given axis (angle in degrees for ! /// rotational axes, distance for translational axes). ! virtual real OPAL_CALL getHighLimit( int axisNum ) const; ! /// Sets the hardness for the given axis' limits. Hardness ! /// represents how "squishy" the limit is. Hardness must be ! /// between 0 and 1, inclusive. Setting the hardness for axis 1 ! /// of the Wheel Joint will adjust its suspension. ! virtual void OPAL_CALL setLimitHardness( int axisNum, real h ); ! /// Returns the hardness for the given axis' limits. ! virtual real OPAL_CALL getLimitHardness( int axisNum ) const; ! /// Sets the bounciness for the given axis' limits. Bounciness ! /// (i.e. restitution) represents how much the Joint will bounce ! /// when it hits a limit. Bounciness must be between 0 and 1, ! /// inclusive. ! virtual void OPAL_CALL setLimitBounciness( int axisNum, real b ); ! /// Returns the bounciness for the given axis' limits. ! virtual real OPAL_CALL getLimitBounciness( int axisNum ) const; ! /// For rotational axes, returns the current angle in degrees ! /// measured from the initial Joint configuration. For translational ! /// axes, simply returns 0. ! virtual real OPAL_CALL getAngle( int axisNum ) const = 0; ! /// For translational axes, returns the distance from the initial ! /// Joint configuration. For rotational axes, simply returns 0. ! virtual real OPAL_CALL getDistance( int axisNum ) const = 0; ! /// Returns the current rate (degrees per second for rotational ! /// axes, distance units per second for translational axes) for a ! /// given axis. ! virtual real OPAL_CALL getVelocity( int axisNum ) const = 0; ! /// Applies a force to this Joint's Solid(s). To be used for ! /// translational axes. This does nothing if the Joint is disabled. ! virtual void OPAL_CALL addForce( int axisNum, real magnitude, ! real duration, bool singleStep = false ); ! /// Applies a torque to this Joint's Solid(s). To be used for ! /// rotational Joints. This does nothing if the Joint is disabled. ! virtual void OPAL_CALL addTorque( int axisNum, real magnitude, ! real duration, bool singleStep = false ); ! /// Wakes up this Joint's two Solids. ! virtual void OPAL_CALL wakeSolids(); ! /// Returns a pointer to Solid0. ! virtual Solid* OPAL_CALL getSolid0() const; ! /// Returns a pointer to Solid1. ! virtual Solid* OPAL_CALL getSolid1() const; ! /// Returns the current specified axis in global coordinates. ! /// Passing in an invalid axis number will return invalid data. ! virtual JointAxis OPAL_CALL getAxis( int axisNum ) const = 0; ! /// Returns the current anchor point in global coordinates. ! /// Passing in an invalid axis number will return invalid data. ! virtual Point3r OPAL_CALL getAnchor() const = 0; ! /// Returns the number of axes used by this Joint. ! virtual int OPAL_CALL getNumAxes() const; ! /// Returns true if the Joint is enabled. ! virtual bool OPAL_CALL isEnabled() const; ! /// Set whether the Joint can affect its Solids. If both Solids are ! /// NULL, this will remain disabled. If the Joint has not yet ! /// been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled( bool e ); ! /// Returns true if the given Joint axis is rotational, false if it ! /// is linear. ! virtual bool OPAL_CALL isRotational( int axisNum ) const; ! /// Set the user data pointer to some external data. The user data ! /// is totally user-managed ! /// (i.e. it is not destroyed when the Joint is destroyed). ! virtual void OPAL_CALL setUserData( void* data ); ! /// Returns the user data pointer (NULL if it has not been set). ! virtual void* OPAL_CALL getUserData(); ! /// Various things could be updated here, including damage values. ! /// If the Joint breaks during this update, it will automatically ! /// be disabled, and the event handler will be notified. ! virtual void OPAL_CALL internal_update() = 0; ! /// Set the desired linear or angular velocity for this Joint. ! /// This is to be used internally by Motors. ! virtual void OPAL_CALL internal_setDesiredVel( int axisNum, ! real value ) = 0; ! /// Set the max force this Joint can use to attain its desired ! /// velocity. This is to be used internally by Motors. ! virtual void OPAL_CALL internal_setMaxTorque( int axisNum, ! real value ) = 0; ! //virtual bool OPAL_CALL internal_isBroken(); ! /// Returns true if this Joint depends on the given Solid. ! virtual bool OPAL_CALL internal_dependsOnSolid( Solid* s ); ! /// Internal function used to destroy this object. ! virtual void OPAL_CALL internal_destroy(); ! protected: ! virtual ~Joint(); ! /// Sets the Solids constrained by this Joint. ! void setSolids( Solid* s0, Solid* s1 ); ! /// Sets the anchor point for this Joint. Both Solids must be ! /// valid (non-NULL) before this is called for it to affect anything. ! /// This Joint's Solids must be positioned and attached ! /// before calling this function. ! virtual void setAnchor( const Point3r& anchor ); ! /// Specifies the given axis for this Joint. Invalid axes numbers ! /// will ... [truncated message content] |