Annwvyn::AnnHandController Class Reference

Represent an hand controller tracked by the VR system and that the user is actively using. Contains position, orientation, buttons and analog inputs. More...

#include <AnnHandController.hpp>

Collaboration diagram for Annwvyn::AnnHandController:

Public Types

enum  AnnHandControllerSide : uint8_t { leftHandController = 0, rightHandController = 1, invalidHandController = 2 }
 Identify the controller as "left hand", "right hand" or "invalid hand". More...
 
enum  HandControllerCapabilites : HandControllerCapabilites_t {
  None = 0, RotationalTracking = 0b0000000001, PositionalTracking = 0b0000000010, AngularAccelerationTracking = 0b0000000100,
  LinearAccelerationTracking = 0b0000001000, ButtonInputs = 0b0000010000, AnalogInputs = 0b0000100000, HapticFeedback = 0b0001000000,
  DiscreteHandGestures = 0b0010000000, SkeletalFingerTracking = 0b0100000000, ProportionalFingerTrackng = 0b1000000000
}
 List of the capabilities that can be tested against. More...
 
using AnnHandControllerTypeHash = size_t
 Hash of a string idientifier. More...
 
using AnnHandControllerGestureHash = size_t
 Hash of a string identifier. More...
 
using proportionalFingerValues = std::array< float, 5 >
 Individual finger values. More...
 
using HandControllerCapabilites_t = uint16_t
 Fix the bitflag at 16bits wide. More...
 

Public Member Functions

virtual ~AnnHandController ()=default
 Destroctor. More...
 
 AnnHandController (const std::string &Type, Ogre::SceneNode *handNode, AnnHandControllerID controllerID, AnnHandControllerSide controllerSide)
 Construct a Controller object. More...
 
void _attachModelItem (Ogre::Item *handModel)
 Advanced method: Attach a 3D model to the hand. Previously attached model will be detached. More...
 
void setHandModel (const std::string &name)
 Set model by name. IF model already attached, model will be detached, and the item will be destroyed. More...
 
void detachModel ()
 Detach model without destroying it. More...
 
Ogre::Item * getHandModel () const
 Return the current model : More...
 
AnnVect3 getWorldPosition () const
 Get position in world space. More...
 
AnnQuaternion getWorldOrientation () const
 Get orientation in world space. More...
 
AnnVect3 getAngularSpeed () const
 Get tracked angular speed. More...
 
AnnVect3 getLinearSpeed () const
 Get tracked linear speed. More...
 
AnnVect3 getPointingDirection () const
 Get a vector aligned with the pointing direction. More...
 
void attachNode (Ogre::SceneNode *grabbedObject)
 Attach the node as a child to the controller node. More...
 
void setTrackedPosition (AnnVect3 position)
 Set the position of the hand. More...
 
void setTrackedOrientation (AnnQuaternion orientation)
 Set the orientation of the hand. More...
 
void setTrackedLinearSpeed (AnnVect3 v)
 Set the linear velocity of the hand. More...
 
void setTrackedAngularSpeed (AnnVect3 v)
 Set the angular velocity of the hand. More...
 
void updateVisibility () const
 Check if controller is visible or not. More...
 
bool isTracked () const
 Return true if the hand controller object has revived updates from the tracking system. More...
 
bool getButtonState (uint8_t buttonIndex)
 
size_t getNbButton () const
 Return the number of buttons. More...
 
bool hasBeenPressed (uint8_t buttonIndex)
 
bool hasBeenReleased (uint8_t buttonIndex)
 
size_t getNbAxes () const
 Return the number of analog axis this controller has. More...
 
AnnHandControllerAxisgetAxis (size_t index)
 
AnnHandControllerSide getSide () const
 Get the "hand side" of this particular controller. More...
 
std::string getTypeString () const
 For test/branching, prefer using getType(). Get the type of the controller. Can be anything. Expect stuff like "Vive Controller" or "Oculus Touch Controller". More...
 
