H3D API  2.4.1
ClutchedDevice.h
Go to the documentation of this file.
1 // Copyright 2011-2019, SenseGraphics AB
3 //
4 // Any use, or distribution, of this file without permission from the
5 // copyright holders is strictly prohibited. Please contact SenseGraphics,
6 // www.sensegraphics.com, for more information.
7 //
8 //
12 //
14 #ifndef __CLUTCHEDDEVICE_H__
15 #define __CLUTCHEDDEVICE_H__
16 
17 #include <H3D/H3DHapticsDevice.h>
18 
19 namespace H3D {
20 
32  class H3DAPI_API ClutchedDevice: public H3DHapticsDevice {
33  public:
35 
37  class EnableClutch: public AutoUpdate< OnValueChangeSField< SFBool > > {
38  virtual void onValueChange( const bool &value );
39  };
40 
42  class ResetClutchOrientation: public AutoUpdate< OnNewValueSField< SFBool > > {
43  virtual void onNewValue( const bool &value );
44  };
45 
47  class ResetClutchPosition: public AutoUpdate< OnNewValueSField< SFBool > > {
48  virtual void onNewValue( const bool &value );
49  };
50 
53  Inst< SFVec3f > _devicePosition = 0,
54  Inst< SFRotation > _deviceOrientation = 0,
55  Inst< TrackerPosition > _trackerPosition = 0,
56  Inst< TrackerOrientation > _trackerOrientation = 0,
57  Inst< SFMatrix4f > _positionCalibration = 0,
58  Inst< SFRotation > _orientationCalibration = 0,
59  Inst< SFVec3f > _proxyPosition = 0,
60  Inst< WeightedProxy > _weightedProxyPosition = 0,
61  Inst< SFFloat > _proxyWeighting = 0,
62  Inst< SFBool > _mainButton = 0,
63  Inst< SFBool > _secondaryButton = 0,
64  Inst< SFInt32 > _buttons = 0,
65  Inst< SFVec3f > _force = 0,
66  Inst< SFVec3f > _torque = 0,
67  Inst< SFInt32 > _inputDOF = 0,
68  Inst< SFInt32 > _outputDOF = 0,
69  Inst< SFInt32 > _hapticsRate = 0,
70  Inst< SFInt32 > _desiredHapticsRate = 0,
71  Inst< SFNode > _stylus = 0,
72  Inst< SFHapticsDevice > _hapticsDevice = 0,
73  Inst< EnableClutch > _enableClutch = 0,
74  Inst< ResetClutchOrientation > _resetClutchOrientation = 0,
75  Inst< ResetClutchPosition > _resetClutchPosition = 0,
76  Inst< SFVec3f > _unclutchedPosition = 0,
77  Inst< SFRotation > _unclutchedOrientation = 0 );
78 
79 
80  virtual ~ClutchedDevice();
82  virtual void initialize ();
83 
86  virtual ErrorCode initDevice();
87 
91  virtual ErrorCode releaseDevice();
92 
101  virtual void renderShapes( const HapticShapeVector &shapes,
102  unsigned int layer = 0 );
103 
107  virtual void updateDeviceValues();
108 
109  static H3DHapticsDevice* getActualHapticsDevice ( H3DHapticsDevice& d ) {
110  if ( ClutchedDevice* cd= dynamic_cast<ClutchedDevice*>(&d) ) {
111  return cd->hapticsDevice->getValue();
112  } else {
113  return &d;
114  }
115  }
116 
121  H3DUniquePtr<SFHapticsDevice> hapticsDevice;
122 
128  H3DUniquePtr < EnableClutch > enableClutch;
129 
135  H3DUniquePtr< ResetClutchOrientation > resetClutchOrientation;
136 
142  H3DUniquePtr< ResetClutchPosition > resetClutchPosition;
143 
147  H3DUniquePtr < SFVec3f > unclutchedPosition;
148 
152  H3DUniquePtr < SFRotation > unclutchedOrientation;
153 
156 
157  };
158 }
159 
160 #endif
Header file for H3DHapticsDevice.
Enables/Disbles the clutching.
Definition: ClutchedDevice.h:37
If True, resets the orientation offset due to clutching.
Definition: ClutchedDevice.h:42
If True, resets the position offset due to clutching.
Definition: ClutchedDevice.h:47
ClutchedDevice is a wrapper for a H3DHapticsDevice which adds clutching functionality.
Definition: ClutchedDevice.h:32
H3DUniquePtr< ResetClutchOrientation > resetClutchOrientation
Reset clutch orientation.
Definition: ClutchedDevice.h:135
H3DUniquePtr< ResetClutchPosition > resetClutchPosition
Reset clutch position.
Definition: ClutchedDevice.h:142
H3DUniquePtr< EnableClutch > enableClutch
Enable and disable the clutch.
Definition: ClutchedDevice.h:128
H3DUniquePtr< SFVec3f > unclutchedPosition
The position ignoring clutching.
Definition: ClutchedDevice.h:147
H3DUniquePtr< SFRotation > unclutchedOrientation
The orientation ignoring clutching.
Definition: ClutchedDevice.h:152
static H3DNodeDatabase database
Node database entry.
Definition: ClutchedDevice.h:155
H3DUniquePtr< SFHapticsDevice > hapticsDevice
The wrapped haptics device to clutch.
Definition: ClutchedDevice.h:121
Base class for all haptic devices.
Definition: H3DHapticsDevice.h:68
Template to make sure that the Node that is set in a SFNode is of a specified Node type.
Definition: SFNode.h:97
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194