H3D API  2.4.1
PlaybackDevice.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __PLAYBACKDEVICE_H__
30 #define __PLAYBACKDEVICE_H__
31 
32 #include <H3D/X3DUrlObject.h>
33 #include <H3D/H3DHapticsDevice.h>
34 #include <H3D/PeriodicUpdate.h>
35 
36 namespace H3D {
37 
61  class H3DAPI_API PlaybackDevice:
62  public X3DUrlObject,
63  public H3DHapticsDevice {
64  public:
65 
67  class H3DAPI_API OnPlay : public OnNewValueSField < AutoUpdate < SFBool > > {
68  virtual void onNewValue( const bool& new_value );
69  };
70 
72  class H3DAPI_API OnSeekToTime : public OnNewValueSField < AutoUpdate < SFTime > > {
73  virtual void onNewValue( const H3DTime& new_value );
74  };
75 
77  class H3DAPI_API OnPlaybackSpeed : public OnNewValueSField < AutoUpdate < SFFloat > > {
78  virtual void onNewValue( const H3DFloat& new_value );
79  };
80 
82  class H3DAPI_API OnDefaultValuesChanged : public PeriodicUpdate < Field > {
83  virtual void update ();
84  };
85 
88  Inst< MFString > _url = 0,
89  Inst< SFVec3f > _devicePosition = 0,
90  Inst< SFRotation > _deviceOrientation = 0,
91  Inst< TrackerPosition > _trackerPosition = 0,
92  Inst< TrackerOrientation > _trackerOrientation = 0,
93  Inst< SFMatrix4f > _positionCalibration = 0,
94  Inst< SFRotation > _orientationCalibration = 0,
95  Inst< SFVec3f > _proxyPosition = 0,
96  Inst< WeightedProxy > _weightedProxyPosition = 0,
97  Inst< SFFloat > _proxyWeighting = 0,
98  Inst< SFBool > _mainButton = 0,
99  Inst< SFBool > _secondaryButton = 0,
100  Inst< SFInt32 > _buttons = 0,
101  Inst< SFVec3f > _force = 0,
102  Inst< SFVec3f > _torque = 0,
103  Inst< SFInt32 > _inputDOF = 0,
104  Inst< SFInt32 > _outputDOF = 0,
105  Inst< SFInt32 > _hapticsRate = 0,
106  Inst< SFInt32 > _desiredHapticsRate = 0,
107  Inst< SFNode > _stylus = 0,
108  Inst< SFHapticsRendererNode > _hapticsRenderer = 0,
109  Inst< MFVec3f > _proxyPositions = 0,
110  Inst< SFBool > _followViewpoint = 0,
111  Inst< OnPlay > _play = 0,
112  Inst< SFBool > _binary = 0,
113  Inst< OnSeekToTime > _seekToTime = 0,
114  Inst< OnPlaybackSpeed > _playbackSpeed = 0,
115  Inst< SFTime > _playbackTime = 0,
116  Inst< SFBool > _playing = 0,
117  Inst< MFString > _playbackData = 0,
118  Inst< SFVec3f > _defaultDevicePosition = 0,
119  Inst< SFRotation > _defaultDeviceOrientation = 0,
120  Inst< SFVec3f > _defaultDeviceVelocity = 0,
121  Inst< SFInt32 > _defaultButtons = 0
122  );
123 
125  virtual void initialize ();
126 
128  virtual void updateDeviceValues ();
129 
133  virtual ErrorCode releaseDevice();
134 
148  H3DUniquePtr < OnPlay > play;
149 
159  H3DUniquePtr< SFBool > binary;
160 
168  H3DUniquePtr < OnSeekToTime > seekToTime;
169 
179  H3DUniquePtr < OnPlaybackSpeed > playbackSpeed;
180 
188  H3DUniquePtr < SFTime > playbackTime;
189 
196  H3DUniquePtr < SFBool > playing;
197 
211  H3DUniquePtr < MFString > playbackData;
212 
219  H3DUniquePtr < SFVec3f > defaultDevicePosition;
220 
227  H3DUniquePtr < SFRotation > defaultDeviceOrientation;
228 
235  H3DUniquePtr < SFVec3f > defaultDeviceVelocity;
236 
243  H3DUniquePtr < SFInt32 > defaultButtons;
244 
247 
248  protected:
249 
251  virtual void updateDefaultValues ();
252 
255  H3DUniquePtr < Field > playbackURLChanged;
256 
258  H3DUniquePtr < OnDefaultValuesChanged > defaultValuesChanged;
259 
262  std::string tmp_filename;
263  };
264 }
265 
266 #endif
Header file for H3DHapticsDevice.
Header file for PeriodicUpdate, template field modifier.
Header file for X3DUrlObject, X3D scene-graph node.
Base class for all haptic devices.
Definition: H3DHapticsDevice.h:68
Template for adding the virtual function onNewValue that can be overridden in subclasses in order to ...
Definition: FieldTemplates.h:79
The PeriodicUpdate is a template modifier that changes the way the field is updated.
Definition: PeriodicUpdate.h:74
A field used to update default playback values.
Definition: PlaybackDevice.h:82
A field used to start and stop playback.
Definition: PlaybackDevice.h:67
A field used to adjust the playback speed.
Definition: PlaybackDevice.h:77
A field used to move playback to a specified time.
Definition: PlaybackDevice.h:72
A PlaybackDevice is a fake haptics device node that can play back device values previously recorded u...
Definition: PlaybackDevice.h:63
H3DUniquePtr< SFInt32 > defaultButtons
The default value to use for the buttons field if no value is played back from the recording.
Definition: PlaybackDevice.h:243
H3DUniquePtr< OnPlay > play
Start and stop the playback.
Definition: PlaybackDevice.h:148
H3DUniquePtr< SFVec3f > defaultDevicePosition
The default value to use for the devicePosition field if no value is played back from the recording.
Definition: PlaybackDevice.h:219
H3DUniquePtr< SFVec3f > defaultDeviceVelocity
The default value to use for the deviceVelocity field if no value is played back from the recording.
Definition: PlaybackDevice.h:235
H3DUniquePtr< MFString > playbackData
The list of field names in the recording that should be played back.
Definition: PlaybackDevice.h:211
H3DUniquePtr< SFTime > playbackTime
Current playback time.
Definition: PlaybackDevice.h:188
H3DUniquePtr< OnSeekToTime > seekToTime
Move playback to the specified time.
Definition: PlaybackDevice.h:168
H3DUniquePtr< OnDefaultValuesChanged > defaultValuesChanged
A field used to update the default device values in the HAPI device.
Definition: PlaybackDevice.h:258
H3DUniquePtr< SFBool > binary
If true, then the recording pointed to by url is assumed to contain binary data.
Definition: PlaybackDevice.h:159
static H3DNodeDatabase database
Node database entry.
Definition: PlaybackDevice.h:246
H3DUniquePtr< OnPlaybackSpeed > playbackSpeed
A scaling factor to apply to the speed of playback.
Definition: PlaybackDevice.h:179
H3DUniquePtr< SFBool > playing
True if the device is currently playing back values.
Definition: PlaybackDevice.h:196
H3DUniquePtr< Field > playbackURLChanged
A field used to detect if the url field has changed since last playback started.
Definition: PlaybackDevice.h:255
H3DUniquePtr< SFRotation > defaultDeviceOrientation
The default value to use for the deviceOrientation field if no value is played back from the recordin...
Definition: PlaybackDevice.h:227
This abstract interface is inherited by all nodes that contain data located on the World Wide Web,...
Definition: X3DUrlObject.h:51
float H3DFloat
double H3DTime
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