コード例 #1
0
    void ScaleSpawnedObject()
    {
        Debug.Log("In scale spawned object");
        if (stateHandler.currentState == spawnObjectState || stateHandler.currentState == moveObjectState || stateHandler.currentState == dropObjectState)
        {
            if (TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Finger) && TrackGestures.GetGesture(MLHands.Left, MLHandKeyPose.Finger))
            {
                if (originalDistance == float.MinValue)
                {
                    originalDistance = Vector3.Distance(MLHands.Right.Center, MLHands.Left.Center);
                }

                float scaleFactor = Vector3.Distance(MLHands.Right.Center, MLHands.Left.Center) - originalDistance;

                scaleFactor = scaleFactor / scaleSensitivity;

                currentObject.localScale = new Vector3(currentObject.localScale.x + scaleFactor, currentObject.localScale.y + scaleFactor, currentObject.localScale.z + scaleFactor);
            }
            else
            {
                if (originalDistance != float.MinValue)
                {
                    originalDistance = float.MinValue;
                }
            }
        }
    }
コード例 #2
0
    void MoveIndicator()
    {
        //first check whether the current state is equal to the MoveIndicator state
        //if not, return;

        //log a message to the console of the current state you are in
        //if you press a certain key, switch state to the next state

        //create an additional two states along with two matching methods

        if (stateHandler.currentState != moveIndicator)
        {
            return;
        }


        Debug.Log("In move indicator");
        //if (TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Thumb))
        //{
        //    InstantiateObject(MLHands.Right.Center, indicatorPrefab);
        //}

        //else if some gesture = specify hand and specify the thumb pose (left hand)
        //spawn the indicator prefab

        //if (TrackGestures.GetGesture(MLHands.Left, MLHandKeyPose.Thumb))
        //{
        //    InstantiateObject(MLHands.Left.Center, indicatorPrefab);
        //}

        // check if the we're using the left hand and finger  gesture
        //Current indicator  position = the gesture position

        //do the same with the left hand and finger gesture
        if (TrackGestures.GetGesture(MLHands.Left, MLHandKeyPose.Finger))
        {
            currentIndicator.position = MoveObjectWithGesture.MoveObjectToPosition(MLHands.Left);
        }
        else if (TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Finger))
        {
            currentIndicator.position = MoveObjectWithGesture.MoveObjectToPosition(MLHands.Right);
        }

        if (eyeTracker.IsBlinking() && TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Thumb))
        {
            currentIndicator.gameObject.SetActive(false);
            currentObject    = Instantiate(objectToSpawn, currentIndicator.position, Quaternion.identity);
            currentIndicator = null;
            stateHandler.SwitchToNextState();
        }


        // nothing should happen unless the state is the Move idicator state
        // we want to check is the current state is the Move Indicator state (if it is, continue on in this method)

        //if a gesture is recognized, do the code below
        // write some code that will allow
    }
コード例 #3
0
 private void MoveSpawnedObject()
 {
     if ((stateHandler.currentState == spawnObjectState || stateHandler.currentState == moveObjectState))
     {
         if (TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Pinch))
         {
             currentObject.position = MoveObjectWithGesture.MoveObjectBetweenTwoFingers(MLHands.Right);
         }
         else if (TrackGestures.GetGesture(MLHands.Left, MLHandKeyPose.Pinch))
         {
             currentObject.position = MoveObjectWithGesture.MoveObjectBetweenTwoFingers(MLHands.Left);
         }
     }
 }
コード例 #4
0
    void SpawnIndicator()
    {
        //first check whether the current state is equal to the SpawnIndicator state
        //if not, return;

        //log a message to the console of the current state you are in
        //if you press a certain key, switch state to the next state

        //create an additional two states along with two matching methods

        if (stateHandler.currentState != spawnIndicator)
        {
            return;
        }

        Debug.Log("In spawn indicator");

        //if some gesture = specify hand and specify the thumb pose (right hand)
        //spawn the indicator prefab

        if (TrackGestures.GetGesture(MLHands.Right, MLHandKeyPose.Thumb))
        {
            InstantiateObject(MLHands.Right.Center, indicatorPrefab);
        }

        //else if some gesture = specify hand and specify the thumb pose (left hand)
        //spawn the indicator prefab

        if (TrackGestures.GetGesture(MLHands.Left, MLHandKeyPose.Thumb))
        {
            InstantiateObject(MLHands.Left.Center, indicatorPrefab);
        }

        //we want to make sure that the current state is the SpawnIndicator state to execute the code inside this method.

        //if gesture is recogized, do the ocde below
        //write some code that will spaw the indicator
        //change the state to the next state
    }