29 #ifndef __H3DFAKEHAPTICSDEVICE_H__
30 #define __H3DFAKEHAPTICSDEVICE_H__
37 #include <HAPI/HAPIHapticsDevice.h>
49 class H3DAPI_API FakeHapticsDevice:
public HAPI::HAPIHapticsDevice {
52 FakeHapticsDevice() : owner( NULL ) {}
56 virtual void updateDeviceValues( DeviceValues &dv, HAPI::HAPITime dt );
59 virtual void sendOutput( DeviceOutput &,
63 virtual bool initHapticsDevice(
int = 1000 ) {
68 virtual bool releaseHapticsDevice() {
return true; }
82 template<
class BaseField >
92 inline virtual const typename BaseField::value_type &
getValue(
int _id = 0 ) {
95 value_lock.readLock();
96 value_for_haptic = rt_value;
98 return value_for_haptic;
108 value_lock.writeLock();
109 rt_value = this->value;
118 inline virtual void setValue(
const typename BaseField::value_type &v,
122 value_lock.writeLock();
123 rt_value = this->value;
128 typename BaseField::value_type rt_value;
136 Inst< SFRotation > _deviceOrientation = 0,
137 Inst< TrackerPosition > _trackerPosition = 0,
138 Inst< TrackerOrientation > _trackerOrientation = 0,
139 Inst< SFMatrix4f > _positionCalibration = 0,
140 Inst< SFRotation > _orientationCalibration = 0,
141 Inst< SFVec3f > _proxyPosition = 0,
142 Inst< WeightedProxy > _weightedProxyPosition = 0,
143 Inst< SFFloat > _proxyWeighting = 0,
144 Inst< SFBool > _mainButton = 0,
145 Inst< SFBool > _secondaryButton = 0,
146 Inst< SFInt32 > _buttons = 0,
147 Inst< SFVec3f > _force = 0,
148 Inst< SFVec3f > _torque = 0,
149 Inst< SFInt32 > _inputDOF = 0,
150 Inst< SFInt32 > _outputDOF = 0,
151 Inst< SFInt32 > _hapticsRate = 0,
152 Inst< SFInt32 > _desiredHapticsRate = 0,
153 Inst< SFNode > _stylus = 0,
154 Inst< SFHapticsRendererNode > _hapticsRenderer = 0,
155 Inst< MFVec3f > _proxyPositions = 0,
156 Inst< SFBool > _followViewpoint = 0,
162 Inst< SFFloat > _gripperAngle = 0,
164 Inst< SFFloat > _gripperForce = 0 );
169 hapi_device.reset( NULL );
205 bool pauseDeviceTransform;
207 HAPI::HAPIHapticsDevice::DeviceValues pauseDeviceTransformDV;
209 virtual void initialize() {
212 dynamic_cast< H3DFakeHapticsDevice::FakeHapticsDevice *
>(hapi_device.get())->owner =
this;
233 virtual void updateDeviceValues();
Header file for H3DHapticsDevice.
Header file for PeriodicUpdate, template field modifier.
Contains the SFFloat field class.
static bool inHapticThread()
static bool inMainThread()
A field which ensure that getValue and only getValue can be called within haptic thread with thread s...
Definition: H3DFakeHapticsDevice.h:83
virtual void upToDate()
Make sure that the field is up-to-date, but never in non-main thread.
Definition: H3DFakeHapticsDevice.h:113
GetValueSafeField()
Constructor.
Definition: H3DFakeHapticsDevice.h:86
virtual void update()
update can not happens in non-main thread
Definition: H3DFakeHapticsDevice.h:105
BaseField::value_type value_for_haptic
value to be used for haptic thread
Definition: H3DFakeHapticsDevice.h:130
virtual void setValue(const typename BaseField::value_type &v, int _id=0)
Set the value of the field, also only allowed in main thread.
Definition: H3DFakeHapticsDevice.h:118
virtual const BaseField::value_type & getValue(int _id=0)
Get the value of the field.
Definition: H3DFakeHapticsDevice.h:92
<>
Definition: H3DFakeHapticsDevice.h:47
static H3DNodeDatabase database
Node database entry.
Definition: H3DFakeHapticsDevice.h:173
H3DUniquePtr< GetValueSafeField< SFBool > > set_secondaryButton
The set_secondaryButton field can be used to set the secondaryButton field of the haptics device.
Definition: H3DFakeHapticsDevice.h:197
H3DUniquePtr< GetValueSafeField< SFRotation > > set_deviceOrientation
The set_deviceOrientation field can be used to set the deviceOrientation field of the haptics device.
Definition: H3DFakeHapticsDevice.h:185
H3DUniquePtr< GetValueSafeField< SFFloat > > set_gripperAngle
The set_gripperAngle field can be used to set the gripperAngle field.
Definition: H3DFakeHapticsDevice.h:223
H3DUniquePtr< GetValueSafeField< SFVec3f > > set_devicePosition
The set_devicePosition field can be used to set the devicePosition field of the haptics device.
Definition: H3DFakeHapticsDevice.h:179
H3DUniquePtr< SFFloat > gripperForce
Output field for the gripper force.
Definition: H3DFakeHapticsDevice.h:228
H3DUniquePtr< GetValueSafeField< SFBool > > set_pauseDeviceTransform
The set_pauseDeviceTransform field can be used to pause the transform of the haptics device.
Definition: H3DFakeHapticsDevice.h:203
H3DUniquePtr< SFFloat > gripperAngle
Output field for the gripper angle.
Definition: H3DFakeHapticsDevice.h:218
H3DUniquePtr< GetValueSafeField< SFBool > > set_mainButton
The set_mainButton field can be used to set the mainButton field of the haptics device.
Definition: H3DFakeHapticsDevice.h:191
~H3DFakeHapticsDevice()
Destructor.
Definition: H3DFakeHapticsDevice.h:167
Base class for all haptic devices.
Definition: H3DHapticsDevice.h:68
The PeriodicUpdate is a template modifier that changes the way the field is updated.
Definition: PeriodicUpdate.h:74
virtual void upToDate()
upToDate is specialized to record the time of the call to the function in the last_up_to_date member.
Definition: PeriodicUpdate.h:125
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194