AnnHandController.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "systemMacro.h"
4 
5 #include <Ogre.h>
6 #include <OgreItem.h>
7 #include "AnnVect3.hpp"
8 #include "AnnQuaternion.hpp"
9 #include "AnnTypes.h"
10 
11 namespace Annwvyn
12 {
13  //Forward declaration of the renderer classes that manager VR controllers
14  class AnnOgreVRRenderer;
15  class AnnOgreOpenVRRenderer;
16  class AnnOgreOculusRenderer;
17 
19  using AnnHandControllerID = size_t;
20 
23  {
24  public:
28  AnnHandControllerAxis(const std::string& AxisName, float normalizedValue);
29 
31  AnnHandControllerAxis(const AnnHandControllerAxis& axis) = default;
32 
34  std::string getName() const;
35 
37  float getValue() const;
38 
39  private:
40  friend class AnnOgreVRRenderer;
41  friend class AnnOgreOpenVRRenderer;
42  friend class AnnOgreOculusRenderer;
43 
45  void updateValue(float normalizedValue);
46 
48  static bool isInRange(float v);
49 
52 
54  float value;
55  };
56 
59  {
60  public:
62  virtual ~AnnHandController() = default;
63 
65  using AnnHandControllerTypeHash = size_t;
68 
71 
73  enum AnnHandControllerSide : uint8_t { leftHandController = 0,
74  rightHandController = 1,
75  invalidHandController = 2 };
76 
78  using HandControllerCapabilites_t = uint16_t;
79 
82  None = 0,
83  RotationalTracking = 0b0000000001, //Can get the orientation of the user hand
84  PositionalTracking = 0b0000000010, //Can get the position of the user hand
85  AngularAccelerationTracking = 0b0000000100, //Can get the current angular acceleration
86  LinearAccelerationTracking = 0b0000001000, //Can get the current linear acceleration
87  ButtonInputs = 0b0000010000, //Can get inputs form buttons
88  AnalogInputs = 0b0000100000, //Can get inputs from axes
89  HapticFeedback = 0b0001000000, //Can produce haptic feedback
90  DiscreteHandGestures = 0b0010000000, //Can detect some hand gestures (Like the touch controller does)
91  SkeletalFingerTracking = 0b0100000000, //Can fully get the pose of an hand (Like on the LEAP Motion controller)
92  ProportionalFingerTrackng = 0b1000000000, //Can get a 5 axis analog representation of the fingers
93  };
94 
96  AnnHandController(const std::string& Type, Ogre::SceneNode* handNode, AnnHandControllerID controllerID, AnnHandControllerSide controllerSide);
97 
99  static std::string getSideAsString(AnnHandControllerSide s);
100 
102  void _attachModelItem(Ogre::Item* handModel);
103 
105  void setHandModel(const std::string& name);
106 
108  void detachModel();
109 
111  Ogre::Item* getHandModel() const;
112 
114  AnnVect3 getWorldPosition() const;
115 
117  AnnQuaternion getWorldOrientation() const;
118 
120  AnnVect3 getAngularSpeed() const;
121 
123  AnnVect3 getLinearSpeed() const;
124 
126  AnnVect3 getPointingDirection() const;
127 
129  void attachNode(Ogre::SceneNode* grabbedObject);
130 
132  void setTrackedPosition(AnnVect3 position);
133 
135  void setTrackedOrientation(AnnQuaternion orientation);
136 
138  void setTrackedLinearSpeed(AnnVect3 v);
139 
141  void setTrackedAngularSpeed(AnnVect3 v);
142 
144  void updateVisibility() const;
145 
147  bool isTracked() const;
148 
151  bool getButtonState(uint8_t buttonIndex);
152 
154  size_t getNbButton() const;
155 
158  bool hasBeenPressed(uint8_t buttonIndex);
159 
162  bool hasBeenReleased(uint8_t buttonIndex);
163 
165  size_t getNbAxes() const;
166 
169  AnnHandControllerAxis& getAxis(size_t index);
170 
172  AnnHandControllerSide getSide() const;
173 
175  std::string getTypeString() const;
176 
178  AnnHandControllerTypeHash getType() const;
179 
181  virtual void rumbleStart(float factor);
182 
184  virtual void rumbleStop();
185 
187  HandControllerCapabilites_t getCapabilities() const;
188 
190  virtual std::string getCurrentGesture();
191 
193  virtual AnnHandControllerGestureHash gestcurrentGesturesHash();
194 
195  protected:
198 
199  friend class AnnOgreVRRenderer;
200  friend class AnnOgreOpenVRRenderer;
201  friend class AnnOgreOculusRenderer;
202 
205 
208 
210  std::vector<AnnHandControllerAxis>& getAxesVector();
211 
213  std::vector<byte>& getButtonStateVector();
214 
216  std::vector<uint8_t>& getPressedButtonsVector();
217 
219  std::vector<uint8_t>& getReleasedButtonsVector();
220 
223 
226 
228  Ogre::SceneNode *node, *grabbed;
229 
231  Ogre::Item* model;
232 
234  bool tracked;
235 
238 
241 
244 
247 
250 
253 
256 
258  static constexpr const char* const gestureNotAvailableString{ "N/A" };
259  };
260 
262 }
std::string controllerTypeString
Type of the controller, Can be string like "Vive controller" or "Oculus Touch Controller".
file for defining macros used for symbol export regarding the way the OS does things.
Abstract class for VR Renderers. Serve as interface between Annwvyn, and "OgreHMDRender" object...
AnnHandControllerSide side
Side of the controller, right hand? left hand? Who knows!
const AnnHandControllerGestureHash gestureNotAvailableHash
The hash of the "N/A" string.
float value
Value of the axis.
AnnVect3 trackedLinearSpeed
Linear velocity vector.
A 3D Vector.
Definition: AnnVect3.hpp:16
AnnHandControllerID id
ID of the controller, expect 1 or 2.
A 3D Vector.
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
std::vector< AnnHandControllerAxis > axes
Axes vector.
bool tracked
tracked boolean, true if controller has been updated by the engine
Represent the axis of an hand controller.
std::string name
Name of the axis.
HandControllerCapabilites_t capabilites
Capabilities of this controller.
AnnHandControllerSide
Identify the controller as "left hand", "right hand" or "invalid hand".
size_t AnnHandControllerGestureHash
Hash of a string identifier.
HandControllerCapabilites
List of the capabilities that can be tested against.
Ogre::SceneNode * node
Some Ogre Scene Nodes.
std::vector< byte > buttonsState
An array of the buttons states.
Represent a Quaternion.
size_t AnnHandControllerID
ID of an hand controller is the index of an array. using size_t s.
size_t AnnHandControllerTypeHash
Hash of a string idientifier.
Represent an hand controller tracked by the VR system and that the user is actively using...
AnnHandControllerAxis invalidAxis
An invalid one to return a reference to if we can&#39;t return a valid axis.
A Quaternion.
uint16_t HandControllerCapabilites_t
Fix the bitflag at 16bits wide.
AnnHandControllerTypeHash controllerTypeHash
Hash of the type, see controllerTypeString.
AnnVect3 trackedAngularSpeed
Angular velocity (Euler?) vector.
Data types definition for Annwvyn.
#define AnnDllExport
Definition: systemMacro.h:24
std::vector< uint8_t > releasedButtons
Ogre::Item * model
Currently attached entity.