AnnHandControllerTypeHash getType () const
 Get the hash of the type of the controller. More...
 
virtual void rumbleStart (float factor)
 Start vibrating the controller with a set amount of "strength". Result will vary between VR systems... More...
 
virtual void rumbleStop ()
 Stop vibrating, if the controller was vibrating in the first place... More...
 
HandControllerCapabilites_t getCapabilities () const
 Get the capabilities (bit test again the capability flags) More...
 
virtual std::string getCurrentGesture ()
 Get the name of the current gesture. Please prefer use the hashed version. More...
 
virtual AnnHandControllerGestureHash gestcurrentGesturesHash ()
 Get the hash of the current gesture. More...
 

Static Public Member Functions

static std::string getSideAsString (AnnHandControllerSide s)
 Get the side type as a std::string. More...
 

Protected Member Functions

std::vector< AnnHandControllerAxis > & getAxesVector ()
 Get a reference to the axes vector. More...
 
std::vector< byte > & getButtonStateVector ()
 Get a reference to the button state vector. More...
 
std::vector< uint8_t > & getPressedButtonsVector ()
 Get a reference to the pressed event vector. More...
 
std::vector< uint8_t > & getReleasedButtonsVector ()
 Get a reference to the released event vector. More...
 

Protected Attributes

HandControllerCapabilites_t capabilites
 Capabilities of this controller. More...
 
std::string controllerTypeString
 Type of the controller, Can be string like "Vive controller" or "Oculus Touch Controller". More...
 
AnnHandControllerTypeHash controllerTypeHash
 Hash of the type, see controllerTypeString. More...
 
AnnHandControllerID id
 ID of the controller, expect 1 or 2. More...
 
AnnHandControllerSide side
 Side of the controller, right hand? left hand? Who knows! More...
 
Ogre::SceneNode * node
 Some Ogre Scene Nodes. More...
 
Ogre::SceneNode * grabbed
 
Ogre::Item * model
 Currently attached entity. More...
 
bool tracked
 tracked boolean, true if controller has been updated by the engine More...
 
AnnVect3 trackedAngularSpeed
 Angular velocity (Euler?) vector. More...
 
AnnVect3 trackedLinearSpeed
 Linear velocity vector. More...
 
std::vector< AnnHandControllerAxisaxes
 Axes vector. More...
 
AnnHandControllerAxis invalidAxis
 An invalid one to return a reference to if we can't return a valid axis. More...
 
std::vector< bytebuttonsState
 An array of the buttons states. More...
 
std::vector< uint8_t > pressedButtons
 buttons that has been pressed or released More...
 
std::vector< uint8_t > releasedButtons
 
const AnnHandControllerGestureHash gestureNotAvailableHash
 The hash of the "N/A" string. More...
 

Static Protected Attributes

static constexpr const char *const gestureNotAvailableString { "N/A" }
 Permanently set to "N/A". More...
 

Friends

class AnnOgreVRRenderer
 
class AnnOgreOpenVRRenderer
 
class AnnOgreOculusRenderer
 

Detailed Description

Represent an hand controller tracked by the VR system and that the user is actively using. Contains position, orientation, buttons and analog inputs.

Definition at line 58 of file AnnHandController.hpp.

Member Typedef Documentation

◆ AnnHandControllerGestureHash

Hash of a string identifier.

Definition at line 67 of file AnnHandController.hpp.

◆ AnnHandControllerTypeHash

Hash of a string idientifier.

Definition at line 65 of file AnnHandController.hpp.

◆ HandControllerCapabilites_t

Fix the bitflag at 16bits wide.

Definition at line 78 of file AnnHandController.hpp.

◆ proportionalFingerValues

Individual finger values.

Definition at line 70 of file AnnHandController.hpp.

Member Enumeration Documentation

◆ AnnHandControllerSide

Identify the controller as "left hand", "right hand" or "invalid hand".

