00001 /************************************************************************/ 00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */ 00003 /* 1993-2002, thereinafter the Software */ 00004 /* */ 00005 /* The Software has been developped within the Siames Project. */ 00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */ 00007 /* property rights */ 00008 /* */ 00009 /* The Software has been registered with the Agence pour la Protection */ 00010 /* des Programmes (APP) under registration number */ 00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200 */ 00012 /* */ 00013 /* This file may be distributed under the terms of the Q Public License */ 00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in */ 00015 /* the file LICENSE.QPL included in the packaging of this file. */ 00016 /* */ 00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or */ 00018 /* Universite Rennes 1 for the software may use this file in */ 00019 /* acordance with that specific license */ 00020 /************************************************************************/ 00021 00022 #if !defined OMK_III_JOINT_H 00023 #define OMK_III_JOINT_H 00024 00025 #include "OMKName.h" 00026 #include "OMKTransform.h" 00027 #include "OBTPrototypeFactory.h" 00028 #include "OMKInteraction.h" 00029 00030 namespace OMK 00031 { 00032 template< typename T > class IAttributeBaseT ; 00033 // Predefined classes 00034 namespace Type { class Transform ; } 00035 namespace Iii 00036 { 00037 class JointExtension ; 00048 #define DECLARE_JOINT_FACTORY( JointClass ) \ 00049 public: \ 00050 \ 00051 friend class OMK::Iii::JointCreatorT< JointClass > ; \ 00052 \ 00053 static OMK::Name OMK_CLASS_ID ; \ 00054 \ 00055 static const bool REGISTERED_IN_JOINT_FACTORY ; \ 00056 protected: \ 00057 \ 00059 JointClass( OMK::Iii::JointExtension* owner, const OMK::ConfigurationParameterDescriptor * node ) ; \ 00060 public: \ 00061 virtual ~JointClass() 00062 00069 #define REGISTER_JOINT_FACTORY( JointClass, Id )\ 00070 /* Factory */ \ 00071 OMK::Name JointClass::OMK_CLASS_ID( Id ) ; \ 00072 const bool JointClass::REGISTERED_IN_JOINT_FACTORY( OMK::Iii::JointFactory::getInstance().registerCreator< OMK::Iii::JointCreatorT< JointClass > >( Id ) ) 00073 00074 00075 //----------------------------------------------------------------------------- 00076 // forward declaration of Joint 00077 class Joint ; 00078 00079 //----------------------------------------------------------------------------- 00087 class OMKIII_API JointCreator 00088 { 00089 public: 00090 virtual ~JointCreator(){} 00091 virtual Joint* operator()( OMK::Iii::JointExtension* owner, const ConfigurationParameterDescriptor * node ) const 00092 { 00093 OMERROR( "Creator is not registered" << std::endl << node ) ; 00094 throw Exception( "Creator is not registered" ) ; 00095 return 0 ; 00096 } 00097 } ; 00098 00099 //----------------------------------------------------------------------------- 00105 template <class T> 00106 class JointCreatorT : public JointCreator 00107 { 00108 public: 00109 00110 typedef T object_to_create ; 00111 virtual ~JointCreatorT(){} 00112 Joint* operator()( OMK::Iii::JointExtension* owner, const ConfigurationParameterDescriptor * node ) const 00113 { 00114 return new T( owner, node ) ; 00115 } 00116 } ; 00117 00118 //----------------------------------------------------------------------------- 00141 typedef OBT::Singleton< OBT::PrototypeFactory< OMK::Name, JointCreator > > JointFactory ; 00142 00143 00144 //----------------------------------------------------------------------------- 00193 class OMKIII_API Joint 00194 { 00195 friend class JointExtension ; 00196 DECLARE_JOINT_FACTORY( Joint ) ; 00197 protected: 00199 00200 00201 00202 00203 virtual void establishLink() ; 00207 virtual void currentJointPosition() ; 00213 virtual bool retroPropagation() ; 00217 virtual void currentObjectPosition() ; 00219 00220 00221 00222 00223 OMK::Type::Transform _jointOffset ; 00225 OMK::Type::Transform _jointOffsetInverse ; 00229 OMK::Type::Transform _objectOffset ; 00231 OMK::Type::Transform _objectOffsetInverse ; 00233 JointExtension* _owner ; 00239 IAttributeBaseT< OMK::Type::Transform >* _objectPosition ; 00242 IAttributeBaseT< OMK::Type::Transform >* _referencePosition ; 00247 IAttributeBaseT< OMK::Type::Transform >* _jointPosition ; 00248 } ; 00249 //----------------------------------------------------------------------------- 00279 class OMKIII_API BallJoint : public Joint 00280 { 00281 DECLARE_JOINT_FACTORY( BallJoint ) ; 00282 protected: 00284 00285 00286 virtual void establishLink() ; 00288 virtual bool retroPropagation() ; 00290 virtual void currentObjectPosition() ; 00292 00293 00294 00295 00296 OMK::Type::Transform _newObjectPosition ; 00298 OMK::Type::Transform _refObjectOffset ; 00300 bool _alreadyKnow ; 00303 float _radius ; 00305 Wm4::Vector3f _previousPosition ; 00307 bool _reset ; 00309 } ; 00310 00311 //----------------------------------------------------------------------------- 00312 class OMKIII_API HingeSlideJoint : public Joint 00313 { 00314 DECLARE_JOINT_FACTORY( HingeSlideJoint ) ; 00315 protected: 00317 virtual void establishLink() ; 00319 virtual bool retroPropagation() ; 00321 virtual void currentObjectPosition() ; 00323 OMK::Type::Transform _newObjectPosition ; 00324 OMK::Type::Transform _refObjectOffset ; 00325 bool _alreadyKnow ; 00327 00328 float _radius ; 00329 float _refSlide ; 00331 00332 00333 float _minSlide ; 00334 float _maxSlide ; 00335 bool _minSlideEnable ; 00336 bool _maxSlideEnable ; 00337 float _minAngle ; 00338 float _maxAngle ; 00339 bool _angleEnable ; 00340 bool _rotateOnly ; 00341 bool _ignoreTranslate ; 00343 virtual bool computeConstraints( float& angle, float& currentSlide, 00344 Wm4::Matrix3f& overRotationMatrix, float& overSlide, 00345 Wm4::Vector3f& newOrientation, 00346 const Wm4::Vector3f& refOrientation, const Wm4::Vector3f& axis ) ; 00347 } ; 00348 00349 //----------------------------------------------------------------------------- 00350 class OMKIII_API ScrewJoint : public HingeSlideJoint 00351 { 00352 DECLARE_JOINT_FACTORY( ScrewJoint ) ; 00353 protected: 00354 virtual void establishLink() ; 00355 00357 00358 float _pitch ; 00359 bool _reverse ; 00361 enum States { NOSCREW, SCREW, UNSCREW, IS_MIN, IS_MAX } ; 00362 States _state ; 00363 States _stateMin ; 00364 States _stateMax ; 00365 float _previousAngle ; 00366 float _turns ; 00367 Wm4::Vector3f _previousOrientation ; 00368 virtual bool computeConstraints( float& angle, float& currentSlide, 00369 Wm4::Matrix3f& overRotationMatrix, float& overSlide, 00370 Wm4::Vector3f& newOrientation, 00371 const Wm4::Vector3f& refOrientation, const Wm4::Vector3f& axis ) ; 00372 float computeConstraintAngle( float& angle, const float& currentSlide, 00373 Wm4::Vector3f& newOrientation, 00374 const Wm4::Vector3f& refOrientation, const Wm4::Vector3f& axis ) ; 00375 } ; 00376 00377 }// namespace Iii 00378 }// namespace OMK 00379 00380 template class OMKIII_API OBT::PrototypeFactory< OMK::Name, OMK::Iii::JointCreator > ; 00381 template class OMKIII_API OBT::Singleton< OBT::PrototypeFactory< OMK::Name, OMK::Iii::JointCreator > > ; 00382 00383 #endif // defined OMK_III_JOINT_H
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |