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


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

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


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

示例1: m_bang


//.........这里部分代码省略.........
                    SETSYMBOL(&fingerInfo[3], gensym("direction"));
                    SETFLOAT(&fingerInfo[4], finger.direction().x);
                    SETFLOAT(&fingerInfo[5], finger.direction().y);
                    SETFLOAT(&fingerInfo[6], finger.direction().z);
                    ToOutAnything(1, gensym("hand"), 7, fingerInfo);
                }
                if(fingers_position_flag){
                    SETFLOAT(&fingerInfo[0], i); // index
                    SETSYMBOL(&fingerInfo[1], gensym("fingers"));
                    SETFLOAT(&fingerInfo[2], j);
                    SETSYMBOL(&fingerInfo[3], gensym("position"));
                    SETFLOAT(&fingerInfo[4], finger.tipPosition().x);
                    SETFLOAT(&fingerInfo[5], finger.tipPosition().y);
                    SETFLOAT(&fingerInfo[6], finger.tipPosition().z);
                    ToOutAnything(1, gensym("hand"), 7, fingerInfo);
                }
                if(fingers_velocity_flag){
                    SETFLOAT(&fingerInfo[0], i); // index
                    SETSYMBOL(&fingerInfo[1], gensym("fingers"));
                    SETFLOAT(&fingerInfo[2], j);
                    SETSYMBOL(&fingerInfo[3], gensym("velocity"));
                    SETFLOAT(&fingerInfo[4], finger.tipVelocity().x);
                    SETFLOAT(&fingerInfo[5], finger.tipVelocity().y);
                    SETFLOAT(&fingerInfo[6], finger.tipVelocity().z);
                    ToOutAnything(1, gensym("hand"), 7, fingerInfo);
                }
                if(fingers_size_flag){
                    SETFLOAT(&fingerInfo[0], i); // index
                    SETSYMBOL(&fingerInfo[1], gensym("fingers"));
                    SETFLOAT(&fingerInfo[2], j);
                    SETSYMBOL(&fingerInfo[3], gensym("size"));
                    SETFLOAT(&fingerInfo[4], finger.width());
                    SETFLOAT(&fingerInfo[5], finger.length());
                    ToOutAnything(1, gensym("hand"), 6, fingerInfo);
                }
            }
        }
        t_atom gestureCountInfo[1];            
        for(int i = 0;i < num_gestures; i++){
            Gesture gesture;
            gesture = frame.gestures()[i];
            //type
            t_atom gestureTypeInfo[3];
            SETFLOAT(&gestureTypeInfo[0], i);
            SETSYMBOL(&gestureTypeInfo[1], gensym("type"));
            switch(gesture.type())
            {
                case Gesture::TYPE_INVALID:
                    SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_INVALID"));
                    break;
                case Gesture::TYPE_SWIPE:
                    SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SWIPE"));
                    break;
                case Gesture::TYPE_CIRCLE:
                    SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_CIRCLE"));
                    break;
                case Gesture::TYPE_SCREEN_TAP:
                    SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SCREEN_TAP"));
                    break;
                case Gesture::TYPE_KEY_TAP:
                    SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_KEY_TAP"));
                    break;
            }
            ToOutList(2, 3, gestureTypeInfo);

            //state
            t_atom gestureStateInfo[3];
            SETFLOAT(&gestureStateInfo[0], i);
            SETSYMBOL(&gestureStateInfo[1], gensym("state"));
            switch(gesture.state())
            {
                case Gesture::STATE_INVALID:
                    SETSYMBOL(&gestureStateInfo[2], gensym("STATE_INVALID"));
                    break;
                case Gesture::STATE_START:
                    SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_START"));
                    break;
                case Gesture::STATE_UPDATE:
                    SETSYMBOL(&gestureStateInfo[2], gensym("STATE_UPDATE"));
                    break;
                case Gesture::STATE_STOP:
                    SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_STOP"));
                    break;
            }
            ToOutList(2, 3, gestureStateInfo);

            t_atom gestureDurationInfo[3];
            SETFLOAT(&gestureDurationInfo[0], i);
            SETSYMBOL(&gestureDurationInfo[1], gensym("duration"));
            SETFLOAT(&gestureDurationInfo[2], gesture.duration());
            ToOutList(2, 3, gestureDurationInfo);

            t_atom gestureIdInfo[3];
            SETFLOAT(&gestureIdInfo[0], i);
            SETSYMBOL(&gestureIdInfo[1], gensym("id"));
            SETFLOAT(&gestureIdInfo[2], gesture.id());
            ToOutList(2, 3, gestureIdInfo);

        }
    }
开发者ID:amatecha,项目名称:Pd_leapmotion,代码行数:101,代码来源:main.cpp

示例2: sendGesture

/*----------------------------------------------------------------------------------------------------*/
void Gestures::sendGesture(const Gesture& pGesture) {
    if ( !pGesture.isValid() ) {
        return;
    }

    Gesture::Type type = pGesture.type();
    Gesture::State state = pGesture.state();
    int64_t duration = pGesture.duration();

    Leap::Vector position;
    Leap::Vector direction;
    float progress = 0;
    float speed = 0;
    float radius = 0;
    std::string typeKey;
    std::string stateName;

    ////

    if ( type == Gesture::TYPE_CIRCLE ) {
        CircleGesture circle = (CircleGesture)pGesture;
        position = circle.center();
        progress = circle.progress();
        radius = circle.radius();
        typeKey = GestureKey::Circle;
    }
    else if ( type == Gesture::TYPE_SWIPE ) {
        SwipeGesture swipe = (SwipeGesture)pGesture;
        position = swipe.startPosition();
        direction = swipe.direction();
        speed = swipe.speed();
        typeKey = GestureKey::Swipe;
    }
    else if ( type == Gesture::TYPE_KEY_TAP ) {
        KeyTapGesture keyTap = (KeyTapGesture)pGesture;
        position = keyTap.position();
        direction = keyTap.direction();
        progress = keyTap.progress();
        typeKey = GestureKey::KeyTap;
    }
    else if ( type == Gesture::TYPE_SCREEN_TAP ) {
        ScreenTapGesture screenTap = (ScreenTapGesture)pGesture;
        position = screenTap.position();
        direction = screenTap.direction();
        progress = screenTap.progress();
        typeKey = GestureKey::ScreenTap;
    }
    else {
        std::cout << "[LEAP] Unsupported gesture type: " << type << std::endl;
        return;
    }

    ////

    switch ( state ) {
    case Gesture::STATE_INVALID:
        stateName = "Invalid";
        break;

    case Gesture::STATE_START:
        stateName = "Start";
        break;

    case Gesture::STATE_UPDATE:
        stateName = "Update";
        break;

    case Gesture::STATE_STOP:
        stateName = "Stop";
        break;

    default:
        std::cout << "[LEAP] Unsupported state type: " << state << std::endl;
        return;
    }

    ////

    std::cout << "GESTURE MESSAGE" <<
              "\n - type: " << type << " (" << typeKey << ")" <<
              "\n - stat: " << state << " (" << stateName << ")" <<
              "\n - dura: " << duration <<
              "\n - pos:  " << position <<
              "\n - dir:  " << direction <<
              "\n - prog: " << progress <<
              "\n - radi: " << radius <<
              "\n - spd:  " << speed <<
              "\n" << std::endl;
}
开发者ID:itguy327,项目名称:OSVR-Leap-Motion,代码行数:90,代码来源:Gestures.cpp

示例3: 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


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