H3D API  2.4.1
OculusRiftSensor.h
Go to the documentation of this file.
1 // Copyright 2016-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 __H3D_OCULUSRIFTSENSOR_H__
30 #define __H3D_OCULUSRIFTSENSOR_H__
31 
32 
33 #include <H3D/X3DSensorNode.h>
34 #include <list>
35 #include <H3D/SFVec3f.h>
36 #include <H3D/SFFloat.h>
37 #include <H3D/SFInt32.h>
38 #include <H3D/SFRotation.h>
39 #include <H3DUtil/Threads.h>
40 #include <H3D/OculusRiftHandler.h>
41 #include <H3D/SFVec2f.h>
42 
43 namespace H3D {
44 
56  class H3DAPI_API OculusRiftSensor : public X3DSensorNode {
57  public:
58 
59 
65  class H3DAPI_API RecenterTrackingField:
66  public AutoUpdate< OnNewValueSField< SFBool > > {
67 
68  protected:
69  virtual void onNewValue(const bool &new_value);
70  };
71 
72  class H3DAPI_API MSAAEnabledField :
73  public AutoUpdate< OnNewValueSField< SFBool > > {
74 
75  protected:
76  virtual void onNewValue(const bool &new_value);
77  };
78 
79  class H3DAPI_API PerformanceStatsField :
80  public AutoUpdate< OnNewValueSField< SFString > > {
81 
82  protected:
83  virtual void onNewValue(const string &new_value);
84  };
85 
86 
87 
88 
90  OculusRiftSensor(
91  Inst< SFBool > _enabled = 0,
92  Inst< SFNode > _metadata = 0,
93  Inst< SFBool > _isActive = 0,
94  Inst< SFVec3f > _headPosition = 0,
95  Inst< SFRotation > _headOrientation = 0,
96  Inst< PerformanceStatsField > _performanceStats = 0,
97  Inst< RecenterTrackingField > _recenterTracking = 0,
98  Inst< MSAAEnabledField > _MSAAEnabled = 0,
99  Inst< SFVec3f > _leftHandPosition = 0,
100  Inst< SFRotation > _leftHandOrientation = 0,
101  Inst< SFFloat > _leftHandTrigger = 0,
102  Inst< SFFloat > _leftHandIndexTrigger = 0,
103  Inst< SFVec2f > _leftHandThumbstick = 0,
104  Inst< SFFloat > _leftHandVibrationFrequency = 0,
105  Inst< SFFloat > _leftHandVibrationAmplitude = 0,
106  Inst< SFVec3f > _rightHandPosition = 0,
107  Inst< SFRotation > _rightHandOrientation = 0,
108  Inst< SFFloat > _rightHandTrigger = 0,
109  Inst< SFFloat > _rightHandIndexTrigger = 0,
110  Inst< SFVec2f > _rightHandThumbstick = 0,
111  Inst< SFFloat > _rightHandVibrationFrequency = 0,
112  Inst< SFFloat > _rightHandVibrationAmplitude = 0,
113  Inst< SFInt32 > _buttons = 0,
114  Inst< SFInt32 > _touches = 0
115  );
116 
117  ~OculusRiftSensor() {
118  }
119 
125  H3DUniquePtr< SFVec3f> headPosition;
126 
133  H3DUniquePtr< SFRotation> headOrientation;
134 
144  H3DUniquePtr< PerformanceStatsField> performanceStats;
145 
146 
152  H3DUniquePtr< RecenterTrackingField> recenterTracking;
153 
160  H3DUniquePtr< MSAAEnabledField > MSAAEnabled;
161 
167  H3DUniquePtr< SFVec3f> leftHandPosition;
168 
174  H3DUniquePtr< SFRotation> leftHandOrientation;
175 
181  H3DUniquePtr< SFFloat > leftHandTrigger;
182 
188  H3DUniquePtr< SFFloat > leftHandIndexTrigger;
189 
195  H3DUniquePtr< SFVec2f > leftHandThumbstick;
196 
203  H3DUniquePtr< SFFloat > leftHandVibrationFrequency;
204 
211  H3DUniquePtr< SFFloat > leftHandVibrationAmplitude;
212 
218  H3DUniquePtr< SFVec3f> rightHandPosition;
219 
225  H3DUniquePtr< SFRotation> rightHandOrientation;
226 
232  H3DUniquePtr< SFFloat > rightHandTrigger;
233 
239  H3DUniquePtr< SFFloat > rightHandIndexTrigger;
240 
246  H3DUniquePtr< SFVec2f > rightHandThumbstick;
247 
254  H3DUniquePtr< SFFloat > rightHandVibrationFrequency;
255 
262  H3DUniquePtr< SFFloat > rightHandVibrationAmplitude;
263 
269  H3DUniquePtr< SFInt32 > buttons;
270 
276  H3DUniquePtr< SFInt32 > touches;
277 
278  public:
279 
282 
283 #ifdef HAVE_LIBOVR
284  static OculusRiftHandler *oculus;
285 #endif
286 
287  private:
288 
291  void updateValues();
292 
293  struct H3DAPI_API Update
294  : AutoUpdate<Field> {
295  void update(){
296  static_cast<OculusRiftSensor*>
297  (owner)->updateValues();
298  }
299  };
300 
301  H3DUniquePtr< Update > update;
302  };
303 }
304 
305 #endif
Header file for the Oculus Rift support code.
Contains the SFFloat field class.
Contains the SFInt32 field class.
Contains the SFRotation field class.
Contains the SFVec2f field class.
Contains the SFVec3f field class.
Header file for X3DSensorNode, X3D scene-graph node.
This class is an AutoUpdate class that sets the field accumulatedRotation to its input value and also...
Definition: OculusRiftSensor.h:66
This is a X3DSensorNode for reading values from a Oculus Rift HMD.
Definition: OculusRiftSensor.h:56
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: OculusRiftSensor.h:281
H3DUniquePtr< PerformanceStatsField > performanceStats
Makes it possible to show performance stats of the oculus.
Definition: OculusRiftSensor.h:144
H3DUniquePtr< SFFloat > leftHandVibrationFrequency
Used to control the vibration frequency of the left touch controller.
Definition: OculusRiftSensor.h:203
H3DUniquePtr< SFFloat > rightHandVibrationAmplitude
Used to control the vibration amplitude of the right touch controller.
Definition: OculusRiftSensor.h:262
H3DUniquePtr< SFVec3f > leftHandPosition
The position of the left touch controller.
Definition: OculusRiftSensor.h:167
H3DUniquePtr< SFVec2f > rightHandThumbstick
The value for the right hand thumb stick.
Definition: OculusRiftSensor.h:246
H3DUniquePtr< RecenterTrackingField > recenterTracking
Recenter the tracking for oculus.
Definition: OculusRiftSensor.h:152
H3DUniquePtr< SFRotation > headOrientation
Contains the current head orientation around the x-axis as reported by the device.
Definition: OculusRiftSensor.h:133
H3DUniquePtr< SFRotation > leftHandOrientation
The orientation of the left touch controller.
Definition: OculusRiftSensor.h:174
H3DUniquePtr< SFRotation > rightHandOrientation
The orientation of the right touch controller.
Definition: OculusRiftSensor.h:225
H3DUniquePtr< SFFloat > leftHandIndexTrigger
The value for the left hand index trigger.
Definition: OculusRiftSensor.h:188
H3DUniquePtr< SFFloat > rightHandIndexTrigger
The value for the right hand index trigger.
Definition: OculusRiftSensor.h:239
H3DUniquePtr< SFFloat > leftHandTrigger
The value for the left hand trigger.
Definition: OculusRiftSensor.h:181
H3DUniquePtr< SFVec3f > rightHandPosition
The position of the right touch controller.
Definition: OculusRiftSensor.h:218
H3DUniquePtr< SFVec3f > headPosition
Contains the current head translation as reported by the device.
Definition: OculusRiftSensor.h:125
H3DUniquePtr< SFFloat > leftHandVibrationAmplitude
Used to control the vibration amplitude of the left touch controller.
Definition: OculusRiftSensor.h:211
H3DUniquePtr< SFFloat > rightHandVibrationFrequency
Used to control the vibration frequency of the right touch controller.
Definition: OculusRiftSensor.h:254
H3DUniquePtr< SFInt32 > touches
Setting some touched output state.
Definition: OculusRiftSensor.h:276
H3DUniquePtr< SFInt32 > buttons
Indicates which buttons are pressed.
Definition: OculusRiftSensor.h:269
H3DUniquePtr< SFVec2f > leftHandThumbstick
The value for the left hand thumb stick.
Definition: OculusRiftSensor.h:195
H3DUniquePtr< MSAAEnabledField > MSAAEnabled
Controls multi sample anti aliasing on the oculus.
Definition: OculusRiftSensor.h:160
H3DUniquePtr< SFFloat > rightHandTrigger
The value for the right hand trigger.
Definition: OculusRiftSensor.h:232
This abstract node type is the base type for all sensors.
Definition: X3DSensorNode.h:40
The OculusRiftHandler class provides support for the Oculus Rift VR device.
Definition: OculusRiftHandler.h:49
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