当前位置: 首页>>代码示例>>C++>>正文


C++ Gesture::durationSeconds方法代码示例

本文整理汇总了C++中Gesture::durationSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Gesture::durationSeconds方法的具体用法?C++ Gesture::durationSeconds怎么用?C++ Gesture::durationSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gesture的用法示例。


在下文中一共展示了Gesture::durationSeconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getFrame


//.........这里部分代码省略.........
                        FRENewObjectFromDouble(circle.radius(), &freCircleGestureRadius);
                        FRESetObjectProperty(freGesture, (const uint8_t*) "radius", freCircleGestureRadius, NULL);
                    
                        FREObject frePointable = frePointablesMap[circle.pointable().id()];
                        if(frePointable != NULL)
                        {
                            FRESetObjectProperty(freGesture, (const uint8_t*) "pointable", frePointable, NULL);
                        }

                        break;
                    }
                    case Gesture::TYPE_SCREEN_TAP:
                    {
                        type = 7;
                        ScreenTapGesture screentap = gesture;
                        
                        FRENewObject( (const uint8_t*) "com.leapmotion.leap.ScreenTapGesture", 0, NULL, &freGesture, NULL);

                        FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(screentap.direction().x, screentap.direction().y, screentap.direction().z), NULL);
                        FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(screentap.position().x, screentap.position().y, screentap.position().z), NULL);

                        break;
                    }
                    case Gesture::TYPE_KEY_TAP:
                    {
                        type = 8;
                        KeyTapGesture tap = gesture;
                        
                        FRENewObject( (const uint8_t*) "com.leapmotion.leap.KeyTapGesture", 0, NULL, &freGesture, NULL);

                        FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(tap.direction().x, tap.direction().y, tap.direction().z), NULL);
                        FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(tap.position().x, tap.position().y, tap.position().z), NULL);
                        
                        break;
                    }
                    default:
                    {
                        type = 4;
                        FRENewObject( (const uint8_t*) "com.leapmotion.leap.Gesture", 0, NULL, &freGesture, NULL);
                        break;
                    }
                }
                
                FREObject freGestureState;
                FRENewObjectFromInt32(state, &freGestureState);
                FRESetObjectProperty(freGesture, (const uint8_t*) "state", freGestureState, NULL);
                
                FREObject freGestureType;
                FRENewObjectFromInt32(type, &freGestureType);
                FRESetObjectProperty(freGesture, (const uint8_t*) "type", freGestureType, NULL);

                FREObject freGestureDuration;
                FRENewObjectFromInt32((int32_t) gesture.duration(), &freGestureDuration);
                FRESetObjectProperty(freGesture, (const uint8_t*) "duration", freGestureDuration, NULL);
                
                FREObject freGestureDurationSeconds;
                FRENewObjectFromDouble(gesture.durationSeconds(), &freGestureDurationSeconds);
                FRESetObjectProperty(freGesture, (const uint8_t*) "durationSeconds", freGestureDurationSeconds, NULL);
                
                FRESetObjectProperty(freGesture, (const uint8_t*) "frame", freCurrentFrame, NULL);
                
                FREObject freGestureId;
                FRENewObjectFromInt32(gesture.id(), &freGestureId);
                FRESetObjectProperty(freGesture, (const uint8_t*) "id", freGestureId, NULL);
                
                if (!gesture.hands().empty()) {
                    
                    FREObject freGestureHands;
                    FREGetObjectProperty(freGesture, (const uint8_t*) "hands", &freGestureHands, NULL);
                    
                    for(int i = 0; i < gesture.hands().count(); i++) {
                        const Hand hand = gesture.hands()[i];
                        
                        FREObject freHand = freHandsMap[hand.id()];
                        FRESetArrayElementAt(freGestureHands, i, freHand);
                    }
                }
                
                if (!gesture.pointables().empty()) {
                    
                    FREObject freGesturePointables;
                    FREGetObjectProperty(freGesture, (const uint8_t*) "pointables", &freGesturePointables, NULL);
                    
                    for(int i = 0; i < gesture.pointables().count(); i++) {
                        const Pointable pointable = gesture.pointables()[i];
                        
                        FREObject frePointable = frePointablesMap[pointable.id()];
                        FRESetArrayElementAt(freGesturePointables, i, frePointable);
                    }
                }
                
                //push it in current gesture vector
                FRESetArrayElementAt(freGestures, i, freGesture);
            }
        }
        
        lastFrame = frame;
        
        return freCurrentFrame;
    }
开发者ID:cjyeh,项目名称:LeapMotionAS3,代码行数:101,代码来源:LNLeapDevice.cpp

示例2: onFrame

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;
//.........这里部分代码省略.........
开发者ID:AdamCarrick,项目名称:BGE,代码行数:101,代码来源:LeapHands.cpp

示例3: onFrame

void MangoListener::onFrame(const Controller& controller) {
  const Frame frame = controller.frame();
    HandList hands = frame.hands();
    int extendedFingers = 0;
    for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
        const Hand hand = *hl;
        for (int i = 0; i < hand.fingers().count(); i++)
        {
            Finger finger = hand.fingers()[i];
            if(finger.isExtended()) extendedFingers++;
        }

        if (!onGesture && !frame.hands().isEmpty() && frame.hands().count() == 1 && extendedFingers == 0)
        {
            preGestureCounter++;
            std::cout << preGestureCounter << std::endl;
            if (preGestureCounter > MAX_PREGESTURE && frameCount == 0)
            {
                onGesture = true;
                preGestureCounter = 0;
                frameCount++;
                note.show();
            }
        }
        else if (preGestureCounter > 0)
        {
            preGestureCounter--;
        }
    }
        if (onGesture && frameCount < MAX_FRAMECOUNT) {

            switch (extendedFingers)
            {
                case 1:
                {
                    std::string command = commands.getCommand("FING3");
                    std::cout << command << std::endl;
                    break;
                }
                case 2:
                {
                    break;
                }
                case 3:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }

            frameCount++;
            const GestureList gestures = frame.gestures();
            for (int g = 0; g < gestures.count(); ++g) {
                Gesture gesture = gestures[g]; //need to move finger detection in here too
                switch (gesture.type()) {
                    case Gesture::TYPE_CIRCLE:
                    {
                        CircleGesture circle = gesture;
                        std::string clockwiseness; //probably simplfy to a bool

                        if (circle.pointable().direction().angleTo(circle.normal()) <= PI/4)
                        {
                          clockwiseness = "clockwise";
                          std::cout << "CIRCLE CLOCKWISE" << std::endl;
                        }
                        else
                        {
                          clockwiseness = "counterclockwise";
                          std::cout << "CIRCLE COUNTERCLOCKWISE" << std::endl;
                        }
                        break;
                    }
                    case Gesture::TYPE_SWIPE:
                    {
                        SwipeGesture swipe = gesture;
                        std::cout << "SWIPE" << std::endl;
                        break;
                    }
                    case Gesture::TYPE_KEY_TAP:
                    {
                        KeyTapGesture tap = gesture;
                        std::cout << "KEY TAP" << std::endl;
                        break;
                    }
                    case Gesture::TYPE_SCREEN_TAP:
                    {
                        ScreenTapGesture screentap = gesture;
                        std::cout << "SCREEN TAP" << std::endl;
                        break;
                    }
                    default:
                    {
                        std::cout << std::string(2, ' ')  << "Unknown gesture type." << std::endl;
                        break;
                    }
                }
                float seconds = gesture.durationSeconds();
//.........这里部分代码省略.........
开发者ID:tritania,项目名称:Mango,代码行数:101,代码来源:mango.cpp


注:本文中的Gesture::durationSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。