00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __HAPTIKHAPTICSDEVICE_H__
00030 #define __HAPTIKHAPTICSDEVICE_H__
00031
00032 #include "H3DThreadedHapticsDevice.h"
00033 #include "MFString.h"
00034 #ifdef HAVE_HAPTIK
00035 #include <RSLib/Haptik.hpp>
00036 #endif
00037 namespace H3D {
00038
00074 class H3DAPI_API HaptikHapticsDevice: public H3DThreadedHapticsDevice {
00075 public:
00076
00082 class H3DAPI_API SelectDevice:
00083 public TypedField< PeriodicUpdate< SFInt32 >,
00084 Types< SFInt32, SFString > > {
00085 virtual void update();
00086 };
00087
00089 HaptikHapticsDevice(
00090 Inst< ThreadSafeSField< SFVec3f > > _devicePosition = 0,
00091 Inst< ThreadSafeSField< SFRotation > > _deviceOrientation = 0,
00092 Inst< TrackerPosition > _trackerPosition = 0,
00093 Inst< TrackerOrientation > _trackerOrientation = 0,
00094 Inst< PosCalibration > _positionCalibration = 0,
00095 Inst< OrnCalibration > _orientationCalibration = 0,
00096 Inst< SFVec3f > _proxyPosition = 0,
00097 Inst< WeightedProxy > _weightedProxyPosition = 0,
00098 Inst< SFFloat > _proxyWeighting = 0,
00099 Inst< ThreadSafeSField< SFBool > > _main_button = 0,
00100 Inst< ThreadSafeSField< SFVec3f > > _force = 0,
00101 Inst< ThreadSafeSField< SFVec3f > > _torque = 0,
00102 Inst< SFInt32 > _inputDOF = 0,
00103 Inst< SFInt32 > _outputDOF = 0,
00104 Inst< SFInt32 > _hapticsRate = 0,
00105 Inst< SFNode > _stylus = 0,
00106 Inst< SFBool > _initialized = 0,
00107 Inst< MFString > _deviceName = 0,
00108 Inst< MFString > _modelName = 0,
00109 Inst< MFString > _manufacturer = 0,
00110 Inst< SelectDevice > _selectedDevice = 0,
00111 Inst< SFInt32 > _set_selectedDevice = 0,
00112 Inst< SFString > _preferredDeviceType = 0 );
00113
00115 virtual ~HaptikHapticsDevice() {
00116 disableDevice();
00117 if( thread ) {
00118 delete thread;
00119 thread = NULL;
00120 }
00121
00122 #ifdef HAVE_HAPTIK
00123 if( haptik_device ) {
00124 RSLib::IHaptikDeviceInterface t = haptik_device;
00125 haptik_device = NULL;
00126 t->Release();
00127 }
00128 #endif
00129 }
00130
00133 virtual void initDevice();
00134
00138 virtual void disableDevice();
00139
00144 auto_ptr< MFString > deviceName;
00145
00150 auto_ptr< MFString > modelName;
00151
00156 auto_ptr< MFString > manufacturer;
00157
00164 auto_ptr< SelectDevice > selectedDevice;
00165
00175 auto_ptr< SFInt32 > set_selectedDevice;
00176
00198 auto_ptr< SFString > preferredDeviceType;
00199
00201 static H3DNodeDatabase database;
00202
00203 protected:
00206 virtual Vec3f getPosition();
00207
00210 virtual Vec3f getVelocity();
00211
00214 virtual Rotation getOrientation();
00215
00218 virtual bool getButtonStatus();
00219
00222 virtual void sendForce( const Vec3f &f );
00223
00226 virtual void sendTorque( const Vec3f &f );
00227
00229 virtual void changeHaptikDevice( UINT32 new_id );
00230
00231 #ifdef HAVE_HAPTIK
00232 RSLib::Haptik haptik;
00234 RSLib::IHaptikDeviceInterface haptik_device;
00235 Vec3f last_force;
00236 Vec3f last_torque;
00237 #endif
00238 };
00239 }
00240
00241 #endif