Bone::Bone( const Vector4 &position, const _NUI_SKELETON_BONE_ORIENTATION &bone ) { mAbsRotQuat = toQuatf( bone.absoluteRotation.rotationQuaternion ); mAbsRotMat = toMatrix44f( bone.absoluteRotation.rotationMatrix ); mJointEnd = bone.endJoint; mJointStart = bone.startJoint; mPosition = toVec3f( position ); mRotQuat = toQuatf( bone.hierarchicalRotation.rotationQuaternion ); mRotMat = toMatrix44f( bone.hierarchicalRotation.rotationMatrix ); }
void Listener::onFrame( const Leap::Controller& controller ) { lock_guard<mutex> lock( *mMutex ); if ( !mNewFrame ) { const Leap::Frame& controllerFrame = controller.frame(); const Leap::HandList& hands = controllerFrame.hands(); HandMap handMap; for ( const Leap::Hand& hand : hands ) { FingerMap fingerMap; ToolMap toolMap; const Leap::PointableList& pointables = hand.pointables(); for ( const Leap::Pointable& pt : pointables ) { if ( pt.isValid() ) { Pointable pointable( pt ); if ( pt.isFinger() ) { fingerMap[ pt.id() ] = Finger( pointable ); } else if ( pt.isTool() ) { toolMap[ pt.id() ] = Tool( pointable ); } } } float rotAngle = (float)hand.rotationAngle( mFirstFrame.mFrame ); Vec3f rotAxis = toVec3f( hand.rotationAxis( mFirstFrame.mFrame ) ); Matrix44f rotMatrix = toMatrix44f( hand.rotationMatrix( mFirstFrame.mFrame ) ); float scale = (float)hand.scaleFactor( mFirstFrame.mFrame ); Vec3f translation = toVec3f( hand.translation( mFirstFrame.mFrame ) ); handMap[ hand.id() ] = Hand( hand, fingerMap, toolMap, rotAngle, rotAxis, rotMatrix, scale, translation ); } mFrame = Frame( controllerFrame, handMap ); if ( !mFirstFrameReceived ) { mFirstFrame = Frame( controllerFrame, handMap ); mFirstFrameReceived = true; } mNewFrame = true; } }
Matrix44f Hand::getRotationMatrix( const Frame& frame ) const { return toMatrix44f( mHand.rotationMatrix( frame.mFrame ) ); }