29 #ifndef __H3DHAPTICSDEVICE_H__
30 #define __H3DHAPTICSDEVICE_H__
50 #include <HAPI/HAPIHapticShape.h>
51 #include <HAPI/HAPIHapticsDevice.h>
52 #include <HAPI/HAPIForceEffect.h>
70 H3DUniquePtr< HAPI::HAPIHapticsDevice > hapi_device;
74 typedef HAPI::HAPIHapticsDevice::ErrorCode ErrorCode;
75 typedef HAPI::HAPIHapticsDevice::DeviceState DeviceState;
82 DEPRECATED(
"SFMatrix4f", )
129 public TypedField< SFVec3f, Types< SFMatrix4f, SFVec3f > > {
132 virtual void update() {
144 value = m.getScaleRotationPart() * d_vel;
156 public TypedField< SFRotation, Types< SFRotation, SFRotation > > {
187 public TypedField< SFVec3f, Types< SFVec3f, SFVec3f, SFFloat > > {
188 virtual void update() {
189 const Vec3f &proxy_pos =
191 const Vec3f &tracker_pos =
195 value = tracker_pos + weighting * ( proxy_pos - tracker_pos );
204 virtual void onAdd(
Node *n ) {
210 if( renderer && device->hapi_device.get() ) {
211 for(
unsigned int i = 0; i < device->hapi_device->nrLayers(); ++i )
212 device->hapi_device->setHapticsRenderer(
216 virtual void onRemove(
Node *n ) {
219 if( renderer && device->hapi_device.get() ) {
220 for(
unsigned int i = 0; i < device->hapi_device->nrLayers(); ++i ) {
222 device->hapi_device->setHapticsRenderer( NULL, i );
234 virtual void onValueChange(
const bool &v ) {
246 Inst< SFRotation > _deviceOrientation = 0,
247 Inst< TrackerPosition > _trackerPosition = 0,
248 Inst< TrackerOrientation > _trackerOrientation = 0,
249 Inst< SFMatrix4f > _positionCalibration = 0,
250 Inst< SFRotation > _orientationCalibration = 0,
251 Inst< SFVec3f > _proxyPosition = 0,
252 Inst< WeightedProxy > _weightedProxyPosition = 0,
253 Inst< SFFloat > _proxyWeighting = 0,
254 Inst< SFBool > _mainButton = 0,
255 Inst< SFBool > _secondaryButton = 0,
256 Inst< SFInt32 > _buttons = 0,
257 Inst< SFVec3f > _force = 0,
258 Inst< SFVec3f > _torque = 0,
259 Inst< SFInt32 > _inputDOF = 0,
260 Inst< SFInt32 > _outputDOF = 0,
261 Inst< SFInt32 > _hapticsRate = 0,
262 Inst< SFInt32 > _desiredHapticsRate = 0,
263 Inst< SFNode > _stylus = 0,
264 Inst< SFHapticsRendererNode > _hapticsRenderer = 0,
265 Inst< MFVec3f > _proxyPositions = 0,
266 Inst< SFBool > _followViewpoint = 0,
267 Inst< SFVec3f > _deviceVelocity = 0,
268 Inst< TrackerVelocity > _trackerVelocity = 0,
270 Inst< SFString > _profiledResult = 0,
272 Inst< SFVec3f > _deviceAngularVelocity = 0,
273 Inst< TrackerAngularVelocity > _trackerAngularVelocity = 0
286 return previous_proxy_pos[layer];
291 return previous_proxy_pos;
302 return hapi_device.get();
307 virtual ErrorCode initDevice();
312 virtual ErrorCode releaseDevice();
315 virtual ErrorCode enableDevice();
319 virtual ErrorCode disableDevice();
323 if( hapi_device.get() ) {
324 return hapi_device->getThread();
339 virtual void updateDeviceValues();
358 unsigned int layer = 0 );
361 virtual void renderStylus();
392 H3DUniquePtr< SFString > profiledResult;
665 vector< Vec3f > previous_proxy_pos;
675 Matrix4f default_vp_pos_mtx;
676 Vec3f default_vp_scaling;
681 Matrix3f default_vp_orn_mtx;
689 HAPI::HAPIHapticsRenderer::Contacts last_contacts;
691 bool error_msg_printed;
694 void setHapticsRenderer(
unsigned int layer );
705 public TypedField< SFVec3f, Types< SFRotation, SFVec3f > > {
Contains different templates to modify field behaviour.
Header file for H3DHapticsRendererNode.
Contains the MFVec3f field class.
Contains the SFBool field class.
Contains the SFFloat field class.
Contains the SFInt32 field class.
Contains the SFMatrix4f field class.
Contains the SFNode class.
Contains the SFRotation field class.
Contains the SFString field class.
Contains the SFTime field class.
Contains the SFVec3f field class.
SFHapticsRendererNode extends TypedSFNode< H3DHapticsRendererNode > in order to change the haptics re...
Definition: H3DHapticsDevice.h:203
SetEnabled specializes SFBool to go into reset mode when a true event is received.
Definition: H3DHapticsDevice.h:233
The TrackerAngularVelocity field updates itself from the deviceAngularVelocity and orientationCalibra...
Definition: H3DHapticsDevice.h:705
virtual void update()
Make the field up to date given that an event has occured.
Definition: H3DHapticsDevice.h:708
The TrackerOrientation field updates itself from the deviceOrientation and orientationCalibration fie...
Definition: H3DHapticsDevice.h:156
virtual void update()
Make the field up to date given that an event has occured.
Definition: H3DHapticsDevice.h:159
The TrackerPosition field updates itself from the devicePosition and positionCalibration fields.
Definition: H3DHapticsDevice.h:101
virtual void update()
value = positionCalibration * devicePosition.
Definition: H3DHapticsDevice.h:105
The TrackerVelocity field updates itself from the deviceVelocity and positionCalibration fields.
Definition: H3DHapticsDevice.h:129
The WeightedProxy field updates to be a value between the proxy position and tracker position dependi...
Definition: H3DHapticsDevice.h:187
Base class for all haptic devices.
Definition: H3DHapticsDevice.h:68
H3DUniquePtr< SFFloat > proxyWeighting
The weighting between proxyPosition and trackerPosition when calculating weightedProxyPosition.
Definition: H3DHapticsDevice.h:451
H3DUniquePtr< TrackerAngularVelocity > trackerAngularVelocity
The angular velocity of the device in the world coordinates of the API.
Definition: H3DHapticsDevice.h:738
H3DUniquePtr< SFInt32 > desiredHapticsRate
The desired update rate of the servoloop of the H3DHapticsDevice.
Definition: H3DHapticsDevice.h:535
H3DUniquePtr< SFMatrix4f > positionCalibration
The calibration matrix between devicePosition and trackerPosition.
Definition: H3DHapticsDevice.h:407
H3DUniquePtr< SFBool > secondaryButton
The state of the secondary button (button 1).
Definition: H3DHapticsDevice.h:467
H3DUniquePtr< SFRotation > deviceOrientation
The orientation of the device given in the coordinate system of the device.
Definition: H3DHapticsDevice.h:383
H3DUniquePtr< SFBool > enabled
true if the device is enabled, e.g.
Definition: H3DHapticsDevice.h:596
H3DUniquePtr< SFTime > hapticsLoopTime
The time spent in the last haptics loop(in seconds) A value of -1 means that no haptics loop has been...
Definition: H3DHapticsDevice.h:545
static H3DNodeDatabase database
Node database entry.
Definition: H3DHapticsDevice.h:663
Vec3f getPreviousProxyPosition(unsigned int layer=0)
Get the proxy position from the previous loop for a certain layer.
Definition: H3DHapticsDevice.h:285
H3DUniquePtr< SFVec3f > torque
The approximation of the torque that has been rendered during the last scenegraph loop.
Definition: H3DHapticsDevice.h:493
H3DUniquePtr< SFVec3f > deviceVelocity
The velocity of the device in the coordinate system of the device.
Definition: H3DHapticsDevice.h:612
H3DUniquePtr< SFInt32 > buttons
The state of all buttons.
Definition: H3DHapticsDevice.h:477
H3DUniquePtr< SFRotation > orientationCalibration
The calibration rotation between deviceOrientation and trackerOrientation.
Definition: H3DHapticsDevice.h:420
virtual ErrorCode disableDevice()
Temporarily disable the device.
Definition: H3DHapticsDevice.cpp:218
H3DUniquePtr< MFVec3f > proxyPositions
The positions of the proxies for each layer used in haptic rendering(layer 0).
Definition: H3DHapticsDevice.h:578
H3DUniquePtr< SFBool > deadmansSwitch
This is an alternative operational safety mode.
Definition: H3DHapticsDevice.h:650
H3DUniquePtr< SFFloat > forceScale
Set the scaling of the output force.
Definition: H3DHapticsDevice.h:639
H3DUniquePtr< SFVec3f > proxyPosition
The position of the proxy used in the haptic rendering(layer 0).
Definition: H3DHapticsDevice.h:431
virtual void postInit()
This function is called for all devices in a DeviceInfo node for which the initDevice has been called...
Definition: H3DHapticsDevice.h:334
H3DUniquePtr< SFNode > stylus
The Node used as the visual representation of the stylus.
Definition: H3DHapticsDevice.h:552
H3DUniquePtr< SFInt32 > inputDOF
The degrees of freedom supported as input.
Definition: H3DHapticsDevice.h:500
virtual ErrorCode enableDevice()
Enable the device. Positions can be read and force can be sent.
Definition: H3DHapticsDevice.cpp:206
H3DUniquePtr< SFVec3f > deviceAngularVelocity
The angular velocity of the device in the coordinate system of the device.
Definition: H3DHapticsDevice.h:729
H3DUniquePtr< SFMatrix4f > adjustedPositionCalibration
The calibration matrix between devicePosition and trackerPosition adjusted with the movement of the v...
Definition: H3DHapticsDevice.h:411
H3DUniquePtr< SFRotation > adjustedOrnCalibration
The calibration rotation between deviceOrientation and trackerOrientation adjusted with the movement ...
Definition: H3DHapticsDevice.h:424
H3DUniquePtr< SFBool > followViewpoint
true if the device should follow the viewpoint.
Definition: H3DHapticsDevice.h:604
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: H3DHapticsDevice.h:296
HAPI::HAPIHapticsDevice * getHAPIDevice()
Get the HAPIHapticsDevice that is encapsulated by this node.
Definition: H3DHapticsDevice.h:301
H3DUniquePtr< SFFloat > torqueLimit
The maximum torque(in Nm) we want the device to render.
Definition: H3DHapticsDevice.h:660
H3DUniquePtr< SFVec3f > force
The approximation of the force that has been rendered during the last scenegraph loop.
Definition: H3DHapticsDevice.h:485
H3DUniquePtr< SetEnabled > set_enabled
Enable/disable the device.
Definition: H3DHapticsDevice.h:587
H3DUniquePtr< WeightedProxy > weightedProxyPosition
A weighted position between proxyPosition and trackerPosition.
Definition: H3DHapticsDevice.h:440
virtual void postRender()
This function is called at the end of each scenegraph loop after all calls to other HapticDevice func...
Definition: H3DHapticsDevice.h:350
H3DUniquePtr< SFBool > initialized
true if the device is initialized and ready for calls to updateDeviceValues() and renderObjects().
Definition: H3DHapticsDevice.h:562
H3DUniquePtr< SFInt32 > hapticsRate
The update rate of the servoloop of the H3DHapticsDevice.
Definition: H3DHapticsDevice.h:514
H3DUniquePtr< SFInt32 > outputDOF
The degrees of freedom supported as output, i.e.
Definition: H3DHapticsDevice.h:507
virtual void preRender()
This function is called at the start of each scenegraph loop before any calls to other HapticDevice f...
Definition: H3DHapticsDevice.h:345
virtual ~H3DHapticsDevice()
Destuctor.
Definition: H3DHapticsDevice.h:277
H3DUtil::PeriodicThreadBase * getThread()
Get the thread that is used to run this haptics device.
Definition: H3DHapticsDevice.h:322
TimeStamp last_effect_change
The time for the last call to the renderEffects function.
Definition: H3DHapticsDevice.h:687
H3DUniquePtr< SFVec3f > devicePosition
The position of the device given in the coordinate system of the device.
Definition: H3DHapticsDevice.h:375
H3DUniquePtr< SFFloat > forceLimit
The maximum force(in N) we want the device to render.
Definition: H3DHapticsDevice.h:630
H3DUniquePtr< SFBool > mainButton
The state of the main button(button 0).
Definition: H3DHapticsDevice.h:459
H3DUniquePtr< TrackerPosition > trackerPosition
The position of the device in the world coordinates of the API.
Definition: H3DHapticsDevice.h:390
H3DUniquePtr< TrackerOrientation > trackerOrientation
The orientation of the device in the world coordinates of the API.
Definition: H3DHapticsDevice.h:399
const vector< Vec3f > & getPreviousProxyPositions()
Get all previous proxy positions.
Definition: H3DHapticsDevice.h:290
H3DUniquePtr< SFHapticsRendererNode > hapticsRenderer
Specifies the haptics rendering algorithm to use to generate forces from geometric shapes.
Definition: H3DHapticsDevice.h:570
H3DUniquePtr< TrackerVelocity > trackerVelocity
The velocity of the device in the world coordinates of the API.
Definition: H3DHapticsDevice.h:620
Base class for all haptic renderers, i.e.
Definition: H3DHapticsRendererNode.h:44
virtual HAPI::HAPIHapticsRenderer * getHapticsRenderer(unsigned int layer)
Get the haptics renderer to use for a certain layer.
Definition: H3DHapticsRendererNode.h:53
virtual void hapticsRendererRemoved(unsigned int layer)
This function should only be called if the HAPI::HAPIHapticsRenderer obtained for the given layer is ...
Definition: H3DHapticsRendererNode.h:69
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
Template for adding the virtual function onValueChange that can be overridden in subclasses in order ...
Definition: FieldTemplates.h:49
virtual void onRemove(Node *n)
This function will be called when the value of RefCountSField changes.
Definition: RefCountSField.h:176
The SFBool field contains a single boolean value.
Definition: SFBool.h:41
The SFFloat field contains one single-precision floating point number.
Definition: SFFloat.h:41
The SFMatrix4f field contains a Matrix4f.
Definition: SFMatrix4f.h:41
The SFRotation field contains one arbitrary Rotation.
Definition: SFRotation.h:41
The SFVec3f field contains a Vec3f.
Definition: SFVec3f.h:41
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
Template to make sure that the Node that is set in a SFNode is of a specified Node type.
Definition: SFNode.h:97
virtual void onAdd(Node *n)
We check that the type of the Node is of the correct type.
Definition: SFNode.h:108
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
The Types template can be used in the RequiredArgTypes or OptionalArgTypes arguments of a TypedField ...
Definition: TypedFieldTypesTmpl.h:60