void FixedUpdate() { // ___________________________________________________________________________________手势swipe模块 this.currentFrame = hc.GetFrame(); Frame frame = hc.GetFrame(); Frame lastframe = hc.getlastframe(); GestureList gestures = this.currentFrame.Gestures(); Vector swipedirection = null; foreach (Gesture g in gestures) { if (g.Type == Gesture.GestureType.TYPE_SWIPE) { SwipeGesture swipe = new SwipeGesture(g); swipedirection = swipe.Direction; //Debug.Log("direction is "+swipedirection); } } if (swipedirection.x > 0) { Debug.Log("right"); mark = 1; } if (swipedirection.x < 0) { Debug.Log("left"); mark = -1; } checkmark(mark); // ———————————————————————————————————————————————————————————————————————————————————————————————————————————— }
// Update is called once per frame void Update() { //get palm position from leap palmPos = controller.GetFrame().Hands [0].PalmPosition.ToUnityScaled(false); //get palm rotation from leap palmRot = controller.GetFrame().Hands [0].PalmNormal.ToUnity(false); handleTankMovement(palmPos); handleTankRotation(palmRot); }
// Update is called once per frame void Update() { Frame frame = hc.GetFrame(); Frame _Xframe = hc.get_X_frame(30); foreach (Hand hand in frame.Hands) //当前帧的手 { if (hand.IsLeft) { lefthand = hand; } if (hand.IsRight) { righthand = hand; } } foreach (Hand lasthand in _Xframe.Hands) { if (lasthand.IsLeft) { pre_lefthand = lasthand; } if (lasthand.IsRight) { pre_righthand = lasthand; } } Debug.Log("hand.pitch " + righthand.Direction.Pitch + " hand.yaw " + righthand.Direction.Yaw + " hand.roll " + righthand.Direction.Roll); Debug.Log("hand.x " + righthand.Direction.x + " hand.y " + righthand.Direction.y + " hand.z " + righthand.Direction.z); }
void Update() { Frame frame = handCtrl.GetFrame(); Hand rightHand = frame.Hands.Rightmost; HandList handsInFrame = frame.Hands; if (rightHand.IsValid) { transform.position = handCtrl.transform.TransformPoint(rightHand.PalmPosition.ToUnityScaled()); transform.rotation = handCtrl.transform.rotation * rightHand.Basis.Rotation(false); } if (handsInFrame.Count > 1 && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(shot, shotSpawn.position, shotSpawn.rotation); } // if (Input.GetButton ("Fire1") && Time.time > nextFire) // { // nextFire = Time.time + fireRate; // Instantiate (shot, shotSpawn.position, shotSpawn.rotation); // } }
// Update is called once per frame void Update() { Frame frame = noob.GetFrame(); color1 = Color.white; color2 = Color.black; //float t = Mathf.PingPong(Time.time, duration) / duration; // a = GameObject.Find("KnobbyFinger 1").GetComponent<Pointable>().TipPosition.z; //a = GameObject.Find("KnobbyFinger 1").GetComponent<Transform>().position.z; text = GameObject.Find("Text").GetComponent <UnityEngine.UI.Text>(); index_tip = bob.fingers[1].GetTipPosition(); //text.text = frame.Hands[0].PalmPosition.z.ToString();//frame.Finger(1).TipPosition.x.ToString();//index_tip.x.ToString();//bob.GetComponent<Transform>().position.x.ToString(); a = frame.Hands[0].PalmPosition.z; if (a * 0.05f + 0.3f < 1) { place = 1f; } else { place = 0f; } if (GameObject.Find("Sphere").GetComponent <TouchNumber>().activeToggle == 0) { camera.backgroundColor = Color.Lerp(color1, color2, a * 0.05f + 0.3f); } else { camera.backgroundColor = Color.black; } }
// Update is called once per frame void Update() { //checks before shoot if ((controller.GetFrame().Hands [0].GrabStrength == 1f || Input.GetKeyUp("space")) && (!shooting)) { //play shoot sound audioSource.Play(); shooting = true; shootDir = transform.forward; shootPos = new Vector3(transform.position.x + transform.forward.x * 15f, transform.position.y + 4f, transform.position.z + transform.forward.z * 15f); //create shoot explosion exp = Instantiate(explosion, shootPos, new Quaternion(0f, 0f, 0f, 0f)) as GameObject; //instantate new projectile instantiatedProjectile = Instantiate(projectile, shootPos, new Quaternion(0f, 0f, 0f, 0f)) as GameObject; shootDir = transform.forward; } //to move projectile if (shooting) { instantiatedProjectile.transform.position += shootDir * 6f; } }
/* * * Enumerable接口是非常的简单,只包含一个抽象的方法GetEnumerator(), * 它返回一个可用于循环访问集合的IEnumerator对象。IEnumerator对象有什么呢? * 它是一个真正的集合访问器,没有它,就不能使用foreach语句遍历集合或数组, * 因为只有IEnumerator对象才能访问集合中的项,假如连集合中的项都访问不了, * 那么进行集合的循环遍历是不可能的事情了。那么让我们看看IEnumerator接口有定义了什么东西。 * IEnumerator接口定义了一个Current属性, * MoveNext和Reset两个方法, * 既然IEnumerator对象时一个访问器,那至少应该有一个Current属性,来获取当前集合中的项 * MoveNext方法只是将游标的内部位置向前移动(就是移到一下个元素而已),要想进行循环遍历,不向前移动一下怎么行呢? * */ void Update() { foreach (var h in hc.GetFrame().Hands) { if (h.IsLeft) { lefthandexist = true; lefthand = h; } if (h.IsRight) { righthandexist = true; righthand = h; } } if (lefthandexist || righthandexist) { Application.LoadLevel("Sence2"); } if (Input.GetMouseButtonDown(0)) { //StartCoroutine(SwitchToPresentationScreen()); if (Application.loadedLevelName == "C#") { Debug.Log("Menu sence"); Application.LoadLevel("Sence2"); } } }
void TitleUpdate() { if (is_tutroial_) { return; } if (is_ready_) { return; } // ゲーム本編に移行 if (canShiftStart()) { foreach (var player in FindObjectsOfType <LobbyPlayer>()) { if (!player.isLocalPlayer) { continue; } player.ChangeReady(); is_ready_ = true; } } foreach (var hand in hand_controller_.GetFrame().Hands) { foreach (var gesture in hand.Frame.Gestures()) { if (!hand.IsRight) { continue; } var swipe_gesture = new SwipeGesture(gesture); if (swipe_gesture.IsValid) { is_tutroial_ = true; FindObjectOfType <SlideDirector>().StartSlide(); } } } if (Input.GetKeyDown(KeyCode.A)) { is_tutroial_ = true; FindObjectOfType <SlideDirector>().StartSlide(); } }
// Update is called once per frame void Update() { currentFrame = hd.GetFrame(); foreach (Hand hand in currentFrame.Hands) {// // if(hand.IsLeft) } }
// Use this for initialization void Start() { theHand = GameObject.FindGameObjectWithTag("handControl").GetComponent <HandController>(); Leap.Frame frame = theHand.GetFrame(); // controller is a Controller object Leap.HandList hands = frame.Hands; firstHand = hands[0]; Debug.Log("starting"); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public override void UpdateInput() { UpdateSettings(); Frame frame = vHandControl.GetFrame(); vFrame = (frame != null && frame.IsValid ? frame : null); vSideL.UpdateWithLeapHand(GetLeapHand(true)); vSideR.UpdateWithLeapHand(GetLeapHand(false)); }
void CheckFrames() { Frame frame = Controller.GetFrame(); if (frame.Id != lastId) { FrameValue = new FrameData(frame, Controller); lastId = frame.Id; } }
void Update() { if (!MyNetworkLobbyManager.s_singleton.IsTutorial) { if (!isLocalPlayer) { return; } if (GetComponent <GameEndDirector>().IsStart) { return; } } foreach (var hand in hand_controller_.GetFrame().Hands) { if (!hand.IsLeft) { continue; } var gesture_list = hand.Frame.Gestures(); foreach (Gesture gesture in gesture_list) { var magic_type = player_magic_manager_.MagicType; if (magic_type == -1) { break; } var circle_gesture = new CircleGesture(gesture); if (circle_gesture.IsValid) { if (!hand.IsLeft) { continue; } if (gesture.DurationSeconds < TURN_SECOND) { continue; } if (!player_magic_manager_.MagicExecute()) { continue; } magic_action_list_[magic_type](); AudioManager.Instance.PlaySe(11); break; } } break; } }
// Update is called once per frame void Update() { Frame frame = handCtrl.GetFrame(); Hand hand = frame.Hands.Frontmost; if (hand.IsValid) { transform.position = new Vector3(hand.PalmPosition.x, hand.PalmPosition.y, transform.position.z); //z should be 0 transform.position += constantVelocity * Time.deltaTime; transform.rotation = handCtrl.transform.rotation * hand.Basis.Rotation(false); } }
void GestureUpdate() { is_attack_ = false; if (!MyNetworkLobbyManager.s_singleton.IsTutorial) { CmdTellServerAttack(false); } foreach (var hand in hand_controller_.GetFrame().Hands) { if (!hand.IsRight) { continue; } var gesture_list = hand.Frame.Gestures(); foreach (Gesture gesture in gesture_list) { var circle_gesture = new CircleGesture(gesture); if (circle_gesture.IsValid) { if (circle_gesture.DurationSeconds < TURN_SECOND) { return; } CmdTellServerAttack(true); is_attack_ = true; var apple_num = tubo_in_destory_.GetApumonCount(); var lemon_num = tubo_in_destory_.GetLemonCount(); CmdTellServerFruitNum( apple_num, lemon_num); apple_num_ = apple_num; lemon_num_ = lemon_num; break; } } } }
void handFromFrame() { if ((FoundState.state == FOUND_STATE_NO_ID) || (FoundState.state == FOUND_STATE_HAND_INVALID)) { return; } else if (NoHandId) { FoundState.Change(FOUND_STATE_NO_ID); return; } Frame f = Controller.GetFrame(); if (f.Id == lastFrameId) { return; } if (!f.Hand(handId).IsValid) { FoundState.Change(FOUND_STATE_HAND_INVALID); return; } lastFrameId = f.Id; HandModel[] handsInScene = Controller.GetAllGraphicsHands(); HandModel oldFound = null; foreach (HandModel handInScene in handsInScene) { if ((!oldFound) && (handInScene.GetLeapHand().Id == handId)) { oldFound = handInScene; FoundState.Change(FOUND_STATE_FOUND); break; } } if (!oldFound) { FoundState.Change(FOUND_STATE_NOT_FOUND); } CurrentHand = oldFound; }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (!InputModuleUtil.FindCursorReference(this, ref CursorDataProvider, true)) { return; } if (!Application.isPlaying) { return; } CursorDataProvider.MarkAllCursorsUnused(); UpdateCursorsWithHands(LeapControl.GetFrame().Hands); Look.UpdateData(CursorDataProvider); CursorDataProvider.ActivateAllCursorsBasedOnUsage(); }
void AddHandPoints() { Frame frame = HandController.GetFrame(); if (frame.Hands.Count > 0) { HandModel handModel = RightmostHand(); if (handModel != null) { AddHandPoints(handModel); ReMesh(); } else { Debug.Log("No RM hand"); } } }
//1,DISTAL(tip) 2,INTERMEDIATE 3,PROXIMAL // Update is called once per frame void Update() { Leap.Frame frame = controller.GetFrame(); if (gestureOption == 0) { hands = frame.Hands; Leap.Hand hand = hands.Leftmost; //Debug.Log ("here"); if (hand.IsValid && hand.IsLeft) { Leap.FingerList fingers = hand.Fingers; Leap.Vector tipV = fingers[0].TipVelocity; float tipVmag = tipV.Magnitude; //Leap.Vector tipV2 = fingers[1].TipVelocity; Leap.Bone bone = fingers[0].Bone(Leap.Bone.BoneType.TYPE_DISTAL); //Leap.Bone bone2 = fingers[1].Bone (Leap.Bone.BoneType.TYPE_DISTAL); float distFromBoneToPalm = bone.Center.DistanceTo(hand.PalmPosition); float palmDirectionSign = hand.PalmNormal.Dot(vecUpInLeapForm); //Debug.Log (distFromBoneToPalm + " " + palmDirectionSign + " " + tipVmag + " " + hand.Confidence); //Debug.Log (bone.Direction.Pitch); if (distFromBoneToPalm < 70 && palmDirectionSign > 0.5 && tipVmag > 30 && hand.Confidence > 0.7) { getCollidersInARangeAndSendMessage(); } } } else if (gestureOption == 1) { Leap.GestureList gestures = frame.Gestures(); for (int i = 0; i < gestures.Count; i++) { if (gestures[i].Type == Leap.Gesture.GestureType.TYPESWIPE) { if (gestures[i].IsValid && gestures[i].State == Leap.Gesture.GestureState.STATESTOP) { Debug.Log("Yes"); getCollidersInARangeAndSendMessage(); } } } } }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (!Application.isPlaying) { return; } if (CursorDataProvider == null || LeapControl == null) { Debug.LogError("References to " + typeof(HoverCursorDataProvider).Name + " and " + typeof(HandController).Name + " must be set.", this); return; } CursorDataProvider.MarkAllCursorsUnused(); UpdateCursorsWithHands(LeapControl.GetFrame().Hands); UpdateCursorWithCamera(); CursorDataProvider.ActivateAllCursorsBasedOnUsage(); }
void Update() { if (controller_ == null) { return; } if (doUpdate == false) { return; } Frame frame = controller_.GetFrame(); if (frame.Images.Count == 0) { image_misses_++; if (image_misses_ == IMAGE_WARNING_WAIT) { // TODO: Make this visible IN applications Debug.LogWarning("Can't find any images. " + "Make sure you enabled 'Allow Images' in the Leap Motion Settings, " + "you are on tracking version 2.1+ and " + "your Leap Motion device is plugged in."); } return; } // Check main texture dimensions. Image image = frame.Images[imageIndex]; if (attached_device_.width != image.Width || attached_device_.height != image.Height) { if (!InitiatePassthrough(ref image)) { Debug.Log("InitiatePassthrough FAILED"); return; } } LoadMainTexture(ref image); LoadDistortion(ref image); }
// Update is called once per frame void Update() { Frame frame = hc.GetFrame(); GestureList gestures = frame.Gestures(); foreach (Gesture g in gestures) { // Swipe Geste if (g.Type == Gesture.GestureType.TYPESWIPE && g.State == Gesture.GestureState.STATE_STOP && g.Id != currentGestureId) { currentGestureId = g.Id; SwipeGesture swipeGesture = new SwipeGesture(g); Vector swipeDirection = swipeGesture.Direction; if (Mathf.Abs(swipeDirection.x) > Mathf.Abs(swipeDirection.y)) { if (swipeDirection.x < 0) { // Debug.Log ("Links"); swipeLeft(); break; } else if (swipeDirection.x > 0) { // Debug.Log ("Rechts"); swipeRight(); break; } } } } if (Input.GetKeyDown("left")) { swipeLeft(); } else if (Input.GetKeyDown("right")) { swipeRight(); } }
public void OnFrame (HandController controller) { // Get the most recent frame and report some basic information Frame frame = controller.GetFrame(); Frame lastframe = controller.getlastframe (); Debug.Log ("Frame id: " + frame.Id //帧ID + ", timestamp: " + frame.Timestamp //帧时间戳:从捕捉开始经过了多少毫秒 + ", hands: " + frame.Hands.Count //有几只手 + ", fingers: " + frame.Fingers.Count //有几只手指 + ", tools: " + frame.Tools.Count //有几个工具 + ", gestures: " + frame.Gestures ().Count); //手势计数 Debug.Log ("lastFrame id: " + lastframe.Id + ", lasttimestamp: " + lastframe.Timestamp + ", lasthands: " + lastframe.Hands.Count + ", lastfingers: " + lastframe.Fingers.Count + ", lasttools: " + lastframe.Tools.Count + ", lastgestures: " + lastframe.Gestures ().Count); }
public void Update() { if (Globals.GameOver) { return; } Globals.Update(Time.deltaTime); Frame frame = _handController.GetFrame(); Hand hand = frame.Hands.Rightmost; checkGrabbed(hand); getHandPosition(hand); var result = _controller.TrySetPosition(_handPosition); if (!result) { Globals.GameOver = true; } }
// Update is called once per frame void Update() { Vector3 sphereRadius = new Vector3(scaleFactor, scaleFactor, scaleFactor); transform.localScale = sphereRadius; Color color = new Color(r, g, b); GetComponent <Renderer>().material.SetColor("_Color", color); noob = GameObject.Find("HandController").GetComponent <HandController>(); Frame frame = noob.GetFrame(); // Toggle Behavior if (GameObject.Find("Main Camera").GetComponent <DepthColor>().place == 1f && frame.Hands[0].GrabStrength == 1) { activeToggle = 1; } // Turn Off Grab if leave if (frame.Hands[0].GrabStrength == 0) { activeToggle = 0; } // Grab is On if (activeToggle == 1) { GrabPan(frame, noob); colorSelect(frame, noob, m_FittsTarget); RegisterHit(frame, noob, dist); } // Mouse Mode is On if (mouseToggle == 1) { mouseColorSelect(m_FittsTarget); mouseRegisterHit(); } }
// 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; } } } }
// Funktion wird jeden Frame ein Mal aufgerufen void FixedUpdate() { Frame frame = hc.GetFrame(); if (frame.Hands.Count == 1) { // Steuerung des Cursors foreach (Hand hand in frame.Hands) { float temp = hand.PalmPosition.x; handPosition = temp / 100.0f; // geraten } } // Bewegung vorwärts rb.AddForce(0, 0, forwardSpeed * Time.deltaTime); // Bewegung zur Seite rb.AddForce(handPosition * (sidewaysSpeed * Time.deltaTime), 0, 0, ForceMode.VelocityChange); // Testen, ob der Ball von der Plattform gefallen ist if (transform.position.y < -0.5f) { FindObjectOfType <GameManagerScript>().EndGame(); } // Workaround: Ball springt manchmal ohne Fremdeinwirkung -> Problem wird hiermit behoben if (transform.position.y > 0.0f) { float tempX = transform.position.x; float tempZ = transform.position.z; transform.position = new Vector3(tempX, 0.0f, tempZ); } // Variable updaten distanceTravelled = transform.localPosition.z; }
// Update is called once per frame void Update() { Frame frame = hc.GetFrame(); if (frame.Hands.Count == 1) { // Steuerung des Cursors foreach (Hand hand in frame.Hands) { // Grab-Gesture if (grabGesture(hand)) { SceneManager.LoadScene(1, LoadSceneMode.Single); break; } } } if (Input.GetKeyDown(KeyCode.Space)) { SceneManager.LoadScene(1, LoadSceneMode.Single); } }
// Update is called once per frame void Update() { Frame f = Controller.GetFrame(); List <int> killIds = new List <int> (); foreach (int hid in AurorasForHand.Keys) { GameObject g = AurorasForHand [hid]; if (!g) { return; } GetHandById gh = g.GetComponent <GetHandById> (); if ((gh != null) && (gh.FoundState != null)) { if (gh.FoundState.state == GetHandById.FOUND_STATE_HAND_INVALID) { killIds.Add(hid); } } } foreach (int i in killIds) { AurorasForHand.Remove(i); } foreach (Hand h in f.Hands) { if (!AurorasForHand.ContainsKey(h.Id)) { AurorasForHand [h.Id] = NewAurora(h.Id); // Debug.Log ("Creating Aurora for hand Id " + h.Id); } } }
// Update is called once per frame void Update() { if (!GLOBAL.IS_PAUSED) { if (USE_MOUSE) { // MOUSE CODE, code to move crosshair pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, zDistance); pos = Camera.main.ScreenToWorldPoint(pos); transform.position = pos; } else { // LEAP MOTION, code to move crosshair FingerList fl = hc.GetFrame().Hands[currentHand].Fingers.FingerType(Finger.FingerType.TYPE_INDEX); Finger indexfinger = fl[0]; fingerpos = indexfinger.StabilizedTipPosition; Vector3 indexPostion = fingerpos.ToUnityScaled(false); transform.position = hc.transform.TransformPoint(indexPostion.x, indexPostion.y, 1f); } } }