Enumerator
leftHandController 
rightHandController 
invalidHandController 

Definition at line 73 of file AnnHandController.hpp.

◆ HandControllerCapabilites

List of the capabilities that can be tested against.

Enumerator
None 
RotationalTracking 
PositionalTracking 
AngularAccelerationTracking 
LinearAccelerationTracking 
ButtonInputs 
AnalogInputs 
HapticFeedback 
DiscreteHandGestures 
SkeletalFingerTracking 
ProportionalFingerTrackng 

Definition at line 81 of file AnnHandController.hpp.

Constructor & Destructor Documentation

◆ ~AnnHandController()

virtual Annwvyn::AnnHandController::~AnnHandController ( )
virtualdefault

Destroctor.

◆ AnnHandController()

AnnHandController::AnnHandController ( const std::string Type,
Ogre::SceneNode *  handNode,
AnnHandControllerID  controllerID,
AnnHandControllerSide  controllerSide 
)

Construct a Controller object.

Definition at line 11 of file AnnHandController.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ _attachModelItem()

void AnnHandController::_attachModelItem ( Ogre::Item *  handModel)

Advanced method: Attach a 3D model to the hand. Previously attached model will be detached.

Definition at line 41 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ attachNode()

void AnnHandController::attachNode ( Ogre::SceneNode *  grabbedObject)

Attach the node as a child to the controller node.

Definition at line 97 of file AnnHandController.cpp.

◆ detachModel()

void AnnHandController::detachModel ( )

Detach model without destroying it.

Definition at line 61 of file AnnHandController.cpp.

◆ gestcurrentGesturesHash()

AnnHandController::AnnHandControllerGestureHash AnnHandController::gestcurrentGesturesHash ( )
virtual

Get the hash of the current gesture.

Definition at line 247 of file AnnHandController.cpp.

◆ getAngularSpeed()

AnnVect3 AnnHandController::getAngularSpeed ( ) const

Get tracked angular speed.

Definition at line 82 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getAxesVector()

std::vector< AnnHandControllerAxis > & AnnHandController::getAxesVector ( )
protected

Get a reference to the axes vector.

Definition at line 184 of file AnnHandController.cpp.

◆ getAxis()

AnnHandControllerAxis & AnnHandController::getAxis ( size_t  index)

Get the axis object for each axis

Parameters
indexIndex of the axis you need

Definition at line 168 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getButtonState()

bool AnnHandController::getButtonState ( uint8_t  buttonIndex)

Get the state of the given button

Parameters
buttonIndexindex of the button to test

Definition at line 139 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getButtonStateVector()

std::vector< byte > & AnnHandController::getButtonStateVector ( )
protected

Get a reference to the button state vector.

Definition at line 189 of file AnnHandController.cpp.

◆ getCapabilities()

AnnHandController::HandControllerCapabilites_t AnnHandController::getCapabilities ( ) const

Get the capabilities (bit test again the capability flags)

Definition at line 237 of file AnnHandController.cpp.

◆ getCurrentGesture()

std::string AnnHandController::getCurrentGesture ( )
virtual

Get the name of the current gesture. Please prefer use the hashed version.

Definition at line 242 of file AnnHandController.cpp.

◆ getHandModel()

Ogre::Item * AnnHandController::getHandModel ( ) const

Return the current model :

Definition at line 67 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getLinearSpeed()

AnnVect3 AnnHandController::getLinearSpeed ( ) const

Get tracked linear speed.

Definition at line 87 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getNbAxes()

size_t AnnHandController::getNbAxes ( ) const

Return the number of analog axis this controller has.

Definition at line 163 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getNbButton()

size_t AnnHandController::getNbButton ( ) const

Return the number of buttons.

Definition at line 144 of file AnnHandController.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPointingDirection()

AnnVect3 AnnHandController::getPointingDirection ( ) const

Get a vector aligned with the pointing direction.

Definition at line 92 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getPressedButtonsVector()

