本文整理汇总了C++中leap::Hand::isLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ Hand::isLeft方法的具体用法?C++ Hand::isLeft怎么用?C++ Hand::isLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Hand
的用法示例。
在下文中一共展示了Hand::isLeft方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFrame
void LeapMotionListener::onFrame(const Leap::Controller & controller)
{
const Leap::Frame frame = controller.frame();
Leap::HandList hands = frame.hands();
for (Leap::HandList::const_iterator hl = hands.begin(); hl!=hands.end();hl++)
{
const Leap::Hand hand = *hl;
QString handType = hand.isLeft() ? "Left hand" : "Right hand";
qDebug()<<handType<<"id: "<<hand.id()<<"palm position: "
<<hand.palmPosition().x<<hand.palmPosition().y<<hand.palmPosition().z;
QFile f("share.dat");
if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&f);
out<<QString("%1 %2 %3").arg(hand.palmPosition().x)
.arg(hand.palmPosition().y).arg(hand.palmPosition().z);
f.close();
}
}
示例2: InterfaceEventTick
//Main Event driven tick
void ULeapController::InterfaceEventTick(float DeltaTime)
{
//This is our tick event that is forwarded from the delegate, check validity
if (!_private->interfaceDelegate) return;
//Pointers
Leap::Frame frame = _private->leap.frame();
Leap::Frame pastFrame = _private->leap.frame(1);
//-Hands-
//Hand Count
int handCount = frame.hands().count();
if (_private->pastState.handCount != handCount)
{
ILeapEventInterface::Execute_HandCountChanged(_private->interfaceDelegate, handCount);
//Zero our input mapping orientations (akin to letting go of a joystick)
if (handCount == 0)
{
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, 0, 0, 0);
}
}
//Cycle through each hand
for (int i = 0; i < handCount; i++)
{
Leap::Hand hand = frame.hands()[i];
LeapHandStateData pastHandState = _private->pastState.stateForId(hand.id()); //we use a custom class to hold reliable state tracking based on id's
//Make a ULeapHand
if (_private->eventHand == NULL)
{
_private->eventHand = NewObject<ULeapHand>(this);
_private->eventHand->SetFlags(RF_RootSet);
}
_private->eventHand->setHand(hand);
//Emit hand
ILeapEventInterface::Execute_LeapHandMoved(_private->interfaceDelegate, _private->eventHand);
//Left/Right hand forwarding
if (hand.isRight())
{
ILeapEventInterface::Execute_LeapRightHandMoved(_private->interfaceDelegate, _private->eventHand);
//Input Mapping
FRotator palmOrientation = _private->eventHand->PalmOrientation;
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, palmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, palmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, palmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
} else if (hand.isLeft())
{
ILeapEventInterface::Execute_LeapLeftHandMoved(_private->interfaceDelegate, _private->eventHand);
//Input Mapping
FRotator palmOrientation = _private->eventHand->PalmOrientation;
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, palmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, palmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, palmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
}
//Grabbing
float grabStrength = hand.grabStrength();
bool grabbed = handClosed(grabStrength);
if (grabbed)
ILeapEventInterface::Execute_LeapHandGrabbing(_private->interfaceDelegate, grabStrength, _private->eventHand);
if (grabbed && !pastHandState.grabbed)
{
ILeapEventInterface::Execute_LeapHandGrabbed(_private->interfaceDelegate, grabStrength, _private->eventHand);
//input mapping
if (_private->eventHand->HandType == LeapHandType::HAND_LEFT)
EmitKeyDownEventForKey(EKeysLeap::LeapLeftGrab, 0, 0);
else
EmitKeyDownEventForKey(EKeysLeap::LeapRightGrab, 0, 0);
}else if (!grabbed && pastHandState.grabbed)
{
ILeapEventInterface::Execute_LeapHandReleased(_private->interfaceDelegate, grabStrength, _private->eventHand);
//input mapping
if (_private->eventHand->HandType == LeapHandType::HAND_LEFT)
EmitKeyUpEventForKey(EKeysLeap::LeapLeftGrab, 0, 0);
else
EmitKeyUpEventForKey(EKeysLeap::LeapRightGrab, 0, 0);
}
//Pinching
float pinchStrength = hand.pinchStrength();
bool pinched = handPinched(pinchStrength);
//While grabbing disable pinching detection, this helps to reduce spam as pose confidence plummets
if (grabbed) pinched = pastHandState.pinched;
//.........这里部分代码省略.........
示例3: ParseEvents
void FLeapMotionInputDevice::ParseEvents()
{
//Optimization: If we don't have any delegates, skip
if (EventDelegates.Num() == 0)
{
return;
}
//Pointers
Leap::Frame Frame = ControllerData.LeapController.frame();
Leap::Frame PastFrame = ControllerData.LeapController.frame(1);
//Calculate HMD Timewarp if valid
if (GEngine->HMDDevice.IsValid() && ControllerData.bTimeWarpEnabled) {
LeapHMDSnapshot ThenSnapshot = HMDSamples->HMDSampleClosestToTimestamp(Frame.timestamp());
LeapHMDSnapshot NowSnapShot = HMDSamples->CurrentHMDSample();
LeapHMDSnapshot HistorySnapshot = HMDSamples->LastHMDSample(); //reduce jitter
//ControllerData.TimeWarpSnapshot = NowSnapShot.Difference(ThenSnapshot, ControllerData.TimeWarpFactor);// * ControllerData.TimeWarpFactor;
FQuat WarpQuat = NowSnapShot.Orientation;//FQuat::Slerp(NowSnapShot.Orientation, HistorySnapshot.Orientation, ControllerData.TimeWarpTween);
FQuat ThenTweened = FQuat::Slerp(ThenSnapshot.Orientation, HistorySnapshot.Orientation, ControllerData.TimeWarpTween);
ControllerData.TimeWarpSnapshot.Orientation = (WarpQuat.Inverse() * ControllerData.TimeWarpFactor) * ThenTweened;
ControllerData.TimeWarpAmountMs = (ControllerData.TimeWarpSnapshot.Timestamp) / 1000.f;
}
//-Hands-
//Hand Count
int HandCount = Frame.hands().count();
if (PastState->HandCount != HandCount)
{
CallFunctionOnDelegates([&](UObject* EventDelegate)
{
ILeapEventInterface::Execute_HandCountChanged(EventDelegate, HandCount);
});
//Zero our input mapping orientations (akin to letting go of a joystick)
if (HandCount == 0)
{
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, 0, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, 0, 0, 0);
}
}
//Cycle through each hand
for (int i = 0; i < HandCount; i++)
{
Leap::Hand Hand = Frame.hands()[i];
LeapHandStateData PastHandState = PastState->StateForId(Hand.id()); //we use a custom class to hold reliable state tracking based on id's
//Make a ULeapHand
if (PEventHand == nullptr)
{
PEventHand = NewObject<ULeapHand>();
PEventHand->AddToRoot();
}
PEventHand->SetHand(Hand);
//Emit hand
CallFunctionOnDelegates([&](UObject* EventDelegate)
{
ILeapEventInterface::Execute_LeapHandMoved(EventDelegate, PEventHand);
});
//Left/Right hand forwarding
if (Hand.isRight())
{
CallFunctionOnDelegates([&](UObject* EventDelegate)
{
ILeapEventInterface::Execute_LeapRightHandMoved(EventDelegate, PEventHand);
});
//Input Mapping
FRotator PalmOrientation = PEventHand->PalmOrientation;
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmPitch, PalmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmYaw, PalmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapRightPalmRoll, PalmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
}
else if (Hand.isLeft())
{
CallFunctionOnDelegates([&](UObject* EventDelegate)
{
ILeapEventInterface::Execute_LeapLeftHandMoved(EventDelegate, PEventHand);
});
//Input Mapping
FRotator PalmOrientation = PEventHand->PalmOrientation;
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmPitch, PalmOrientation.Pitch * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmYaw, PalmOrientation.Yaw * LEAP_IM_SCALE, 0, 0);
EmitAnalogInputEventForKey(EKeysLeap::LeapLeftPalmRoll, PalmOrientation.Roll * LEAP_IM_SCALE, 0, 0);
}
//.........这里部分代码省略.........
示例4: onFrame
void SampleListener::onFrame(const Leap::Controller& controller) {
// Get the most recent frame and report some basic information
const Leap::Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", extended fingers: " << frame.fingers().extended().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl;
Leap::HandList hands = frame.hands();
for (Leap::HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Leap::Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
std::cout << std::string(2, ' ') << handType << ", id: " << hand.id()
<< ", palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Leap::Vector normal = hand.palmNormal();
const Leap::Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(2, ' ') << "pitch: " << direction.pitch() * Leap::RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * Leap::RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * Leap::RAD_TO_DEG << " degrees" << std::endl;
// Get the Arm bone
Leap::Arm arm = hand.arm();
std::cout << std::string(2, ' ') << "Arm direction: " << arm.direction()
<< " wrist position: " << arm.wristPosition()
<< " elbow position: " << arm.elbowPosition() << std::endl;
// Get fingers
const Leap::FingerList fingers = hand.fingers();
for (Leap::FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Leap::Finger finger = *fl;
std::cout << std::string(4, ' ') << fingerNames[finger.type()]
<< " finger, id: " << finger.id()
<< ", length: " << finger.length()
<< "mm, width: " << finger.width() << std::endl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Leap::Bone::Type boneType = static_cast<Leap::Bone::Type>(b);
Leap::Bone bone = finger.bone(boneType);
std::cout << std::string(6, ' ') << boneNames[boneType]
<< " bone, start: " << bone.prevJoint()
<< ", end: " << bone.nextJoint()
<< ", direction: " << bone.direction() << std::endl;
}
}
}
// Get tools
const Leap::ToolList tools = frame.tools();
for (Leap::ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Leap::Tool tool = *tl;
std::cout << std::string(2, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
}
// Get gestures
const Leap::GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Leap::Gesture gesture = gestures[g];
switch (gesture.type()) {
case Leap::Gesture::TYPE_CIRCLE:
{
Leap::CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= Leap::PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Leap::Gesture::STATE_START) {
Leap::CircleGesture previousUpdate = Leap::CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * Leap::PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * Leap::RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Leap::Gesture::TYPE_SWIPE:
{
Leap::SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
//.........这里部分代码省略.........