Torque3D Documentation / _generateds / leapMotionData.h

leapMotionData.h

Engine/source/platform/input/leapMotion/leapMotionData.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _LEAPMOTIONDATA_H_
 25#define _LEAPMOTIONDATA_H_
 26
 27#include "console/consoleTypes.h"
 28#include "math/mMathFn.h"
 29#include "math/mMatrix.h"
 30#include "math/mQuat.h"
 31#include "platform/input/leapMotion/leapMotionConstants.h"
 32#include "Leap.h"
 33
 34struct LeapMotionDeviceData
 35{
 36   enum DataDifferences {
 37      DIFF_NONE            = 0,
 38      DIFF_HANDROTAXISX    = (1<<1),
 39      DIFF_HANDROTAXISY    = (1<<2),
 40
 41      DIFF_HANDROTAXIS = (DIFF_HANDROTAXISX | DIFF_HANDROTAXISY),
 42   };
 43
 44   enum MetaDataDifferences {
 45      METADIFF_NONE              = 0,
 46      METADIFF_FRAME_VALID_DATA  = (1<<0),
 47   };
 48
 49protected:
 50   void processPersistentHands(const Leap::HandList& hands, bool keepPointableIndexPersistent, LeapMotionDeviceData* prevData);
 51   void processHands(const Leap::HandList& hands);
 52   void processHand(const Leap::Hand& hand, U32 handIndex, bool keepPointableIndexPersistent, LeapMotionDeviceData* prevData);
 53
 54   void processPersistentHandPointables(const Leap::PointableList& pointables, U32 handIndex, LeapMotionDeviceData* prevData);
 55   void processHandPointables(const Leap::PointableList& pointables, U32 handIndex);
 56   void processHandPointable(const Leap::Pointable& pointable, U32 handIndex, U32 handPointableIndex);
 57
 58public:
 59   bool mDataSet;
 60
 61   // Frame Data Set
 62   bool mIsValid;
 63   bool mHasTrackingData;
 64
 65   // Hand Data Set
 66   bool mHandValid[LeapMotionConstants::MaxHands];
 67   S32 mHandID[LeapMotionConstants::MaxHands];
 68
 69   // Hand Position
 70   F32 mHandRawPos[LeapMotionConstants::MaxHands][3];
 71   S32 mHandPos[LeapMotionConstants::MaxHands][3];
 72   Point3F mHandPosPoint[LeapMotionConstants::MaxHands];
 73
 74   // Hand Rotation
 75   MatrixF mHandRot[LeapMotionConstants::MaxHands];
 76   QuatF mHandRotQuat[LeapMotionConstants::MaxHands];
 77
 78   // Hand rotation as axis x, y
 79   F32 mHandRotAxis[2];
 80
 81   // Pointable Data Set
 82   bool mPointableValid[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 83   S32 mPointableID[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 84   F32 mPointableLength[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 85   F32 mPointableWidth[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 86
 87   // Pointable Position
 88   F32 mPointableRawPos[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand][3];
 89   S32 mPointablePos[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand][3];
 90   Point3F mPointablePosPoint[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 91
 92   // Pointable Rotation
 93   MatrixF mPointableRot[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 94   QuatF mPointableRotQuat[LeapMotionConstants::MaxHands][LeapMotionConstants::MaxPointablesPerHand];
 95
 96   // Sequence number from device
 97   U64 mSequenceNum;
 98
 99   LeapMotionDeviceData();
100
101   /// Reset device data
102   void reset();
103
104   /// Set data based on Leap Motion device data
105   void setData(const Leap::Frame& frame, LeapMotionDeviceData* prevData, bool keepHandIndexPersistent, bool keepPointableIndexPersistent, const F32& maxHandAxisRadius);
106
107   /// Compare this data and given and return differences
108   U32 compare(LeapMotionDeviceData* other);
109
110   /// Compare meta data between this and given and return differences
111   U32 compareMeta(LeapMotionDeviceData* other);
112};
113
114#endif   // _LEAPMOTIONDATA_H_
115