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


C# Frame.Gestures方法代码示例

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


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

示例1: Update

    // Update is called once per frame
    void Update()
    {
        curFrame = controller.Frame();

        Finger curFinger = curFrame.Fingers[0];
        Vector curFingerPos = curFinger.TipPosition;

        bool canMove = true;
        if( Mathf.Abs(curFingerPos.x - prevFingerPos.x) > 15 ) {
            canMove = false;
        }
        if( Mathf.Abs(curFingerPos.y - prevFingerPos.y) > 15 ) {
            canMove = false;
        }

        //Debug.Log (pointerFingerPosition.x + " " + prevPointerPosition.x + " " + canMove);

        if(canMove == true) {
            Vector3 pos = Camera.main.ScreenToWorldPoint( new Vector3( (curFingerPos.x + 35) * 10, (curFingerPos.y - 40) * 7, 10) );
            transform.position = pos;
        }
        if(curFrame.Gestures().Count > 0) {
            CircleGesture circleItem = new CircleGesture(curFrame.Gestures()[0]);
            Vector circlePos = new Vector( (circleItem.Center.x + 35) * 10, (circleItem.Center.y - 40) * 7, 10);
            Ray ray = Camera.main.ScreenPointToRay(new Vector3(circlePos.x, circlePos.y, 0)); // Ray from the camera to the mouse position
            Debug.DrawRay(Camera.main.ScreenToWorldPoint(new Vector3(circlePos.x, circlePos.y, 0)), Vector3.forward);
            RaycastHit hit; // Raycast Hit information
            if( Physics.Raycast(ray, out hit) ) { // If the raycast hits something
                hit.transform.gameObject.GetComponent<Rotate>().dropping = true;
            }
        }
        prevFingerPos = curFingerPos;
    }
开发者ID:Valakor,项目名称:Space-Party,代码行数:34,代码来源:LeapMotion_Script.cs

示例2: Export

        // CSVレコード出力
        public void Export(Frame frame)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(frame.Id).Append(Delimiter);
            sb.Append(frame.Timestamp).Append(Delimiter);
            sb.Append(frame.Hands.Count).Append(Delimiter);
            sb.Append(frame.Fingers.Count).Append(Delimiter);
            sb.Append(frame.Tools.Count).Append(Delimiter);
            sb.Append(frame.Gestures().Count).Append(Delimiter);
            if (!frame.Hands.IsEmpty)
            {
                Hand hand = frame.Hands[0];
                FingerList fingers = hand.Fingers;
                if (!fingers.IsEmpty)
                {
                    Vector avgPos = Vector.Zero;
                    foreach (Finger finger in fingers)
                    {
                        avgPos += finger.TipPosition;
                    }
                    avgPos /= fingers.Count;
                    sb.Append(avgPos.x).Append(Delimiter).Append(avgPos.y).Append(Delimiter).Append(avgPos.z);
                }
            }
            else
            {
                sb.Append("0,0,0");
            }

            StreamWriter writer = new StreamWriter(FilePath, true);
            writer.WriteLine(sb.ToString());
            writer.Close();
        }
开发者ID:TMCN,项目名称:TechCafe-Vol-01,代码行数:34,代码来源:CSVExporter.cs

示例3: Update

        public bool Update(Frame frame)
        {
            // List of Ids for current Leap Gestures
            var currentIds = _CurrentGestures.Where(g => g is VyroLeapGesture).Select(g => ((VyroLeapGesture)g).LeapGestureId).ToList();
            // Find any new Leap Gestures
            var newLeapGestures = frame.Gestures().Where(ge => !currentIds.Contains(ge.Id));

            // Update current gestures dispatching activated ones and removing the invalid/complete ones
            var item = _CurrentGestures.First;
            while (item != null)
            {
                var next = item.Next;
                var state = item.Value.Update(frame);
                if (state == VyroGestureState.DiscreteComplete || state == VyroGestureState.IterationComplete)
                    _Dispatcher.Dispatch(item.Value);
                if (state == VyroGestureState.Invalid || state == VyroGestureState.DiscreteComplete || state == VyroGestureState.ContinuousComplete)
                    _CurrentGestures.Remove(item);
                item = next;
            }

            // Add new Leap Gestures
            foreach (var g in newLeapGestures)
                _CurrentGestures.AddLast(VyroLeapGesture.CreateFromLeapGesture(g));

            return true;
        }
