本文整理汇总了C++中leap::Controller::hasFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::hasFocus方法的具体用法?C++ Controller::hasFocus怎么用?C++ Controller::hasFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap::Controller
的用法示例。
在下文中一共展示了Controller::hasFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFrame
void ZirkLeap::onFrame(const Leap::Controller& controller) {
if(controller.hasFocus()) {
Leap::Frame frame = controller.frame();
if (mPointableId >= 0) {
ourProcessor->setSelectedSource(mEditor->getCBSelectedSource()-1);
Leap::Pointable p = frame.pointable(mPointableId);
if (!p.isValid() || !p.isExtended()) {
mPointableId = -1;
mLastPositionValid = false;
} else {
Leap::Vector pos = p.tipPosition();
const float zPlane1 = 50; // 5 cm
const float zPlane2 = 100; // 10 cm
if (pos.z < zPlane2) {
if (mLastPositionValid) {
//Leap Motion mouvement are calculated from the last position in order to have something dynamic and ergonomic
Leap::Vector delta = pos- mLastPosition;
float scale = 3;
if (pos.z > zPlane1) {
float s = 1 - (pos.z - zPlane1) / (zPlane2 - zPlane1);
scale *= s;
}
int src = ourProcessor->getSelectedSource();
float fX, fY;
ourProcessor->getSources()[src].getXY(fX, fY);
fX += delta.x * scale;
fY -= delta.y * scale;
//clamp coordinates to circle
float fCurR = hypotf(fX, fY);
if ( fCurR > ZirkOscAudioProcessor::s_iDomeRadius){
float fExtraRatio = ZirkOscAudioProcessor::s_iDomeRadius / fCurR;
fX *= fExtraRatio;
fY *= fExtraRatio;
}
mEditor->move(src, fX, fY);
} else {
//std::cout << "pointable last pos not valid" << std::endl;
}
mLastPosition = pos;
mLastPositionValid = true;
} else {
//std::cout << "pointable not touching plane" << std::endl;
mLastPositionValid = false;
}
}
}
if (mPointableId < 0) {
Leap::PointableList pl = frame.pointables().extended();
if (pl.count() > 0) {
mPointableId = pl[0].id();
//std::cout << "got new pointable: " << mPointableId << std::endl;
}
}
}
}