MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InputDeviceVRPNTracker.H
Go to the documentation of this file.
1 //========================================================================
2 // MinVR
3 // Platform: Any
4 // API version: 1.0
5 //------------------------------------------------------------------------
6 // The MIT License (MIT)
7 //
8 // Copyright (c) 2013 Regents of the University of Minnesota
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of
11 // this software and associated documentation files (the "Software"), to deal in
12 // the Software without restriction, including without limitation the rights to
13 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 // the Software, and to permit persons to whom the Software is furnished to do so,
15 // subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in all
18 // copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //========================================================================
27 
35 #ifndef VRPNTRACKERDEVICE_H
36 #define VRPNTRACKERDEVICE_H
37 
38 // Note: This include ordering is important, don't screw with it!
39 #include <glm/glm.hpp>
40 #include <glm/gtc/matrix_access.hpp>
41 #include <glm/gtx/orthonormalize.hpp>
42 #include <glm/gtc/quaternion.hpp>
43 #include <vector>
45 #include "MVRCore/ConfigMap.H"
46 #include "MVRCore/StringUtils.H"
47 
48 #include <boost/log/trivial.hpp>
49 #define BOOST_ASSERT_MSG_OSTREAM std::cout
50 #include <boost/assert.hpp>
51 
52 #ifdef USE_VRPN
53 class vrpn_Tracker_Remote;
54 class vrpn_Connection;
55 #endif
56 
57 namespace MinVR {
58 
95 {
96 public:
97 #ifdef USE_VRPN
99  const std::string &vrpnTrackerDeviceName,
100  const std::vector<std::string> &eventsToGenerate,
101  const double &trackerUnitsToRoomUnitsScale,
102  const glm::mat4 &deviceToRoom,
103  const std::vector<glm::mat4> &propToTracker,
104  const std::vector<glm::mat4> &finalOffset,
105  const bool &waitForNewReportInPoll,
106  const bool &convertLHtoRH = false,
107  const bool &ignoreZeroes = false);
108 
109  InputDeviceVRPNTracker(const std::string name, const ConfigMapRef map);
110 
111  virtual ~InputDeviceVRPNTracker();
112 
113  void processEvent(const glm::mat4 &vrpnEvent, int sensorNum);
114  std::string getEventName(int trackerNumber);
115  void pollForInput(std::vector<EventRef> &events);
116  void setPrintSensor0(bool b) { _printSensor0 = b; }
117 
118 private:
119  vrpn_Connection *_vrpnConnection;
120  vrpn_Tracker_Remote *_vrpnDevice;
121  std::vector<std::string> _eventNames;
122  double _trackerUnitsToRoomUnitsScale;
123  glm::mat4 _deviceToRoom;
124  std::vector<glm::mat4> _propToTracker;
125  std::vector<glm::mat4> _finalOffset;
126  bool _printSensor0;
127  bool _waitForNewReport;
128  bool _convertLHtoRH;
129  bool _ignoreZeroes;
130  bool _newReportFlag;
131  std::vector<EventRef> _pendingEvents;
132 #else
134  const std::string &vrpnTrackerDeviceName,
135  const std::vector<std::string> &eventsToGenerate,
136  const double &trackerUnitsToRoomUnitsScale,
137  const glm::mat4 &deviceToRoom,
138  const std::vector<glm::mat4> &propToTracker,
139  const std::vector<glm::mat4> &finalOffset,
140  const bool &waitForNewReportInPoll,
141  const bool &convertLHtoRH = false,
142  const bool &ignoreZeroes = false)
143  {
144  BOOST_ASSERT_MSG(false, "VRPN is currently unsupported. Set cmake option USE_VRPN to ON and recompile.");
145  }
146 
147  InputDeviceVRPNTracker(const std::string name, const ConfigMapRef map)
148  {
149  BOOST_ASSERT_MSG(false, "VRPN is currently unsupported. Set cmake option USE_VRPN to ON and recompile.");
150  }
151 
153  void pollForInput(std::vector<EventRef> &events) {}
154 
155 #endif // USE_VRPN
156 };
157 
158 } // end namespace
159 
160 #endif
161 
162