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


C++ Finger::width方法代码示例

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


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

示例1: drawFinger

//--------------------------------------------------------------
void LeapVisualizer::drawFinger (const Finger & finger,ofxLeapMotion & leap){
	
	if (finger.isValid()){
		
		// For every bone (i.e. phalange) in the finger,
		for (int b=0; b<4; b++) {
			
			// Get each bone;
			Bone::Type boneType = static_cast<Bone::Type>(b);
			Bone bone = finger.bone(boneType);
			if (bone.isValid()){
				
				// Don't consider zero-length bones, such as the Thumb's metacarpal.
				if (bone.length() > 0){
					drawBone (finger, bone,leap);
					
				} // end if boneLength
			} // end if bone isValid()
		} // end for each bone
		
		if (bDrawSimple){
			// Draw the fingertip, which is an extra point within the last phalange.
			ofSetColor(ofColor::white);
			ofPoint fingerTipPt = leap.getofPoint ( finger.tipPosition() );
			ofDrawSphere(fingerTipPt, finger.width() * 0.05);
		}
	}
}
开发者ID:Julien-Dr,项目名称:digital_art_2014,代码行数:29,代码来源:LeapVisualizer.cpp

示例2: recordFingerXML

//--------------------------------------------------------------
void testApp::recordFingerXML (const Finger & finger){
	
	if (bRecordingThisFrame){
		if (finger.isValid()){
			Finger::Type fingerType = finger.type();
			
			int fingerTagNum = XML.addTag("F");
			if( XML.pushTag("F", fingerTagNum) ){
				XML.setValue("TYPE", (int)fingerType, fingerTagNum);
				XML.setValue("WIDTH", finger.width(), fingerTagNum);
				
				// Add in the fingerTip point as its own point.
				ofPoint fingerTipPt = leap.getofPoint ( finger.tipPosition() );
				int tipTagNum = XML.addTag("T");
				XML.setValue("T:X", fingerTipPt.x, tipTagNum);
				XML.setValue("T:Y", fingerTipPt.y, tipTagNum);
				XML.setValue("T:Z", fingerTipPt.z, tipTagNum);
				
				// For every bone (i.e. phalange) in the finger,
				for (int b=0; b<4; b++) {
					
					// Get each bone;
					Bone::Type boneType = static_cast<Bone::Type>(b);
					Bone bone = finger.bone(boneType);
					if (bone.isValid()){
						
						// Don't consider zero-length bones, such as the Thumb's metacarpal.
						if (bone.length() > 0){
							recordBoneXML (finger, bone);
							
						} // end if boneLength
					} // end if bone isValid()
				} // end for each bone
				
				
				XML.popTag(); // pop F(INGER)
			}
		} //end if finger isValid()
	}
}
开发者ID:ahork,项目名称:digital_art_2014,代码行数:41,代码来源:recordXML.cpp

示例3: 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;
//.........这里部分代码省略.........
开发者ID:quantum0813,项目名称:Erics3DEngine,代码行数:101,代码来源:LeapListener.cpp

