本文整理汇总了C++中leap::Hand::sphereCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Hand::sphereCenter方法的具体用法?C++ Hand::sphereCenter怎么用?C++ Hand::sphereCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Hand
的用法示例。
在下文中一共展示了Hand::sphereCenter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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
}
示例3: update
//--------------------------------------------------------------
void testApp::update(){
Leap::Vector pNormal;
Leap::Frame frame = leapController.frame();
Leap::HandList hands = frame.hands();
Leap::Vector pt0;
Leap::Vector pt1;
if (!hands.isEmpty()) {
fingerPos.clear();
sphereSize.clear();
sphereNorm.clear();
spherePos.clear();
//ofLogNotice("hand detected");
//----------------------------------- data collection -------------------------------------------------------------
for (int i = 0; i<hands.count(); i++) {
if (i>1) break;
Leap::Hand tempHand = hands[i];
Leap::FingerList tempfinger = tempHand.fingers();
for (int j = 0; j <= tempfinger.count(); j++) {
ofVec3f pt;
Leap::Finger finger = hands[i].fingers()[j];
Leap::Vector tempPT=finger.tipPosition();
pt.x=tempPT.x;pt.y=tempPT.y;pt.z=tempPT.z;
fingerPos.push_back(pt);
}
pt0 = tempHand.palmNormal();
Leap::Vector center = tempHand.sphereCenter();
ofVec3f sp; sp.x = center.x; sp.y = center.y; sp.z = center.z;
float r = tempHand.sphereRadius();
spherePos.push_back(sp);
sphereSize.push_back(r);
sphereNorm.push_back(pt0);
ofLogNotice("hand " +ofToString(i) + "normal", ofToString(pt0.x) + " " + ofToString(pt0.y) + " " + ofToString(pt0.z));
ofLogNotice("hand " + ofToString(i) + "center ", ofToString(sp.x) + " " + ofToString(sp.y) + " " + ofToString(sp.z));
}
//---------------------------------- state machine ------------------------------------------------------------------
if(phase1==true && phase2 == false && phase3==false && phase4 == false && phase5==false && phase6 == false && phase7 == false && (!fingerPos.empty()))
{
phase2 = true;
state = 1;
}
if (phase2 == true && (sphereNorm.size()>=2)) {
pt0 = sphereNorm[0];
pt1 = sphereNorm[1];
if (abs(abs(pt0.x)-abs(pt1.x))<0.04 && abs(abs(pt0.y)-abs(pt1.y))<0.04) {
phase3 = true;
phase2 = false;
}
}
}
// ofLogNotice("phase1: ", ofToString(phase1));
// ofLogNotice("phase2: ", ofToString(phase2));
// ofLogNotice("phase3: ", ofToString(phase3));
// ofLogNotice("phase4: ", ofToString(phase4));
// ofLogNotice("phase5: ", ofToString(phase5));
// ofLogNotice("phase6: ", ofToString(phase6));
// ofLogNotice("phase7: ", ofToString(phase7));
oldFrame = frame;
preId = frame.id();
}
示例4: modeFlyingControlTest
// This controller mode is used to fly the avatar, going up, down, forward and turning.
void LLLMImpl::modeFlyingControlTest(Leap::HandList & hands)
{
static S32 sLMFlyingHysteresis = 0;
S32 numHands = hands.count();
BOOL agent_is_flying = gAgent.getFlying();
if (numHands == 0
&& agent_is_flying
&& sLMFlyingHysteresis > 0)
{
sLMFlyingHysteresis--;
if (sLMFlyingHysteresis == 0)
{
LL_INFOS("LeapMotion") << "LM stop flying - look ma, no hands!" << LL_ENDL;
gAgent.setFlying(FALSE);
}
}
else 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();
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
// Number of fingers controls flying on / off
if (num_fingers == 0 && // To do - add hysteresis or data smoothing?
agent_is_flying)
{
if (sLMFlyingHysteresis > 0)
{
sLMFlyingHysteresis--;
}
else
{
LL_INFOS("LeapMotion") << "LM stop flying" << LL_ENDL;
gAgent.setFlying(FALSE);
}
}
else if (num_fingers > 2 &&
!agent_is_flying)
{
LL_INFOS("LeapMotion") << "LM start flying" << LL_ENDL;
gAgent.setFlying(TRUE);
sLMFlyingHysteresis = 5;
}
// Radius of ball controls forward motion
if (agent_is_flying)
{
if (ball_radius > 110.f)
{ // Open hand, move fast
gAgent.setControlFlags(AGENT_CONTROL_AT_POS | AGENT_CONTROL_FAST_AT);
}
else if (ball_radius > 85.f)
{ // Partially open, move slow
gAgent.setControlFlags(AGENT_CONTROL_AT_POS);
}
else
{ // Closed - stop
gAgent.clearControlFlags(AGENT_CONTROL_AT_POS);
}
// Height of palm controls moving up and down
if (palm_pos.y > 260.f)
{ // Go up fast
gAgent.setControlFlags(AGENT_CONTROL_UP_POS | AGENT_CONTROL_FAST_UP);
}
else if (palm_pos.y > 200.f)
{ // Go up
gAgent.setControlFlags(AGENT_CONTROL_UP_POS);
}
else if (palm_pos.y < 60.f)
{ // Go down fast
gAgent.setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_NEG);
}
else if (palm_pos.y < 120.f)
{ // Go down
gAgent.setControlFlags(AGENT_CONTROL_UP_NEG);
}
else
{ // Clear up / down
gAgent.clearControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_POS | AGENT_CONTROL_UP_NEG);
}
// Palm normal going left / right controls direction
if (mYawTimer.checkExpirationAndReset(LLLEAP_YAW_INTERVAL))
{
if (palm_normal.x > 0.4f)
{ // Go left fast
//.........这里部分代码省略.........
示例5: oleap_bang
//.........这里部分代码省略.........
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().y);
sprintf(buff,"/hand/leftmost/palm/positiony/z");
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().z);
sprintf(buff,"/hand/leftmost/direction/x");
oleap_bundleMessage(bundle,buff,leftmost.direction().x);
sprintf(buff,"/hand/leftmost/direction/y");
oleap_bundleMessage(bundle,buff,leftmost.direction().y);
sprintf(buff,"/hand/leftmost/direction/z");
oleap_bundleMessage(bundle,buff,leftmost.direction().z);
sprintf(buff,"/hand/leftmost/pitch");
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().pitch());
sprintf(buff,"/hand/leftmost/yaw");
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().yaw());
sprintf(buff,"/hand/leftmost/roll");
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().roll());
sprintf(buff,"/hand/leftmost/palm/velocity/x");
oleap_bundleMessage(bundle,buff,leftmost.palmVelocity().x);
sprintf(buff,"/hand/leftmost/palm/velocity/y");
oleap_bundleMessage(bundle,buff,leftmost.palmVelocity().y);
sprintf(buff,"/hand/leftmost/palm/velocity/z");
oleap_bundleMessage(bundle,buff,leftmost.palmVelocity().z);
sprintf(buff,"/hand/leftmost/palm/sphere/center/x");
oleap_bundleMessage(bundle,buff,leftmost.sphereCenter().x);
sprintf(buff,"/hand/leftmost/palm/sphere/center/y");
oleap_bundleMessage(bundle,buff,leftmost.sphereCenter().y);
sprintf(buff,"/hand/leftmost/palm/sphere/center/z");
oleap_bundleMessage(bundle,buff,leftmost.sphereCenter().z);
sprintf(buff,"/hand/leftmost/palm/sphere/radius");
oleap_bundleMessage(bundle,buff,leftmost.sphereRadius());
sprintf(buff,"/hand/leftmost/palm/normal/x");
oleap_bundleMessage(bundle,buff,leftmost.palmNormal().x);
sprintf(buff,"/hand/leftmost/palm/normal/y");
oleap_bundleMessage(bundle,buff,leftmost.palmNormal().y);
sprintf(buff,"/hand/leftmost/palm/normal/z");
oleap_bundleMessage(bundle,buff,leftmost.palmNormal().z);
sprintf(buff,"/hand/leftmost/distance/from/rightmost");
oleap_bundleMessage(bundle,buff,leftmost.palmPosition().angleTo(rightmost.palmPosition()));
const Leap::FingerList &fingers = leftmost.fingers();
const size_t numFingers = fingers.count();
for(size_t j = 0; j < numFingers; j++)
{
const Leap::Finger &finger = fingers[j];
const int32_t finger_id = finger.id();
//const Leap::Ray& tip = finger.tip();
const Leap::Vector direction = finger.direction();
const Leap::Vector position = finger.tipPosition();