本文整理汇总了C++中leap::Hand类的典型用法代码示例。如果您正苦于以下问题:C++ Hand类的具体用法?C++ Hand怎么用?C++ Hand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: drawHands
void HandController::drawHands() {
glPushMatrix();
glTranslatef(translation_);
glScalef(scale_, scale_, scale_);
Leap::Frame frame = controller_.frame();
for (int h = 0; h < frame.hands().count(); ++h) {
Leap::Hand hand = frame.hands()[h];
for (int f = 0; f < hand.fingers().count(); ++f) {
Leap::Finger finger = hand.fingers()[f];
// Draw first joint inside hand.
Leap::Bone mcp = finger.bone(Leap::Bone::Type::TYPE_METACARPAL);
drawJoint(mcp.prevJoint());
for (int b = 0; b < 4; ++b) {
Leap::Bone bone = finger.bone(static_cast<Leap::Bone::Type>(b));
drawJoint(bone.nextJoint());
drawBone(bone);
}
}
}
glPopMatrix();
}
开发者ID:gauntalt,项目名称:MagneticMesh,代码行数:26,代码来源:HandController.cpp
示例2: onFrame
void Quickstart::onFrame(const Leap::Controller &controller) {
// returns the most recent frame. older frames can be accessed by passing in
// a "history" parameter to retrieve an older frame, up to about 60
// (exact number subject to change)
const Leap::Frame frame = controller.frame();
// do nothing unless hands are detected
if (frame.hands().empty())
return;
// first detected hand
const Leap::Hand firstHand = frame.hands()[0];
// first pointable object (finger or tool)
const Leap::PointableList pointables = firstHand.pointables();
if (pointables.empty()) return;
const Leap::Pointable firstPointable = pointables[0];
// print velocity on the X axis
cout << "Pointable X velocity: " << firstPointable.tipVelocity()[0] << endl;
const Leap::FingerList fingers = firstHand.fingers();
if (fingers.empty()) return;
for (int i = 0; i < fingers.count(); i++) {
const Leap::Finger finger = fingers[i];
std::cout << "Detected finger " << i << " at position (" <<
finger.tipPosition().x << ", " <<
finger.tipPosition().y << ", " <<
finger.tipPosition().z << ")" << std::endl;
}
}
开发者ID:revmischa,项目名称:leapbook,代码行数:32,代码来源:quickstart.cpp
示例3: modeStreamDataToSL
// This experimental mode sends chat messages into SL on a back channel for LSL scripts
// to intercept with a listen() event. This is experimental and not sustainable for
// a production feature ... many avatars using this would flood the chat system and
// hurt server performance. Depending on how useful this proves to be, a better
// mechanism should be designed to stream data from the viewer into SL scripts.
void LLLMImpl::modeStreamDataToSL(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1 &&
mChatMsgTimer.checkExpirationAndReset(LLLEAP_CHAT_MSG_INTERVAL))
{
// Get the first (and only) hand
Leap::Hand hand = hands[0];
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
// Chat message looks like "/2343 LM1,<palm pos>,<palm normal>,<sphere center>,<sphere radius>"
LLVector3 vec;
std::stringstream status_chat_msg;
status_chat_msg << "/2343 LM,";
status_chat_msg << "<" << palm_pos.x << "," << palm_pos.y << "," << palm_pos.z << ">,";
status_chat_msg << "<" << palm_normal.x << "," << palm_normal.y << "," << palm_normal.z << ">,";
status_chat_msg << "<" << ball_center.x << "," << ball_center.y << "," << ball_center.z << ">," << ball_radius;
FSNearbyChat::instance().sendChatFromViewer(status_chat_msg.str(), CHAT_TYPE_SHOUT, FALSE);
}
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:31,代码来源:llleapmotioncontroller.cpp
示例4: evaluate
/**
Returns
1 if abs(xvel) <= 1/2 abs(yvel)
0 otherwise
*/
virtual int evaluate(const Leap::Frame &frame,
const std::string& nodeid) {
Leap::Hand h = frame.hand(0);
if (h.isValid()) {
Leap::Vector vel = h.palmVelocity();
return (abs(vel.x) <= 0.5 * abs(vel.y))
? 1 : 0;
} else
return 0;
}
开发者ID:pjromano,项目名称:zoom-ui,代码行数:15,代码来源:static.cpp
示例5: get_finger_positions
fdata get_finger_positions()
{
Leap::Frame frame = control.frame();
Leap::FingerList fingers = frame.fingers();
Leap::ToolList tools = frame.tools();
Leap::HandList hands = frame.hands();
//std::vector<std::pair<cl_float4, int>> positions;
fdata hand_data;
int p = 0;
for(int i=0; i<40; i++)
{
hand_data.fingers[i] = 0.0f;
}
///will explode if more than 2
for(int i=0; i<hands.count(); i++)
{
const Leap::Hand hand = hands[i];
Leap::FingerList h_fingers = hand.fingers();
float grab_strength = hand.grabStrength();
hand_data.grab_confidence[i] = grab_strength;
for(int j=0; j<h_fingers.count(); j++)
{
const Leap::Finger finger = h_fingers[j];
float mfingerposx = finger.tipPosition().x;
float mfingerposy = finger.tipPosition().y;
float mfingerposz = finger.tipPosition().z;
//cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};
//cl_float4 ps = {mfingerposx, mfingerposy, mfingerposz, 0.0f};
int id = finger.id();
hand_data.fingers[p++] = mfingerposx;
hand_data.fingers[p++] = mfingerposy;
hand_data.fingers[p++] = mfingerposz;
hand_data.fingers[p++] = 0.0f;
//positions.push_back(std::pair<cl_float4, int>(ps, id));
}
}
return hand_data;
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:54,代码来源:main.cpp
示例6: handForId
bool handForId(int32 checkId, Leap::HandList hands, Leap::Hand& returnHand)
{
for (int i = 0; i < hands.count(); i++)
{
Leap::Hand hand = hands[i];
if (checkId == hand.id()){
returnHand = hand;
return true;
}
}
return false;
}
开发者ID:77stone,项目名称:leap-ue4,代码行数:12,代码来源:LeapController.cpp
示例7: HandForId
bool FLeapMotionInputDevice::HandForId(int32 CheckId, Leap::HandList Hands, Leap::Hand& ReturnHand)
{
for (int i = 0; i < Hands.count(); i++)
{
Leap::Hand Hand = Hands[i];
if (CheckId == Hand.id())
{
ReturnHand = Hand;
return true;
}
}
return false;
}
开发者ID:7hny,项目名称:leap-ue4,代码行数:13,代码来源:FLeapMotionInputDevice.cpp
示例8: frame
virtual void onFrame (const Leap::Controller&)
{
const Leap::Frame frame(m_Controller.frame(0));
const Leap::Hand hand(frame.hands().rightmost());
if (!hand.isValid())
{
m_LastNormalizedPos.reset();
return;
}
const Leap::Vector pos(hand.palmPosition());
m_LastNormalizedPos = frame.interactionBox().normalizePoint(pos);
}
开发者ID:IrmatDen,项目名称:sfge,代码行数:13,代码来源:controller_leap_metalpad.cpp
示例9:
void jester::LeapMotionImpl::processHand(Leap::Hand hand, LeapHand whichHand) {
Bone::JointId toSet = (whichHand == LeapHand::LEFT ? Bone::JointId::WRIST_L : Bone::JointId::WRIST_R);
Bone::BoneId firstFinger = (whichHand == LeapHand::LEFT ? Bone::BoneId::PHALANX_L_1 : Bone::BoneId::PHALANX_R_1);
JointFusionData wristData;
wristData.confidence = LeapConfidence;
wristData.position = glm::vec3(hand.palmPosition()[0] / LeapMeasurmentScalingFactor,
hand.palmPosition()[1] / LeapMeasurmentScalingFactor,
hand.palmPosition()[2] / LeapMeasurmentScalingFactor);
wristData.id = toSet;
kJointData.insert(std::pair<Bone::JointId, JointFusionData>(toSet, wristData));
processFingers(hand, firstFinger, whichHand);
}
开发者ID:kevinschapansky,项目名称:Jester,代码行数:15,代码来源:LeapMotionImpl.cpp
示例10: eventShake
int StateKen::eventShake(StateContext& context, const Leap::Controller& controller)
{
std::cout << "けん\n" << std::endl;
const Leap::Frame frame = controller.frame();
const Leap::Hand hand = frame.hands()[0];
Leap::Vector position = hand.palmPosition();
JankenApp::getInstance()->setShakeStartPosition(position);
int ret = context.changeState(StatePon::getInstance());
return ret;
}
开发者ID:haraki,项目名称:ConsoleJanken-for-Windows,代码行数:15,代码来源:StateKen.cpp
示例11: memset
void eleap::eleap_t::impl_t::onFrame(const Leap::Controller& controller)
{
const Leap::Frame frame = controller.frame();
if (frame.isValid())
{
// send the known hands in this frame, this will handle hands coming and going
const Leap::HandList hands = frame.hands();
{
unsigned long long time_encoded = (0&0xffffffff)<<8 | (DATA_KNOWN_HANDS&0xff);
float *f;
unsigned char *dp;
piw::data_nb_t d = ctx_.allocate_host(time_encoded,INT32_MAX,INT32_MIN,0,BCTVTYPE_INT,sizeof(int32_t),&dp,hands.count(),&f);
memset(f,0,hands.count()*sizeof(int32_t));
*dp = 0;
for(int i = 0; i < hands.count(); ++i)
{
const Leap::Hand hand = hands[i];
if(hand.isValid() && hand.fingers().count() > 1)
{
((int32_t *)f)[i] = hand.id();
}
}
enqueue_fast(d,1);
}
// handle the actual data for the detected hands
for(int i = 0; i < hands.count(); ++i)
{
const Leap::Hand hand = hands[i];
if(hand.isValid() && hand.fingers().count() > 1)
{
unsigned long long time_encoded = (hand.id()&0xffffffff)<<8 | (DATA_PALM_POSITION&0xff);
const Leap::Vector palm_pos = hand.palmPosition();
float *f;
unsigned char *dp;
piw::data_nb_t d = ctx_.allocate_host(time_encoded,600,-600,0,BCTVTYPE_FLOAT,sizeof(float),&dp,3,&f);
memset(f,0,3*sizeof(float));
*dp = 0;
f[0] = piw::normalise(600,-600,0,palm_pos.x);
f[1] = piw::normalise(600,-600,0,palm_pos.y);
f[2] = piw::normalise(600,-600,0,palm_pos.z);
enqueue_fast(d,1);
}
}
}
}
开发者ID:Eigenlabs,项目名称:EigenD-Contrib,代码行数:52,代码来源:eleap.cpp
示例12: convertHandRotation
void convertHandRotation(const Leap::Hand& hand, MatrixF& outRotation)
{
// We need to convert from Motion coordinates to
// Torque coordinates. The conversion is:
//
// Motion Torque
// a b c a b c a -c b
// d e f --> -g -h -i --> -g i -h
// g h i d e f d -f e
const Leap::Vector& handToFingers = hand.direction();
Leap::Vector handFront = -handToFingers;
const Leap::Vector& handDown = hand.palmNormal();
Leap::Vector handUp = -handDown;
Leap::Vector handRight = handUp.cross(handFront);
outRotation.setColumn(0, Point4F( handRight.x, -handRight.z, handRight.y, 0.0f));
outRotation.setColumn(1, Point4F( -handFront.x, handFront.z, -handFront.y, 0.0f));
outRotation.setColumn(2, Point4F( handUp.x, -handUp.z, handUp.y, 0.0f));
outRotation.setPosition(Point3F::Zero);
}
开发者ID:03050903,项目名称:Torque3D,代码行数:20,代码来源:leapMotionUtil.cpp
示例13: onFrame
void LeapListener::onFrame(const Controller& controller) {
const Frame frame = controller.frame();
static int64_t lastFrameID = 0;
if(frame.id() < lastFrameID+10)
return;
Leap::HandList hands = frame.hands();
Leap::Hand hand = hands[0];
if(hand.isValid()) {
float pitch = hand.direction().pitch();
float yaw = hand.direction().yaw();
float roll = hand.palmNormal().roll();
float height = hand.palmPosition().y;
std::cout << "Pitch: " << RAD_TO_DEG*pitch << " Yaw: " << RAD_TO_DEG*yaw << " Roll: " << RAD_TO_DEG*roll << " Height: " << height << " Frame: " << frame.id() << std::endl;
// switch(gest.type()) {
// case Gesture::TYPE_CIRCLE:
// std::cout << "Takeoff" << std::endl;
// if (jakopter_takeoff() < 0)
// return;
// break;
// case Gesture::TYPE_SWIPE:
// std::cout << "Land" << std::endl;
// if (jakopter_land() < 0)
// return;
// break;
// default:
// break;
// }
char c = 's';
if (height > 300)
c = 'u';
else if(height < 75)
c = 'k';
else if (height < 150)
c = 'd';
if (roll > 0.7)
c = 'l';
else if (roll < -0.7)
c = 'r';
if (pitch > 0.7)
c = 'b';
else if (pitch < -0.7)
c = 'f';
FILE *cmd = fopen(CMDFILENAME,"w");
fprintf(cmd, "%c\n", c);
fclose(cmd);
}
lastFrameID = frame.id();
}
开发者ID:Drone2,项目名称:utils,代码行数:60,代码来源:leap.cpp
示例14: recognizedControls
void BallGesture::recognizedControls(const Leap::Controller &controller, std::vector<ControlPtr> &controls) {
Leap::Frame frame = controller.frame();
// hands detected?
if (frame.hands().isEmpty())
return;
for (int i = 0; i < frame.hands().count(); i++) {
// gonna assume the user only has two hands. sometimes leap thinks otherwise.
if (i > 1) break;
Leap::Hand hand = frame.hands()[i];
double radius = hand.sphereRadius(); // in mm
if (! radius)
continue;
BallRadiusPtr bc = make_shared<BallRadius>(radius, i);
ControlPtr cptr = dynamic_pointer_cast<Control>(bc);
controls.push_back(cptr);
}
}
开发者ID:SteveClement,项目名称:leapmidi,代码行数:23,代码来源:BallGesture.cpp
示例15: leapMenuClosed
void MenuController::leapMenuClosed(const Leap::Controller& controller, const Leap::Frame& frame)
{
Leap::GestureList gestures = frame.gestures();
for (const Leap::Gesture& g : gestures) {
if (g.type() == Leap::Gesture::TYPE_CIRCLE) {
Leap::CircleGesture circle(g);
bool xyPlane = abs(circle.normal().dot(Leap::Vector(0, 0, 1))) > 0.8f;
if (circle.progress() > 1.0f && xyPlane && circle.radius() > 35.0f) {
Leap::Hand hand = circle.hands().frontmost();
Leap::FingerList fingers = hand.fingers();
if (fingers[1].isValid()) {
pointer_ = fingers[1];
} else if (fingers[2].isValid()) {
pointer_ = fingers[2];
}
bool main = pointer_.isValid() && fingers.extended().count() <= 2;
bool secondary = fingers[Leap::Finger::TYPE_INDEX].isExtended() &&
fingers[Leap::Finger::TYPE_THUMB].isExtended() &&
fingers[Leap::Finger::TYPE_MIDDLE].isExtended() && fingers.extended().count() == 3;
if (main) {
leap_state_ = LeapState::triggered_main;
} else if (secondary && MainController::getInstance().focusLayer() && MainController::getInstance().focusLayer()->contextMenu()) {
leap_state_ = LeapState::triggered_context;
}
}
}
}
}
开发者ID:joemasterjohn,项目名称:medleap,代码行数:36,代码来源:MenuController.cpp
示例16: modeDumpDebugInfo
// This controller mode just dumps out a bunch of the Leap Motion device data, which can then be
// analyzed for other use.
void LLLMImpl::modeDumpDebugInfo(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
if (num_fingers >= 1)
{ // Calculate the hand's average finger tip position
Leap::Vector pos(0, 0, 0);
Leap::Vector direction(0, 0, 0);
for (size_t i = 0; i < num_fingers; ++i)
{
Leap::Finger finger = finger_list[i];
pos += finger.tipPosition();
direction += finger.direction();
// Lots of log spam
LL_INFOS("LeapMotion") << "Finger " << i << " string is " << finger.toString() << LL_ENDL;
}
pos = Leap::Vector(pos.x/num_fingers, pos.y/num_fingers, pos.z/num_fingers);
direction = Leap::Vector(direction.x/num_fingers, direction.y/num_fingers, direction.z/num_fingers);
LL_INFOS("LeapMotion") << "Hand has " << num_fingers << " fingers with average tip position"
<< " (" << pos.x << ", " << pos.y << ", " << pos.z << ")"
<< " direction (" << direction.x << ", " << direction.y << ", " << direction.z << ")"
<< LL_ENDL;
}
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
LL_INFOS("LeapMotion") << "Palm pos " << palm_pos.x
<< ", " << palm_pos.y
<< ", " << palm_pos.z
<< ". Normal: " << palm_normal.x
<< ", " << palm_normal.y
<< ", " << palm_normal.z
<< LL_ENDL;
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
LL_INFOS("LeapMotion") << "Ball pos " << ball_center.x
<< ", " << ball_center.y
<< ", " << ball_center.z
<< ", radius " << ball_radius
<< LL_ENDL;
} // dump_out_data
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:56,代码来源:llleapmotioncontroller.cpp
示例17: 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();
}
}
开发者ID:crf1111,项目名称:LeapMotion_Slicer,代码行数:24,代码来源:leapmotionlistener.cpp
示例18: onFrame
void LeapListener::onFrame(const Controller& controller) {
const Frame frame = controller.frame();
Leap::HandList hands = frame.hands();
Leap::Hand hand = hands[0];
if(hand.isValid()){
leapData.pitch = hand.direction().pitch();
leapData.yaw = hand.direction().yaw();
leapData.roll = hand.palmNormal().roll();
leapData.height = hand.palmPosition().y;
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", height: " << leapData.height
<< ", pitch: " << RAD_TO_DEG * leapData.pitch
<< ", yaw: " << RAD_TO_DEG * leapData.yaw
<< ", roll: " << RAD_TO_DEG * leapData.roll << std::endl;
}
}
开发者ID:AlexandreMumble,项目名称:Jakopter,代码行数:20,代码来源:Leap.cpp
示例19: pos
// This mode tries to move the avatar and camera in Second Life. It's pretty rough and needs a lot of work
void LLLMImpl::modeMoveAndCamTest1(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
F32 orbit_rate = 0.f;
Leap::Vector pos(0, 0, 0);
for (size_t i = 0; i < num_fingers; ++i)
{
Leap::Finger finger = finger_list[i];
pos += finger.tipPosition();
}
pos = Leap::Vector(pos.x/num_fingers, pos.y/num_fingers, pos.z/num_fingers);
if (num_fingers == 1)
{ // 1 finger - move avatar
if (pos.x < -LM_DEAD_ZONE)
{ // Move left
gAgent.moveLeftNudge(1.f);
}
else if (pos.x > LM_DEAD_ZONE)
{
gAgent.moveLeftNudge(-1.f);
}
/*
if (pos.z < -LM_DEAD_ZONE)
{
gAgent.moveAtNudge(1.f);
}
else if (pos.z > LM_DEAD_ZONE)
{
gAgent.moveAtNudge(-1.f);
} */
if (pos.y < -LM_DEAD_ZONE)
{
gAgent.moveYaw(-1.f);
}
else if (pos.y > LM_DEAD_ZONE)
{
gAgent.moveYaw(1.f);
}
} // end 1 finger
else if (num_fingers == 2)
{ // 2 fingers - move camera around
// X values run from about -170 to +170
if (pos.x < -LM_DEAD_ZONE)
{ // Camera rotate left
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.x) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitLeftKey(orbit_rate);
}
else if (pos.x > LM_DEAD_ZONE)
{
gAgentCamera.unlockView();
orbit_rate = (pos.x - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitRightKey(orbit_rate);
}
if (pos.z < -LM_DEAD_ZONE)
{ // Camera zoom in
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.z) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitInKey(orbit_rate);
}
else if (pos.z > LM_DEAD_ZONE)
{ // Camera zoom out
gAgentCamera.unlockView();
orbit_rate = (pos.z - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitOutKey(orbit_rate);
}
if (pos.y < -LM_DEAD_ZONE)
{ // Camera zoom in
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.y) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitUpKey(orbit_rate);
}
else if (pos.y > LM_DEAD_ZONE)
{ // Camera zoom out
gAgentCamera.unlockView();
orbit_rate = (pos.y - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitDownKey(orbit_rate);
}
} // end 2 finger
}
}
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:96,代码来源:llleapmotioncontroller.cpp
示例20: if
// This mode tries to detect simple hand motion and either triggers an avatar gesture or
// sends a chat message into SL in response. It is very rough, hard-coded for detecting
// a hand wave (a SL gesture) or the wiggling-thumb gun trigger (a chat message sent to a
// special version of the popgun).
void LLLMImpl::modeGestureDetection1(Leap::HandList & hands)
{
static S32 trigger_direction = -1;
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
static S32 last_num_fingers = 0;
if (num_fingers == 1)
{ // One finger ... possibly reset the
Leap::Finger finger = finger_list[0];
Leap::Vector finger_dir = finger.direction();
// Negative Z is into the screen - check that it's the largest component
S32 abs_z_dir = llabs(finger_dir.z);
if (finger_dir.z < -0.5 &&
abs_z_dir > llabs(finger_dir.x) &&
abs_z_dir > llabs(finger_dir.y))
{
Leap::Vector finger_pos = finger.tipPosition();
Leap::Vector finger_vel = finger.tipVelocity();
LL_INFOS("LeapMotion") << "finger direction is " << finger_dir.x << ", " << finger_dir.y << ", " << finger_dir.z
<< ", position " << finger_pos.x << ", " << finger_pos.y << ", " << finger_pos.z
<< ", velocity " << finger_vel.x << ", " << finger_vel.y << ", " << finger_vel.z
<< LL_ENDL;
}
if (trigger_direction != -1)
{
LL_INFOS("LeapMotion") << "Reset trigger_direction - one finger" << LL_ENDL;
trigger_direction = -1;
}
}
else if (num_fingers == 2)
{
Leap::Finger barrel_finger = finger_list[0];
Leap::Vector barrel_finger_dir = barrel_finger.direction();
// Negative Z is into the screen - check that it's the largest component
F32 abs_z_dir = llabs(barrel_finger_dir.z);
if (barrel_finger_dir.z < -0.5f &&
abs_z_dir > llabs(barrel_finger_dir.x) &&
abs_z_dir > llabs(barrel_finger_dir.y))
{
Leap::Finger thumb_finger = finger_list[1];
Leap::Vector thumb_finger_dir = thumb_finger.direction();
Leap::Vector thumb_finger_pos = thumb_finger.tipPosition();
Leap::Vector thumb_finger_vel = thumb_finger.tipVelocity();
if ((thumb_finger_dir.x < barrel_finger_dir.x) )
{ // Trigger gunfire
if (trigger_direction < 0 && // Haven't fired
thumb_finger_vel.x > 50.f && // Moving into screen
thumb_finger_vel.z < -50.f &&
mChatMsgTimer.checkExpirationAndReset(LLLEAP_CHAT_MSG_INTERVAL))
{
// Chat message looks like "/2343 LM2 gunfire"
std::string gesture_chat_msg("/2343 LM2 gunfire");
//LLNearbyChatBar::sendChatFromViewer(gesture_chat_msg, CHAT_TYPE_SHOUT, FALSE);
trigger_direction = 1;
LL_INFOS("LeapMotion") << "Sent gunfire chat" << LL_ENDL;
}
else if (trigger_direction > 0 && // Have fired, need to pull thumb back
thumb_finger_vel.x < -50.f &&
thumb_finger_vel.z > 50.f) // Moving out of screen
{
trigger_direction = -1;
LL_INFOS("LeapMotion") << "Reset trigger_direction" << LL_ENDL;
}
}
}
else if (trigger_direction != -1)
{
LL_INFOS("LeapMotion") << "Reset trigger_direction - hand pos" << LL_ENDL;
trigger_direction = -1;
}
}
else if (num_fingers == 5 &&
num_fingers == last_num_fingers)
{
if (mGestureTimer.checkExpirationAndReset(LLLEAP_GESTURE_INTERVAL))
{
// figure out a gesture to trigger
std::string gestureString("/overhere");
LLGestureMgr::instance().triggerAndReviseString( gestureString );
}
}
last_num_fingers = num_fingers;
//.........这里部分代码省略.........
开发者ID:CaseyraeStarfinder,项目名称:Firestorm-Viewer,代码行数:101,代码来源:llleapmotioncontroller.cpp
注:本文中的leap::Hand类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论