示例4: m_bang

    void m_bang()
    {

        Frame frame;
        t_atom generalInfo[6];
        int num_hands, num_tools, num_gestures;
        frame = dispatcher.frame;
        num_hands = frame.hands().count();
        num_tools = frame.tools().count();
        num_gestures = frame.gestures().count();
        
        if(general_flag){
            SETFLOAT(&generalInfo[0], (float)frame.id());
            SETFLOAT(&generalInfo[1], (float)frame.timestamp());
            SETFLOAT(&generalInfo[2], (float)num_hands);
            SETFLOAT(&generalInfo[3], (float)frame.fingers().count());
            SETFLOAT(&generalInfo[4], (float)frame.tools().count());
            SETFLOAT(&generalInfo[5], (float)frame.gestures().count());
            ToOutList(0, 6, generalInfo);        
        }
        // tools
        for(int i = 0; i<num_tools; i++){
            Tool tool;
            tool = frame.tools()[i];

            t_atom toolInfo[5];
            if(tools_position_flag) {
                SETFLOAT(&toolInfo[0], i);
                SETSYMBOL(&toolInfo[1], gensym("direction"));
                SETFLOAT(&toolInfo[2], tool.direction().x);
                SETFLOAT(&toolInfo[3], tool.direction().y);
                SETFLOAT(&toolInfo[4], tool.direction().z);
                ToOutAnything(1, gensym("tool"), 5, toolInfo);
            }
            if(tools_position_flag) {
                SETFLOAT(&toolInfo[0], i);
                SETSYMBOL(&toolInfo[1], gensym("position"));
                SETFLOAT(&toolInfo[2], tool.tipPosition().x);
                SETFLOAT(&toolInfo[3], tool.tipPosition().y);
                SETFLOAT(&toolInfo[4], tool.tipPosition().z);
                ToOutAnything(1, gensym("tool"), 5, toolInfo);
            }
            if(tools_velocity_flag){
                SETFLOAT(&toolInfo[0], i);
                SETSYMBOL(&toolInfo[1], gensym("velocity"));
                SETFLOAT(&toolInfo[2], tool.tipVelocity().x);
                SETFLOAT(&toolInfo[3], tool.tipVelocity().y);
                SETFLOAT(&toolInfo[4], tool.tipVelocity().z);
                ToOutAnything(1, gensym("tool"), 5, toolInfo);
            }
            if(tools_size_flag){
                SETFLOAT(&toolInfo[0], i); 
                SETSYMBOL(&toolInfo[1], gensym("size"));
                SETFLOAT(&toolInfo[2], tool.width());
                SETFLOAT(&toolInfo[3], tool.length());
                ToOutAnything(1, gensym("tool"), 4, toolInfo);
            }
        }
        // hands and fingers
        for(int i = 0; i<num_hands; i++){
            Hand hand;
            hand = frame.hands()[i];
            int num_fingers = hand.fingers().count();
            int num_tools = hand.tools().count();
            t_atom handInfo[5];

            if(hands_direction_flag){
                // direction
                SETFLOAT(&handInfo[0], i);
                SETSYMBOL(&handInfo[1], gensym("direction"));
                SETFLOAT(&handInfo[2], hand.direction().x);
                SETFLOAT(&handInfo[3], hand.direction().y);
                SETFLOAT(&handInfo[4], hand.direction().z);
                ToOutAnything(1, gensym("hand"), 5, handInfo);
            }
            if(hands_palm_position_flag){
                // position
                SETFLOAT(&handInfo[0], i);
                SETSYMBOL(&handInfo[1], gensym("palm_position"));
                SETFLOAT(&handInfo[2], hand.palmPosition().x);
                SETFLOAT(&handInfo[3], hand.palmPosition().y);
                SETFLOAT(&handInfo[4], hand.palmPosition().z);
                ToOutAnything(1, gensym("hand"), 5, handInfo);
            }
            if(hands_palm_velocity_flag){
                // velocity
                SETFLOAT(&handInfo[0], i);
                SETSYMBOL(&handInfo[1], gensym("palm_velocity"));
                SETFLOAT(&handInfo[2], hand.palmVelocity().x);
                SETFLOAT(&handInfo[3], hand.palmVelocity().y);
                SETFLOAT(&handInfo[4], hand.palmVelocity().z);
                ToOutAnything(1, gensym("hand"), 5, handInfo);
            }
            if(hands_palm_normal_flag){
                // normal
                SETFLOAT(&handInfo[0], i);
                SETSYMBOL(&handInfo[1], gensym("palm_normal"));
                SETFLOAT(&handInfo[2], hand.palmNormal().x);
                SETFLOAT(&handInfo[3], hand.palmNormal().y);
                SETFLOAT(&handInfo[4], hand.palmNormal().z);
//.........这里部分代码省略.........
开发者ID:amatecha,项目名称:Pd_leapmotion,代码行数:101,代码来源:main.cpp


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