std::vector< uint8_t > & AnnHandController::getPressedButtonsVector ( )
protected

Get a reference to the pressed event vector.

Definition at line 194 of file AnnHandController.cpp.

◆ getReleasedButtonsVector()

std::vector< uint8_t > & AnnHandController::getReleasedButtonsVector ( )
protected

Get a reference to the released event vector.

Definition at line 199 of file AnnHandController.cpp.

◆ getSide()

AnnHandController::AnnHandControllerSide AnnHandController::getSide ( ) const

Get the "hand side" of this particular controller.

Definition at line 174 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getSideAsString()

std::string AnnHandController::getSideAsString ( AnnHandControllerSide  s)
inlinestatic

Get the side type as a std::string.

Definition at line 35 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getType()

AnnHandController::AnnHandControllerTypeHash AnnHandController::getType ( ) const

Get the hash of the type of the controller.

Definition at line 222 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getTypeString()

std::string AnnHandController::getTypeString ( ) const

For test/branching, prefer using getType(). Get the type of the controller. Can be anything. Expect stuff like "Vive Controller" or "Oculus Touch Controller".

Definition at line 179 of file AnnHandController.cpp.

◆ getWorldOrientation()

AnnQuaternion AnnHandController::getWorldOrientation ( ) const

Get orientation in world space.

Definition at line 77 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ getWorldPosition()

AnnVect3 AnnHandController::getWorldPosition ( ) const

Get position in world space.

Definition at line 72 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ hasBeenPressed()

bool AnnHandController::hasBeenPressed ( uint8_t  buttonIndex)

Return true if the given button has been pressed during the frame

Parameters
buttonIndexindex of the button to test

Definition at line 149 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ hasBeenReleased()

bool AnnHandController::hasBeenReleased ( uint8_t  buttonIndex)

Return false if the given button has been pressed during the frame

Parameters
buttonIndexindex of the button to test

Definition at line 156 of file AnnHandController.cpp.

Here is the caller graph for this function:

◆ isTracked()

bool AnnHandController::isTracked ( ) const

Return true if the hand controller object has revived updates from the tracking system.

Definition at line 134 of file AnnHandController.cpp.

◆ rumbleStart()

void AnnHandController::rumbleStart ( float  factor)
virtual

Start vibrating the controller with a set amount of "strength". Result will vary between VR systems...

Definition at line 227 of file AnnHandController.cpp.

◆ rumbleStop()

void AnnHandController::rumbleStop ( )
virtual

Stop vibrating, if the controller was vibrating in the first place...

Definition at line 232 of file AnnHandController.cpp.

◆ setHandModel()

void AnnHandController::setHandModel ( const std::string name)

Set model by name. IF model already attached, model will be detached, and the item will be destroyed.

Definition at line 48 of file AnnHandController.cpp.

Here is the call graph for this function:

◆ setTrackedAngularSpeed()

void AnnHandController::setTrackedAngularSpeed ( AnnVect3  v)

Set the angular velocity of the hand.

Definition at line 123 of file AnnHandController.cpp.

◆ setTrackedLinearSpeed()

void AnnHandController::setTrackedLinearSpeed ( AnnVect3  v)

Set the linear velocity of the hand.

Definition at line 117 of file AnnHandController.cpp.

◆ setTrackedOrientation()

void AnnHandController::setTrackedOrientation ( AnnQuaternion  orientation)

Set the orientation of the hand.

Definition at line 111 of file AnnHandController.cpp.

◆ setTrackedPosition()

void AnnHandController::setTrackedPosition ( AnnVect3  position)

Set the position of the hand.

Definition at line 105 of file AnnHandController.cpp.

◆ updateVisibility()

void AnnHandController::updateVisibility ( ) const

Check if controller is visible or not.

Definition at line 129 of file AnnHandController.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ AnnOgreOculusRenderer

friend class AnnOgreOculusRenderer
friend

Definition at line 201 of file AnnHandController.hpp.

