00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OPAL_JOINT_H
00029 #define OPAL_JOINT_H
00030
00031 #include "Defines.h"
00032 #include "JointBreakEventHandler.h"
00033 #include "JointData.h"
00034
00035 namespace opal
00036 {
00054 class Joint
00055 {
00056 public:
00057 Joint();
00058
00062 virtual void OPAL_CALL init( const JointData& data );
00063
00065 virtual const JointData& OPAL_CALL getData();
00066
00068 virtual void OPAL_CALL setName( const std::string& name );
00069
00071 virtual const std::string& OPAL_CALL getName() const;
00072
00075 virtual void OPAL_CALL setContactsEnabled( bool e );
00076
00079 virtual bool OPAL_CALL areContactsEnabled() const;
00080
00082 virtual JointType OPAL_CALL getType() const;
00083
00086 virtual void OPAL_CALL setBreakParams( JointBreakMode mode,
00087 real breakThresh, real accumThresh = 0 );
00088
00090 virtual JointBreakMode OPAL_CALL getBreakingMode() const;
00091
00093 virtual real OPAL_CALL getBreakThresh() const;
00094
00096 virtual real OPAL_CALL getAccumulatedDamage() const;
00097
00099
00102 virtual real OPAL_CALL getAccumulatedThresh() const;
00103
00105 virtual bool OPAL_CALL isBroken() const;
00106
00109 virtual void OPAL_CALL repairAccumDamage();
00110
00112 virtual void OPAL_CALL setJointBreakEventHandler(
00113 JointBreakEventHandler* eventHandler );
00114
00117 virtual JointBreakEventHandler* OPAL_CALL
00118 getJointBreakEventHandler() const;
00119
00121 virtual void OPAL_CALL setLimitsEnabled( int axisNum, bool e );
00122
00124 virtual bool OPAL_CALL areLimitsEnabled( int axisNum );
00125
00131 virtual void OPAL_CALL setLimitRange( int axisNum, real low,
00132 real high );
00133
00136 virtual real OPAL_CALL getLowLimit( int axisNum ) const;
00137
00140 virtual real OPAL_CALL getHighLimit( int axisNum ) const;
00141
00146 virtual void OPAL_CALL setLimitHardness( int axisNum, real h );
00147
00149 virtual real OPAL_CALL getLimitHardness( int axisNum ) const;
00150
00155 virtual void OPAL_CALL setLimitBounciness( int axisNum, real b );
00156
00158 virtual real OPAL_CALL getLimitBounciness( int axisNum ) const;
00159
00163 virtual real OPAL_CALL getAngle( int axisNum ) const = 0;
00164
00167 virtual real OPAL_CALL getDistance( int axisNum ) const = 0;
00168
00172 virtual real OPAL_CALL getVelocity( int axisNum ) const = 0;
00173
00176 virtual void OPAL_CALL addForce( int axisNum, real magnitude,
00177 real duration, bool singleStep = false );
00178
00181 virtual void OPAL_CALL addTorque( int axisNum, real magnitude,
00182 real duration, bool singleStep = false );
00183
00185 virtual void OPAL_CALL wakeSolids();
00186
00188 virtual Solid* OPAL_CALL getSolid0() const;
00189
00191 virtual Solid* OPAL_CALL getSolid1() const;
00192
00195 virtual JointAxis OPAL_CALL getAxis( int axisNum ) const = 0;
00196
00199 virtual Point3r OPAL_CALL getAnchor() const = 0;
00200
00202 virtual int OPAL_CALL getNumAxes() const;
00203
00205 virtual bool OPAL_CALL isEnabled() const;
00206
00210 virtual void OPAL_CALL setEnabled( bool e );
00211
00214 virtual bool OPAL_CALL isRotational( int axisNum ) const;
00215
00219 virtual void OPAL_CALL setUserData( void* data );
00220
00222 virtual void* OPAL_CALL getUserData();
00223
00227 virtual void OPAL_CALL internal_update() = 0;
00228
00231 virtual void OPAL_CALL internal_setDesiredVel( int axisNum,
00232 real value ) = 0;
00233
00236 virtual void OPAL_CALL internal_setMaxTorque( int axisNum,
00237 real value ) = 0;
00238
00239
00240
00242 virtual bool OPAL_CALL internal_dependsOnSolid( Solid* s );
00243
00245 virtual void OPAL_CALL internal_destroy();
00246
00247 protected:
00248 virtual ~Joint();
00249
00251 void setSolids( Solid* s0, Solid* s1 );
00252
00257 virtual void setAnchor( const Point3r& anchor );
00258
00263 virtual void setAxis( int axisNum, const JointAxis& axis );
00264
00267 void updateDamage( real currentStress );
00268
00270 JointData mData;
00271
00273 JointBreakEventHandler* mJointBreakEventHandler;
00274
00277 void* mUserData;
00278
00280 bool mInitCalled;
00281
00283 int mNumAxes;
00284
00285
00286
00287 bool mAxisRotational[ 3 ];
00288
00289 private:
00290
00291 };
00292 }
00293
00294 #endif