开发者ID:RossDay,项目名称:Leap,代码行数:26,代码来源:GestureRecognizer.cs

示例4: FixedUpdate

 private void FixedUpdate()
 {
     currentFrame = leapMotionController.Frame();
     gestures = currentFrame.Gestures();
     hands = currentFrame.Hands;
     fingers = currentFrame.Fingers;
     tools = currentFrame.Tools;
 }
开发者ID:Nindustrialist,项目名称:VRBreadboarding,代码行数:8,代码来源:InitializationController.cs

示例5: IsRecognized

 private bool IsRecognized(Frame frame)
 {
     GestureList gestures = frame.Gestures ();
     foreach (Gesture gesture in gestures) {
         if (gesture.Type == Gesture.GestureType.TYPESWIPE) {
             SwipeGesture swipeGesture = new SwipeGesture (gesture);
             return IsAcceptableDirection (swipeGesture.Direction);
         }
     }
     return false;
 }
开发者ID:Sushisushi-sandesu,项目名称:sushi,代码行数:11,代码来源:SwipeRecognizer.cs

示例6: OnFrame

        public void OnFrame(Frame frame)
        {
            if (!_ActiveHand.Update(frame))
            {
                _IsGrabbed = false;
                if (!frame.Hands.IsEmpty)
                    _ActiveHand.Initialize(frame.Hands.Leftmost);
            }

            if (!_ActiveHand.IsFinalized)
                _LogAction(_ActiveHand.Dump());

            // Do nothing if the hand is not yet stabilized
            if (!_ActiveHand.IsStabilized)
                return;

            // We have the same Hand as in the past and we're still grabbed.
            if (_IsGrabbed)
            {
                if (_ActiveHand.CurrentHand.Fingers.Count >= 3)
                {
                    _IsGrabbed = false;
                }
                else
                {
                    var startY = _ActiveHand.StabilizedHand.StabilizedPalmPosition.y;
                    var y = _ActiveHand.CurrentHand.StabilizedPalmPosition.y;
                    //_LogAction(String.Format("Hand {0} now at {1:0.0} was grabbed at {2:0.0}.", _ActiveHand.Id, y, startY));
                    if (y < startY - 15)
                        for (var i = 0; i < Math.Floor((startY - y) / 20); i++)
                            Native.ScrollActiveWindow(false);
                    else if (y > startY + 15)
                        for (var i = 0; i < Math.Floor((y - startY) / 20); i++)
                            Native.ScrollActiveWindow(true);
                }
            }
            else if (_ActiveHand.CurrentHand.Fingers.Count < 2)
            {
                _IsGrabbed = true;
            }

            foreach (var g in frame.Gestures().Where(g => g.Type == Gesture.GestureType.TYPECIRCLE))
            {
                var circle = new CircleGesture(g);

                var isClockwise = (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4);

                if (circle.Progress < _Progress || circle.Progress > _Progress + 1)
                {
                    Native.ScrollActiveWindow(!isClockwise);
                    _Progress = Convert.ToInt32(Math.Floor(circle.Progress));
                }
            }
        }
开发者ID:RossDay,项目名称:Leap,代码行数:54,代码来源:GrabAndScroll.cs

