Joint.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 *                                                                       *
00003 * Open Physics Abstraction Layer                                        *
00004 * Copyright (C) 2004-2005                                               *
00005 * Alan Fischer  alan.fischer@gmail.com                                  *
00006 * Andres Reinot  andres@reinot.com                                      *
00007 * Tyler Streeter  tylerstreeter@gmail.com                               *
00008 * All rights reserved.                                                  *
00009 * Web: opal.sourceforge.net                                             *
00010 *                                                                       *
00011 * This library is free software; you can redistribute it and/or         *
00012 * modify it under the terms of EITHER:                                  *
00013 *   (1) The GNU Lesser General Public License as published by the Free  *
00014 *       Software Foundation; either version 2.1 of the License, or (at  *
00015 *       your option) any later version. The text of the GNU Lesser      *
00016 *       General Public License is included with this library in the     *
00017 *       file license-LGPL.txt.                                          *
00018 *   (2) The BSD-style license that is included with this library in     *
00019 *       the file license-BSD.txt.                                       *
00020 *                                                                       *
00021 * This library is distributed in the hope that it will be useful,       *
00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024 * license-LGPL.txt and license-BSD.txt for more details.                *
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             //virtual bool OPAL_CALL internal_isBroken();
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             // This data stores which axes are rotational, as opposed to
00286             // translational, degrees of freedom.
00287             bool mAxisRotational[ 3 ];
00288 
00289         private:
00290 
00291     };
00292 }
00293 
00294 #endif

Generated on Tue May 16 17:49:51 2006 for OPAL by  doxygen 1.4.6-NO