예제 #1
0
 //投げる動作か判定
 public bool IsThrownGesture(Hand hand)
 {
     if (hand != null)
     {
         if (this.IsPalmNormalSameDirectionWith(hand, HandUtil.ToVector3(hand.PalmVelocity)) &&
             !this.IsHandStayed(hand))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
    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);
    }
예제 #3
0
    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(); }
    }
예제 #4
0
 private bool IsPalmNormalSameDirectionWith(Hand hand, Vector3 dir)
 {
     return(this.IsAlmostSameDirection(HandUtil.ToVector3(hand.PalmNormal), dir));
 }
예제 #5
0
 private bool IsAlmostSameDirection(Vector a, Vector b)
 {
     return(this.IsAlmostSameDirection(HandUtil.ToVector3(a), HandUtil.ToVector3(b)));
 }
예제 #6
0
 private Vector3 GetHandVelocity(Hand hand)
 {
     return(this.playerTransform.InverseTransformDirection(HandUtil.ToVector3(hand.PalmVelocity)));
 }