示例7: Update

	// Update is called once per frame
	void Update () {
        frame = controller.Frame();
        GestureList gestures = frame.Gestures();
        if(gestures.Count != 0)
        {
            foreach (Gesture gest in gestures)
			{
				if(gest.Type == Gesture.GestureType.TYPE_KEY_TAP)
				{
					Debug.Log (gest.Hands.Frontmost.Fingers[1].TipPosition);
					Leap.Vector fingerPosition = gest.Hands.Frontmost.Fingers[1].TipPosition;
					float x = fingerPosition.x;
					float y = fingerPosition.y;
					float z = fingerPosition.z;
					Vector3 position = new Vector3(x,y,z);
					Collider[] close_things =
						Physics.OverlapSphere(position.normalized, 2, -1);
					
					GameObject closest = null;
					float closestDistance = Mathf.Infinity;
					GrabbableObject[] listOfGrabbableObjects= new GrabbableObject[10];
					GameObject[] listOfGameObjects = GameObject.FindGameObjectsWithTag("GrabbableObject");

					

					//float closest_sqr_distance = 2 * 2;
					
					for (int j = 0; j < listOfGameObjects.Length; ++j) {
						if(listOfGameObjects[j] != null)
						{
							float dist = Vector3.Distance (position.normalized, listOfGameObjects[j].transform.position);
							if(closestDistance > dist)
							{
								closest = listOfGameObjects[j];
								closestDistance = dist;
							}
						}
					}
				
					Debug.Log (closest.name.ToString());
				}
			}
                //Debug.Log(gest.Type.ToString());
        }
        
	}
开发者ID:Nindustrialist,项目名称:VRBreadboarding,代码行数:47,代码来源:SimpleGestureRecognize.cs