◆ AnnOgreOpenVRRenderer

friend class AnnOgreOpenVRRenderer
friend

Definition at line 200 of file AnnHandController.hpp.

◆ AnnOgreVRRenderer

friend class AnnOgreVRRenderer
friend

Definition at line 199 of file AnnHandController.hpp.

Member Data Documentation

◆ axes

std::vector<AnnHandControllerAxis> Annwvyn::AnnHandController::axes
protected

Axes vector.

Definition at line 243 of file AnnHandController.hpp.

◆ buttonsState

std::vector<byte> Annwvyn::AnnHandController::buttonsState
protected

An array of the buttons states.

Definition at line 249 of file AnnHandController.hpp.

◆ capabilites

HandControllerCapabilites_t Annwvyn::AnnHandController::capabilites
protected

Capabilities of this controller.

Definition at line 197 of file AnnHandController.hpp.

◆ controllerTypeHash

AnnHandControllerTypeHash Annwvyn::AnnHandController::controllerTypeHash
protected

Hash of the type, see controllerTypeString.

Definition at line 207 of file AnnHandController.hpp.

◆ controllerTypeString

std::string Annwvyn::AnnHandController::controllerTypeString
protected

Type of the controller, Can be string like "Vive controller" or "Oculus Touch Controller".

Definition at line 204 of file AnnHandController.hpp.

◆ gestureNotAvailableHash

const AnnHandControllerGestureHash Annwvyn::AnnHandController::gestureNotAvailableHash
protected

The hash of the "N/A" string.

Definition at line 255 of file AnnHandController.hpp.

◆ gestureNotAvailableString

constexpr const char* const Annwvyn::AnnHandController::gestureNotAvailableString { "N/A" }
staticprotected

Permanently set to "N/A".

Definition at line 258 of file AnnHandController.hpp.

◆ grabbed

Ogre::SceneNode * Annwvyn::AnnHandController::grabbed
protected

Definition at line 228 of file AnnHandController.hpp.

◆ id

AnnHandControllerID Annwvyn::AnnHandController::id
protected

ID of the controller, expect 1 or 2.

Definition at line 222 of file AnnHandController.hpp.

◆ invalidAxis

AnnHandControllerAxis Annwvyn::AnnHandController::invalidAxis
protected

An invalid one to return a reference to if we can't return a valid axis.

Definition at line 246 of file AnnHandController.hpp.

◆ model

Ogre::Item* Annwvyn::AnnHandController::model
protected

Currently attached entity.

Definition at line 231 of file AnnHandController.hpp.

◆ node

Ogre::SceneNode* Annwvyn::AnnHandController::node
protected

Some Ogre Scene Nodes.

Definition at line 228 of file AnnHandController.hpp.

◆ pressedButtons

std::vector<uint8_t> Annwvyn::AnnHandController::pressedButtons
protected

buttons that has been pressed or released

Definition at line 252 of file AnnHandController.hpp.

◆ releasedButtons

std::vector<uint8_t> Annwvyn::AnnHandController::releasedButtons
protected

Definition at line 252 of file AnnHandController.hpp.

◆ side

AnnHandControllerSide Annwvyn::AnnHandController::side
protected

Side of the controller, right hand? left hand? Who knows!

Definition at line 225 of file AnnHandController.hpp.

◆ tracked

bool Annwvyn::AnnHandController::tracked
protected

tracked boolean, true if controller has been updated by the engine

Definition at line 234 of file AnnHandController.hpp.

◆ trackedAngularSpeed

AnnVect3 Annwvyn::AnnHandController::trackedAngularSpeed
protected

Angular velocity (Euler?) vector.

Definition at line 237 of file AnnHandController.hpp.

◆ trackedLinearSpeed

AnnVect3 Annwvyn::AnnHandController::trackedLinearSpeed
protected

Linear velocity vector.

Definition at line 240 of file AnnHandController.hpp.


The documentation for this class was generated from the following files: