void Update() { Frame frame = this.m_Provider.CurrentFrame; Hand[] hands = HandUtil.GetCorrectHands(frame); //0=LEFT, 1=RIGHT if (hands[HandUtil.LEFT] != null && hands[HandUtil.RIGHT] != null) { Hand leftHand = hands[HandUtil.LEFT]; Hand rightHand = hands[HandUtil.RIGHT]; if (this.handUtil.JustOpenedHandOn(hands, HandUtil.LEFT)) { //Moment that index finger of left hand is opened if (rightHand.Fingers[(int)FingerType.TYPE_INDEX].IsExtended) { Vector3 markingPoint = HandUtil.ToVector3(rightHand.Fingers[(int)FingerType.TYPE_INDEX].TipPosition); } } else if (this.handUtil.JustOpenedHandOn(hands, HandUtil.RIGHT)) { //Moment that index finger of right hand is opened if (leftHand.Fingers[(int)FingerType.TYPE_INDEX].IsExtended) { Vector3 markingPoint = HandUtil.ToVector3(leftHand.Fingers[(int)FingerType.TYPE_INDEX].TipPosition); FingerMapper.MarkPoint(this.mappedPoints, markingPoint); Debug.Log("Marked point at " + markingPoint); } } } if (SceneManager.GetActiveScene().name == FingerMapper.sceneName) { if (Input.GetKeyUp(KeyCode.E)) { this.Save(); } else if (Input.GetKeyUp(KeyCode.D)) { //foreach (Transform t in this.mappedPoints.transform) { Destroy(t.gameObject); } } } //this.handUtil.SavePreviousFingers(hands); this.handUtil.SavePreviousHands(hands); }
void Update() { Frame frame = this.m_Provider.CurrentFrame; Hand[] hands = HandUtil.GetCorrectHands(frame); //0=LEFT, 1=RIGHT if (hands[HandUtil.LEFT] != null || hands[HandUtil.RIGHT] != null) { Hand leftHand = hands[HandUtil.LEFT]; Hand rightHand = hands[HandUtil.RIGHT]; bool isJustOpenedLeftHand = this.handUtil.JustOpenedHandOn(hands, HandUtil.LEFT); bool isJustOpenedRightHand = this.handUtil.JustOpenedHandOn(hands, HandUtil.RIGHT); if (!this.isStartedLighting && (isJustOpenedLeftHand || isJustOpenedRightHand)) { Debug.Log("Opend a hand."); // 現在の光の位置と,次の光の位置を割り出す if (isJustOpenedLeftHand) { this.line.currentPoint = HandUtil.ToVector3(leftHand.PalmPosition); } else if (isJustOpenedRightHand) { this.line.currentPoint = HandUtil.ToVector3(rightHand.PalmPosition); } this.line.nextPoint = GetClosePoint(this.line.currentPoint); //this.TurnOnLight(1); // Light1をつける //this.TurnOnLight(2); // Light2をつける //this.light3Timer.Start(); //Light3をつけるまで待つ //this.lineTimer.Start(); //線の描画を待つ this.isStartedLighting = true; //Debug.Log(this.line.currentPoint + ", " + this.line.nextPoint); } } //時間が来たらlight3を点灯させる if (this.light3Timer.OnTime()) { this.TurnOnLight(3); // Light3をつける this.MakeLineObj(); //source pos=0, dest pos=0 } /* // ある程度光が放たれ,線を描画するタイミングが来たら,線を作成 * if (this.lineTimer.OnTime()) { * } */ if (this.line.isStarted) { if (this.line.progress < 1.0f) { //線描画が始まっていたら,線を放っていく this.ProgressLight(); } else { if (this.inactivePoints.Count > 0) { //次のポイントに変更 this.line.currentPoint = this.line.nextPoint; this.line.nextPoint = this.GetClosePoint(this.line.currentPoint); this.TurnOnLight(1); // Light1をつける this.TurnOnLight(2); // Light2をつける this.light3Timer.Start(); //Light3をつけるまで待つ this.line.progress = 0.0f; this.line.isStarted = false; } } } if (this.light3Timer.isStarted) { this.light3Timer.Clock(); } //if (this.lineTimer.isStarted) { this.lineTimer.Clock(); } }
void Update() { Frame frame = this.m_Provider.CurrentFrame; Hand[] hands = HandUtil.GetCorrectHands(frame); //0=LEFT, 1=RIGHT if (this.handUtil.JustOpenedHandOn(hands, this.attractorHandId)) { Debug.Log("Just OPENED RIGHT hand"); //Show attractor this.curAttractor = this.attractors[this.curAttractorIndex]; this.curAttractor.GetComponent <VisualEffect>().enabled = true; } else if (this.handUtil.JustClosedHandOn(hands, this.attractorHandId)) { Debug.Log("Just CLOSED RIGHT hand"); //Unshow attractor this.curAttractor.GetComponent <VisualEffect>().enabled = false; this.curAttractorIndex = (this.curAttractorIndex + 1) % this.attractors.Count; //Go next attractor } if (this.handUtil.JustOpenedFingerOn(hands, this.effectorHandId, (int)Finger.FingerType.TYPE_INDEX)) { Debug.Log("Just OPENED RIGHT index finger"); this.IsFingerEffector = true; } else if (this.handUtil.JustClosedFingerOn(hands, this.effectorHandId, (int)Finger.FingerType.TYPE_INDEX)) { Debug.Log("Just CLOSED RIGHT index finger"); this.IsFingerEffector = false; } //Attractor and hand exists if (this.curAttractor != null && hands[this.attractorHandId] != null) { Hand hand = hands[this.attractorHandId]; //手の中心とアトラクターとの距離から表示位置を割り出す Vector attractorPos = hand.PalmPosition + this.attractorDistances[this.curAttractorIndex] * hand.PalmNormal; //アトラクターの位置を補正(attractorAddPositions) this.curAttractor.transform.position = HandUtil.GetVector3(attractorPos) + this.attractorAddPositions[this.curAttractorIndex]; //アトラクターの回転を補正(attractorAddQuaternions) this.curAttractor.transform.rotation = HandUtil.GetQuaternion(hand.Rotation) * Quaternion.Euler(this.attractorAddQuaternions[this.curAttractorIndex]); } //FingerEffect and hand exists if (this.IsFingerEffector && hands[this.effectorHandId] != null) { Finger indexFinger = hands[this.effectorHandId].Fingers[(int)Finger.FingerType.TYPE_INDEX]; Vector3 tipPosition = HandUtil.GetVector3(indexFinger.TipPosition); this.fingerTip.transform.position = tipPosition; //Debug.Log("tipPos: " + tipPosition); } this.handUtil.SavePreviousHands(hands); this.handUtil.SavePreviousFingers(hands); this.previousHands = hands; //if (Input.GetKeyUp(KeyCode.F)) { }