示例8: Update

    // Update is called once per frame
    void Update()
    {
        frame = hc.GetFrame();

        foreach (Gesture gesture in frame.Gestures())
        {

            switch (gesture.Type)
            {
                case (Gesture.GestureType.TYPESCREENTAP):
                    {
                        audioSource.PlayOneShot(SFX_SELECT, SETTINGS.MASTER_VOLUME * SETTINGS.SFX_VOLUME);
                        StartCoroutine(PressSelectedButton());
                        break;
                    }
                case (Gesture.GestureType.TYPESWIPE):
                    {
                        swipe = new SwipeGesture(gesture);

                        if (!isSwiping && swipe.Direction.y > 0)
                        {
                            StartCoroutine(CycleUp(delay));
                        }

                        else if (!isSwiping && swipe.Direction.y < 0)
                        {
                            StartCoroutine(CycleDown(delay));
                        }

                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        }
    }
开发者ID:Liljan,项目名称:Handgun,代码行数:39,代码来源:LeapMenuHandler.cs

示例9: SecondaryUpdate

    private void SecondaryUpdate()
    {
        try
        {

            frame = controller.Frame();
            controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
            gestLst = frame.Gestures();
            foreach (Gesture ges in gestLst)
            {

                /*getting the SWIPE GESTURE  */
                if((ges.Type == Gesture.GestureType.TYPESWIPE)&&(piece.rigidbody.isKinematic == false))
            {
               // respawn();
            }
            }

            if ((!frame.Hands.Empty))

            {

                hand = frame.Hands[0];
                hand1 = frame.Hands[1];
                //actualCordX = ((((100 - (float)hand.PalmPosition.x) / 100) * BOARD_WIDTH_X) - (BOARD_WIDTH_X/2));
               // actualCordZ = ((((100 - (float)hand.PalmPosition.z) / 100) * BOARD_LENGTH_Z) - (BOARD_LENGTH_Z/2));
                actualCordX = (hand.PalmPosition.x / 100) * -2.38f;
                actualCordZ = (hand.PalmPosition.z / 100) * -2.4f;

                //Debug.Log(hand.PalmNormal.x.ToString());
                actualCordY = (hand.PalmPosition.y/40) - 5;

                #region for incase it need to move the piece discreatly on the board
                //if (piece.rigidbody.velocity.y == 0.0f)
                    //{

                    //    piece.transform.position = gpArray[getPlaneSlote(pla.transform.position.x, pla.transform.position.z)].X_center;
                    //}
                    #endregion

                //pla.transform.position = gpArray[getPlaneSlote(actualCordX, -actualCordZ)].X_center;

                //////////////////////////     codition  when palm is open   ////////////////////////////

                if (hand.Fingers.Count > 2)
                {

                    piece.rigidbody.isKinematic = false;
                    if (!isHandOpen)
                    {
                        virtualHand.animation.Play("release");
                        //isHandOpen = true;
                    }
                    isHandOpen = true;

                    if (grabbed == true)
                    {
                    stablePieceposition = gpArray[getPlaneSlote(piece.transform.position.x, piece.transform.position.z)].X_center;
                    stableVelocity = ((new Vector3(stablePieceposition.x, 0, stablePieceposition.z) - new Vector3(piece.transform.position.x, 0, piece.transform.position.z)));
                    //piece.rigidbody.velocity = stableVelocity*2;
                    //piece.rigidbody.MovePosition();
                    Debug.Log("Only once on releasing the piece!!!");
                    }
                    //else
                    //{
                    //    stablePieceposition = piece.transform.position;
                    //}

                    grabbed = false;

                    endPointTrigger = false;
                    motionForward = true;
                    pla.renderer.material.color = Color.green;

                }
                                     ////////////////    codition when palm is closed/////////////////////
                else if (hand.Fingers.Count < 3)
                {
                    if (isHandOpen)
                    {
                        virtualHand.animation.Play("handsSkin");

                    }
                    isHandOpen = false;

                    pla.renderer.material = Resources.Load("n", typeof(Material)) as Material;
                    if ((pla.transform.position.x == piece.transform.position.x) && ((pla.transform.position.z == piece.transform.position.z)) && (grabbed == false))
                    {

                        grabbed = true;

                        if (!endPointTrigger)
                        {
                            startPoint = virtualHand.transform.position;
                            endPoint = new Vector3(piece.transform.position.x-0.3f,-1.8f,piece.transform.position.z);
                            endPointTrigger = true;
                            transitionComplete = false;
                        }
                        piece.rigidbody.isKinematic = true;

//.........这里部分代码省略.........
开发者ID:rohalchandrakar2007,项目名称:leap_motion,代码行数:101,代码来源:MainScript.cs

示例10: SwipeRight

        private AcceptedGestures SwipeRight(Frame frame)
        {
            GestureList gestures = frame.Gestures();

            List<Hand> hands = DetectedHands(frame.Hands);
            List<Finger> fingers = ExtendedFingers(hands[0].Fingers, false);

            if (gestures.Count > 0) {
                foreach (Gesture gesture in gestures) {
                    if (gesture.Type == Gesture.GestureType.TYPESWIPE && gesture.State == Gesture.GestureState.STATESTOP) {
                        SwipeGesture swipe = new SwipeGesture(gesture);
                        if (swipe.Speed >= SWIPE_SPEED && fingers.Count == 2 && swipe.Direction.x >= SWIPE_RIGHT_DIRECTION) {
                            Log("Gesture: Answer/Finish Call");
                            gestureType = AcceptedGestures.AnswerCall;
                            return gestureType;
                        }
                        else if (swipe.Speed >= SWIPE_SPEED && swipe.Direction.x >= SWIPE_RIGHT_DIRECTION) {
                            Log("Gesture: Swipe Right");
                            gestureType = AcceptedGestures.SwipeRight;
                            return gestureType;
                        }
                    }
                }
            }
            return AcceptedGestures.InvalidGesture;
        }
开发者ID:RomeoInc,项目名称:InCarGestureInteraction,代码行数:26,代码来源:CountDetector.cs

示例11: Update

    // Update is called once per frame
    void Update()
    {
        Frame frame = new Frame();
        frame = controller.Frame(); // each frame object contains a snapshot of the scene's data (i.e. postions, entities)
        GestureList gestures = frame.Gestures(lastFrame); //List of the Gesture objects within that frame, note they are not reported as events
        lastFrame = frame;                                //Instead they are added to the frames that are within the life time of the gesture
        /*
        for (int i = 0; i < gestures.Count; i++)
        {
            Gesture gesture = gestures[i];
            if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP && gesture.Hands[0].IsRight)
            {
                KeyTapGesture tap = new KeyTapGesture(gesture);
                GameObject newCube = Instantiate(cube);
                newCube.transform.position = box.transform.position;
                newCube.transform.rotation = box.transform.rotation;
                newCube.transform.parent = box.transform;

                Vector tapPosition = tap.Position;
                Vector3 correctedPos = handController.transform.TransformPoint(tapPosition.ToUnityScaled());
                //correctedPos.y = correctedPos.y - 1.5f;
                //correctedPos.z = correctedPos.z - 0.3f;
                //newCube.transform.position = SnapToGrid(correctedPos);
                snapPos = SnapToGrid(correctedPos);
                SpawnObject(curPlayer, snapPos);
                Vector3 arrayPos = UnityToArrayIndex(snapPos);
                xStr = "X: " + ((int)arrayPos.x).ToString();
                yStr = "Y: " + ((int)arrayPos.y).ToString();
                zStr = "Z: " + ((int)arrayPos.z).ToString();

                Debug.Log(correctedPos + " | " + snapPos);
            }
        }       */

        //Find the current position of the index finger and display it in a text box

        HandList hands = frame.Hands; //List of Hand's present in the scene, can recognize up to 5?
        Vector3 currentPos; //Tuple for the position vector in Unity's coordinates
        Vector tipPos; // Tuple for the position of index finger tip in Leap Motion coordinates
        foreach (Hand hand in hands)
        {
            if (hand.IsRight) //Only recognize a key tap from the right hand
            {
                foreach (Finger finger in hand.Fingers)
                {
                    if ( (int)finger.Type == 1) // referes to index finger
                    {
                        for (int i = 0; i < gestures.Count; i++)
                        {
                            Gesture gesture = gestures[i];
                            if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP && gesture.Hands[0].IsRight)
                            {
                                // tapping will terminate the end game screen and restart the game
                                if (gameOver == 1)
                                {
                                    // the Transform refers to the object's position, rotation, scale
                                    foreach (Transform child in objects.transform) // basically destroys every object
                                        Destroy(child.gameObject);
                                    logic.reInitializeArray();
                                    //if (objects != null)
                                    //objects = GameObject.Find("Objects");
                                    gameOver = 0;
                                    curPlayer = 1;
                                    winStr = "";
                                }
                                else
                                {

                                    KeyTapGesture tap = new KeyTapGesture(gesture);
                                    /*newCube.transform.position = box.transform.position;
                                    newCube.transform.rotation = box.transform.rotation;
                                    newCube.transform.parent = box.transform;
                                    */
                                    // Convert Leap coordinates to Unity coordinates
                                    Vector tapPosition = tap.Position;
                                    Vector3 correctedPos = handController.transform.TransformPoint(tapPosition.ToUnityScaled()); //taken from documentation
                                    //correctedPos.y = correctedPos.y - 1.5f;
                                    //correctedPos.z = correctedPos.z - 0.3f;
                                    //newCube.transform.position = SnapToGrid(correctedPos);
                                    snapPos = SnapToGrid(correctedPos);
                                    if (snapPos.x > 3f || snapPos.y > 3f || snapPos.z > 3f) //tapping out side the cube undos the last move
                                    {
                                        Undo(lastMove); // lastMove is the GameObject representing the players token
                                        if (curPlayer == 1)
                                        {
                                            //Debug.Log("hello");
                                            curPlayer = 2;
                                        }
                                        else
                                            curPlayer = 1;
                                    }else{
                                        SpawnObject(curPlayer, snapPos); //placed the corresponding player token at that location
                                    }
                                    Vector3 arrayPos = UnityToArrayIndex(snapPos); // to be used in the logic
                                }
                            }
                        }

                        // live display of the index fingers current position (index of 3d array)
//.........这里部分代码省略.........
开发者ID:h397wang,项目名称:SpaceTTT,代码行数:101,代码来源:Main.cs

示例12: SwipeDown

        private AcceptedGestures SwipeDown(Frame frame)
        {
            GestureList gestures = frame.Gestures();

            if (gestures.Count > 0)
            {
                foreach (Gesture gesture in gestures)
                {
                    if (gesture.Type == Gesture.GestureType.TYPESWIPE && gesture.State == Gesture.GestureState.STATESTOP)
                    {
                        SwipeGesture swipe = new SwipeGesture(gesture);
                        if (swipe.Speed >= SWIPE_VERTICAL && swipe.Direction.y <= SWIPE_DOWN_DIRECTION)
                        {
                            Log("Gesture: Swipe Down");
                            gestureType = AcceptedGestures.SwipeDown;
                            return gestureType;
                        }
                    }
                }
            }
            return AcceptedGestures.InvalidGesture;
        }
开发者ID:RomeoInc,项目名称:InCarGestureApplication,代码行数:22,代码来源:CountDetector.cs

示例13: LogFrame

 /// <summary>
 /// Log diagnostic information about the given Frame object.
 /// </summary>
 private void LogFrame(Frame frame)
 {
     Log(String.Format("Frame {0}, Hands: {1}, Fingers: {2}, Tools: {3}, Gestures: {4}",
         frame.Id, frame.Hands.Count, frame.Fingers.Count, frame.Tools.Count, frame.Gestures().Count));
 }
开发者ID:RomeoInc,项目名称:InCarGestureInteraction,代码行数:8,代码来源:LeapListener.cs

示例14: WindowUp

        private AcceptedGestures WindowUp(Frame frame)
        {
            GestureList gestures = frame.Gestures();

            List<Hand> hands = DetectedHands(frame.Hands);
            if (hands.Count > 0)
            {
                List<Finger> fingers = ExtendedFingers(hands[0].Fingers, false);

                if (gestures.Count > 0)
                {
                    foreach (Gesture gesture in gestures)
                    {
                        if (gesture.Type == Gesture.GestureType.TYPESWIPE && gesture.State == Gesture.GestureState.STATESTOP)
                        {
                            SwipeGesture swipe = new SwipeGesture(gesture);

                            if (swipe.Speed >= SWIPE_UP && fingers.Count == 2 && swipe.Direction.y >= SWIPE_UP_DIRECTION)
                            {
                                Log("Gesture: Open Both Windows");
                                gestureType = AcceptedGestures.BothClosed;
                                return gestureType;
                            }

                            else if (swipe.Speed >= SWIPE_UP && swipe.Direction.y >= SWIPE_UP_DIRECTION)
                            {
                                if (swipe.Position.x >= 0)
                                {
                                    Log("Gesture: Open Driver Window");
                                    gestureType = AcceptedGestures.DriverClosed;
                                    return gestureType;
                                }
                                else if (swipe.Position.x < 0)
                                {
                                    Log("Gesture: Open Passenger Window");
                                    gestureType = AcceptedGestures.PassengerClosed;
                                    return gestureType;
                                }

                            }
                        }
                    }
                }
            }
            return AcceptedGestures.InvalidGesture;
        }
开发者ID:RomeoInc,项目名称:InCarGestureApplication,代码行数:46,代码来源:CountDetector.cs

示例15: Rotate

        private AcceptedGestures Rotate(Frame frame)
        {
            GestureList gestures = frame.Gestures();

            if (gestures.Count > 0) {
                foreach (Gesture gesture in gestures) {
                    if (gesture.Type == Gesture.GestureType.TYPECIRCLE && gesture.State == Gesture.GestureState.STATESTOP) {
                        CircleGesture circle = new CircleGesture(gesture);
                        if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4 && circle.Progress > 0.80) {
                            Log("Gesture: Clockwise Rotation");
                            gestureType = AcceptedGestures.RotateClockwise;
                            return gestureType;
                        }
                        else if (circle.Progress > 0.80)
                        {
                            Log("Gesture: Anti-Clockwise Rotation");
                            gestureType = AcceptedGestures.RotateAntiClockwise;
                            return gestureType;
                        }
                    }
                }
            }
            return AcceptedGestures.InvalidGesture;
        }
开发者ID:RomeoInc,项目名称:InCarGestureApplication,代码行数:24,代码来源:CountDetector.cs


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