本文整理汇总了C++中GestureList类的典型用法代码示例。如果您正苦于以下问题:C++ GestureList类的具体用法?C++ GestureList怎么用?C++ GestureList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GestureList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/*----------------------------------------------------------------------------------------------------*/
void Gestures::update() {
Frame frame = mController.frame(0);
GestureList gestures = frame.gestures();
int gestureCount = gestures.count();
for ( int i = 0 ; i < gestureCount ; i++ ) {
sendGesture(gestures[i]);
}
}
示例2: onFrame
void MyListener::onFrame(const Controller& controller)
{
const Frame frame = controller.frame();
const GestureList gestures = frame.gestures();
HandList hands = frame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
const Hand hand = *hl;
// Smoothing and stabilization is performed in order to make this
// value more suitable for interaction with 2D content. The stabilized
// position lags behind the palm position by a variable amount,
// depending primarily on the speed of movement.
Vector position = hand.stabilizedPalmPosition();
if (m_positionChanged)
m_positionChanged(position[0], position[1], position[2],
frame.fingers().extended().count(),
hand.direction(),
hand.palmVelocity());
if (m_pinch)
m_pinch(hand.pinchStrength());
if (m_grab)
m_grab(hand.grabStrength());
}
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_KEY_TAP:
case Gesture::TYPE_SCREEN_TAP:
if (m_tapped)
m_tapped();
break;
case Gesture::TYPE_SWIPE:
break;
}
}
}
示例3: BoneData
void LeapHands::onFrame(const Controller& controller)
{
//Game::Instance()->PrintFloat("Hand children: ", childrenMap.size());
std::map<string, BoneData> tempBoneData;
HandList hands = controller.frame().hands();
int handId = 0;
hands[0].fingers()[(int) Finger::Type::TYPE_THUMB];
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Hand hand = *hl;
// Get fingers
const FingerList fingers = hand.fingers();
int fingerId = 0;
bool firstFinger = true;
Finger previousFinger;
stringstream ass;
ass << "Arm: 0 Hand: " << handId;
tempBoneData[ass.str()] = BoneData(ass.str(), LeapToGlVec3(hand.arm().wristPosition()), LeapToGlVec3(hand.arm().elbowPosition()), true);
ass.clear();
glm::vec3 thumbBone = LeapToGlVec3(hand.fingers()[Finger::Type::TYPE_THUMB].bone(Bone::Type::TYPE_DISTAL).nextJoint());
glm::vec3 indexBone = LeapToGlVec3(hand.fingers()[Finger::Type::TYPE_INDEX].bone(Bone::Type::TYPE_DISTAL).nextJoint());
pinchDist = glm::length(thumbBone - indexBone);
if (pinchDist < 5.0f)
{
pinch = true;
}
else
{
pinch = false;
}
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
stringstream ss;
ss << "Hand: " << handId << " Finger: " << fingerId << " Bone: " << b;
tempBoneData[ss.str()] = BoneData(ss.str(), LeapToGlVec3(bone.prevJoint()), LeapToGlVec3(bone.nextJoint()), true);
}
// Draw some other bits of the hand
if (!firstFinger)
{
for (int b = 0; b < 2; ++b)
{
stringstream ss;
ss << "Hand: " << handId << "Finger: " << (fingerId - 1) << "Finger: " << (fingerId) << " Bone: " << b;
Bone startBone = previousFinger.bone(static_cast<Bone::Type>(b));
Bone endBone = finger.bone(static_cast<Bone::Type>(b));
if ((b == 1) && (fingerId == 1))
{
tempBoneData[ss.str()] = BoneData(ss.str(), LeapToGlVec3(startBone.nextJoint()), LeapToGlVec3(endBone.prevJoint()), false);
}
else
{
tempBoneData[ss.str()] = BoneData(ss.str(), LeapToGlVec3(startBone.prevJoint()), LeapToGlVec3(endBone.prevJoint()), false);
}
}
}
const GestureList gestures = controller.frame().gestures();
for (int g = 0; g < gestures.count(); ++g)
{
Gesture gesture = gestures[g];
switch (gesture.type())
{
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
if (gesture.durationSeconds() > 1)
{
if (circle.pointable().direction().angleTo(circle.normal()) <= PI / 2) {
spawn = vehicle;
}
else {
spawn = model;
}
}
}
}
}
previousFinger = finger;
firstFinger = false;
++fingerId;
}
++handId;
}
EnterCriticalSection(&criticalSection);
trackedHands = handId;
//.........这里部分代码省略.........
示例4: onFrame
void SampleListener::onFrame(const Controller& controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", fingers: " << frame.fingers().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl;
if (!frame.hands().isEmpty()) {
// Get the first hand
const Hand hand = frame.hands()[0];
// Check if the hand has any fingers
const FingerList fingers = hand.fingers();
if (!fingers.isEmpty()) {
// Calculate the hand's average finger tip position
Vector avgPos;
for (int i = 0; i < fingers.count(); ++i) {
avgPos += fingers[i].tipPosition();
}
avgPos /= (float)fingers.count();
std::cout << "Hand has " << fingers.count()
<< " fingers, average finger tip position" << avgPos << std::endl;
}
// Get the hand's sphere radius and palm position
std::cout << "Hand sphere radius: " << hand.sphereRadius()
<< " mm, palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << "Hand pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;
}
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/4) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << "Circle id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << "Swipe id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
std::cout << "Key Tap id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", position: " << tap.position()
<< ", direction: " << tap.direction()<< std::endl;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << "Screen Tap id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction()<< std::endl;
break;
}
default:
//.........这里部分代码省略.........
示例5: onFrame
void LeapListener::onFrame(const Controller & controller) {
// Get the most recent frame and report some basic information
const 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;
HandList hands = frame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const 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 Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(2, ' ') << "pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;
// Get the Arm bone
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 FingerList fingers = hand.fingers();
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const 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) {
Bone::Type boneType = static_cast<Bone::Type>(b);
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 ToolList tools = frame.tools();
for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Tool tool = *tl;
std::cout << std::string(2, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
}
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE: {
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE: {
SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
//.........这里部分代码省略.........
示例6: time
void SampleListener::onFrame(const Controller& controller)
{
// This function needs to be broken up, it's way too long
const Frame frame = controller.frame();
//int currid = 1;
//check if we already processed this frame
if (frame.id() == this->lastFrameID)
return;
this->lastFrameID = frame.id();
//stop activity if we've not been used for ACTIVETIMEOUT
if ((ACTIVETIMEOUT + this->lastEvent) < time(0) && this->active)
{
std::cout << "auto deactivated" << std::endl;
this->active = false;
}
if (frame.fingers().count() == 2)
{
GestureList gestures = frame.gestures();
for (int it = 0; it < gestures.count(); ++it)
{
if (gestures[it].type() != Gesture::TYPE_KEY_TAP)
continue;
if ((this->lastToggle + TOGGLE_FRAME_LIMIT) > frame.id()) //avoid detecting the same tap twice
continue;
KeyTapGesture gesture = gestures[it];
Vector v = gesture.direction();
this->active = !this->active;
this->lastToggle = frame.id();
this->lastEvent = time(0);
std::cout << (this->active ? "activated" : "deactivated") << std::endl;
break; //make sure we don't accidentally use the same list twice
}
}
if (!this->active)
return;
if (frame.fingers().count() == 1 & side != 2)
{
PointableList pointables = frame.pointables();
InteractionBox iBox = frame.interactionBox();
for (int p = 0; p < pointables.count(); ++p)
{
Pointable pointable = pointables[p];
Vector normalizedPosition = iBox.normalizePoint(pointable.stabilizedTipPosition());
float distance = pointable.touchDistance();
float x = normalizedPosition.x * (Mouse->w_width+250);
float y = (Mouse->w_height + 250) - normalizedPosition.y * (Mouse->w_height + 250);
if (side == 0)
{
Mouse->move((int)x, (int)y);
pressedDelay = 0;
}
if (distance < 0)
{
clickcount++;
side = 1;
if (clickcount > sensibility)
{
if (pressstate == 0)
{
Mouse->leftPress();
pressstate = 1;
}
else
{
if (clickcount >= 30)
{
if (rclick == 0)
Mouse->move((int)x,(int)y);
std::cout << "move side: "<< side << std::endl;
clickcount = 20;
}
}
}
}
else if (side == 1)
{
Mouse->leftRelease();
std::cout << "released side: " << side << std::endl;
side = 0;
pressstate = 0;
pressedDelay = 0;
clickcount = 0;
rclick = 0;
}
}
this->lastEvent = time(0);
}
else if (frame.fingers().count() > 1 & side != 1)
{
clickcount = 0;
std::cout << "active side: " << side << std::endl;
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g)
{
//.........这里部分代码省略.........
示例7: onFrame
void QLeapEventListener::onFrame(const Controller & controller)
{
const Frame frame = controller.frame();
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/4) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << "Circle id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << "Swipe id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
onSwipe(swipe);
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
std::cout << "Key Tap id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", position: " << tap.position()
<< ", direction: " << tap.direction()<< std::endl;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << "Screen Tap id: " << gesture.id()
<< ", state: " << gesture.state()
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction()<< std::endl;
break;
}
default:
std::cout << "Unknown gesture type." << std::endl;
break;
}
}
}
示例8: onFrame
void SampleListener::onFrame(const Controller& controller) {
//tictoc_stack.push(clock());
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
HandList hands = frame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
const Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
// Get the Arm bone
Arm arm = hand.arm();
// Get fingers
const FingerList fingers = hand.fingers();
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
myfile << std::string(4, ' ') << fingerNames[finger.type()]
<< ": " << hand.palmPosition().distanceTo(finger.tipPosition());
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
}
}
}
// Get tools
const ToolList tools = frame.tools();
for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Tool tool = *tl;
}
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI / 2) {
clockwiseness = "clockwise";
}
else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
break;
}
default:
break;
}
}
if (!frame.hands().isEmpty() || !gestures.isEmpty()) {
std::cout << std::endl;
}
myfile << " Time elapsed: "
<< ((double)(clock() - tictoc_stack.top())) / CLOCKS_PER_SEC;
tictoc_stack.pop();
myfile << endl;
}
示例9: tanf
void LeapInput::onFrame(const Controller& controller)
{
Frame frame = controller.frame();
HandList hands = frame.hands();
this->hands = hands.count();
if(hands.count() == 2)
{
Hand leftHand = hands.leftmost();
Hand rightHand = hands.rightmost();
leftHandY = leftHand.palmPosition().y;
rightHandY = rightHand.palmPosition().y;
leftFingers = leftHand.fingers().count();
rightFingers = rightHand.fingers().count();
float threshold = tanf(5* 3.141592f / 180.0f);
float maxTan = tanf(45 * 3.141592f / 180.0f);
if(leftHand.palmPosition().x != rightHand.palmPosition().x){
float tanValue = fabs((leftHand.palmPosition().y - rightHand.palmPosition().y) / (leftHand.palmPosition().x - rightHand.palmPosition().x));
if(tanValue > threshold){
curve = tanValue / maxTan;
if(curve > 1)
curve = 1;
}else
curve = 0;
}else
curve = 0;
}
else
{
leftHandY = rightHandY = 0;
}
boost = false;
GestureList gestureList = frame.gestures();
for(GestureList::const_iterator i = gestureList.begin(); i != gestureList.end(); ++i)
{
Gesture gesture = *i;
if(gesture.state() != Gesture::State::STATE_INVALID)
{
switch(gesture.type())
{
case Gesture::Type::TYPE_SCREEN_TAP:
boost = true;
break;
}
}
}
back = false;
if(hands.count() == 2 && leftFingers == 1 && rightFingers == 1 &&
hands.leftmost().fingers()[0].direction().z > 0 &&
hands.rightmost().fingers()[0].direction().z > 0)
{
back = true;
}
//accelGesture = brakeGesture = false;
//GestureList gestureList = frame.gestures();
//for(GestureList::const_iterator i = gestureList.begin(); i != gestureList.end(); ++i)
//{
// Gesture gesture = *i;
// if(gesture.state() != Gesture::State::STATE_INVALID)
// {
// if(typeid(gesture) == typeid(MyGesture))
// {
// accelGesture = true;
// }
//
// }
//}
}
示例10: pan
void LeapController::update() {
hands = leap.getLeapHands();
if(leap.isFrameNew() && hands.size()){
for(int i = 0; i < hands.size(); i++){
Hand hand = hands[i];
if (handsPrevious.size() == hands.size() && hand.fingers().count() == 3){
float dx = hand.palmPosition().x - handsPrevious[i].palmPosition().x;
float dy = hand.palmPosition().z - handsPrevious[i].palmPosition().z;
float dz = -hand.palmPosition().y + handsPrevious[i].palmPosition().y;
int numFingers = hands[i].fingers().count();
// horizontalPan = (numFingers == 2);
horizontalPan = false;
verticalPan = true;
pan(dx,dy,dz);
}
}
}
Frame frame = controller.frame();
GestureList gestures = framePrevious.isValid() ?
frame.gestures(framePrevious) :
frame.gestures();
framePrevious = frame;
for (size_t i=0; i < gestures.count(); i++) {
if (gestures[i].type() == Gesture::TYPE_SCREEN_TAP) {
ScreenTapGesture tap = gestures[i];
static GestureEventArgs args;
args.pos = ofVec3f(tap.position().x, tap.position().y, tap.position().z);
ofNotifyEvent(onTapScreen, args, this);
} else if (gestures[i].type() == Gesture::TYPE_KEY_TAP) {
KeyTapGesture tap = gestures[i];
static GestureEventArgs args;
args.pos = ofVec3f(tap.position().x, tap.position().y, tap.position().z);
ofNotifyEvent(onTapDown, args, this);
//cout << "LEAP TAP GESTURE AT: " << pos << endl;
} else if (gestures[i].type() == Gesture::TYPE_SWIPE) {
SwipeGesture swipe = gestures[i];
Vector diff = 0.004f*(swipe.position() - swipe.startPosition());
static GestureEventArgs args;
args.pos = ofVec3f(swipe.position().x, swipe.position().y, swipe.position().z);
args.startPos = ofVec3f(swipe.startPosition().x, swipe.startPosition().y, swipe.startPosition().z);
args.state = swipe.state();
ofNotifyEvent(onSwipe, args, this);
//cout << "LEAP SWIPE GESTURE" << endl;
} else if (gestures[i].type() == Gesture::TYPE_CIRCLE) {
CircleGesture circle = gestures[i];
float progress = circle.progress();
if (progress >= 1.0f) {
double curAngle = 6.5;
//cout << "LEAP CIRCLE GESTURE" << endl;
}
static GestureEventArgs args;
args.pos = ofVec3f(circle.center().x, circle.center().y, circle.center().z);
args.normal = ofVec3f(circle.normal().x, circle.normal().y, circle.normal().z);
args.progress = circle.progress();
ofNotifyEvent(onCircle, args, this);
}
}
handsPrevious = hands;
leap.markFrameAsOld();
SceneController::update();
}
示例11: LeapGestureLogic
void QTVS_Leap::LeapGestureLogic()
{
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
// emit Listener_Gesture(gesture, gesture.type());
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI / 2) {
clockwiseness = "clockwise";
// MouseKeyboardEmulation::MouseWheelDown(5);
} else {
clockwiseness = "counterclockwise";
// MouseKeyboardEmulation::MouseWheelUp(5);
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
// debugDisplayString = "";
// debugDisplayString.append("Swipe id: " + QString::number(gesture.id()));
// debugDisplayString.append( ", state: " + QString(stateNames[gesture.state()].data()));
// debugDisplayString.append( ", direction: " + QString(swipe.direction().toString().data()));
// debugDisplayString.append( ", speed: " + QString::number(swipe.speed()));
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
// std::cout << std::string(2, ' ')
//debugDisplayString = "";
// debugDisplayString.append("Key Tap id: " + QString::number(gesture.id()));
// debugDisplayString.append( ", state: " + QString(stateNames[gesture.state()].data()));
//debugDisplayString.append( ", position: " + QString(tap.position().toString().data()));
// debugDisplayString.append( ", direction: " + QString(tap.direction().toString().data()));
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << std::string(2, ' ')
<< "Screen Tap id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction() << std::endl;
break;
}
default:
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
}
if (!frame.hands().isEmpty() || !gestures.isEmpty()) {
std::cout << std::endl;
}
}