Beispiel #1
0
        void updatePose(InteractionSourcePose pose)
        {
            Vector3    angularVelocity, gripPosition, pointerPosition, pointerForward, gripForward;
            Quaternion gripRotation, pointerRotation;

            if (pose.TryGetPosition(out gripPosition, InteractionSourceNode.Grip))
            {
                _currentState.GripPosition = gripPosition;
            }

            if (pose.TryGetPosition(out pointerPosition, InteractionSourceNode.Pointer))
            {
                _currentState.PointerPosition = pointerPosition;
            }

            if (pose.TryGetRotation(out pointerRotation, InteractionSourceNode.Pointer))
            {
                _currentState.PointerRotation = pointerRotation;
            }


            if (pose.TryGetRotation(out gripRotation, InteractionSourceNode.Grip))
            {
                _currentState.GripRotation = gripRotation;
            }

            if (pose.TryGetForward(out pointerForward, InteractionSourceNode.Pointer))
            {
                _currentState.PointerForward = pointerForward;
            }

            if (pose.TryGetAngularVelocity(out angularVelocity))
            {
                _currentState.AngularVelocity = angularVelocity;
            }
        }
Beispiel #2
0
    public static ControllerReleaseData GetThrowReleasedVelocityAndAngularVelocity(this Rigidbody _rigidbody, Vector3 centerOfMassOfRigidbody, InteractionSourcePose poseInfo)
    {
        Vector3 setVel                    = default(Vector3);
        Vector3 angVel                    = default(Vector3);
        Vector3 controllerPos             = default(Vector3);
        Vector3 controllerVelocity        = default(Vector3);
        Vector3 controllerAngularVelocity = default(Vector3);

        poseInfo.TryGetPosition(out controllerPos);
        poseInfo.TryGetVelocity(out controllerVelocity);
        poseInfo.TryGetAngularVelocity(out controllerAngularVelocity);
        float dist = Vector3.Distance(centerOfMassOfRigidbody, controllerPos);

        //vel = velocityOfController + angularVelOfController * distBetween grabbable center of mass and controllerPos;
        //setVel = controllerVelocity + controllerAngularVelocity + (controllerAngularVelocity *-1) * dist;
        setVel = controllerVelocity;
        Debug.Log(" SetVal = ControllerVelocity ( " + controllerVelocity + ") controllerAngVel ((" + controllerAngularVelocity + ") * -1 )" + "  * dist (" + dist + ")");

        return(new ControllerReleaseData(setVel, angVel));
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        current_color = ColorBank[0];
        rainbowActive = 0;
        rainbowInt    = 0;
        ref_distance  = 20.0f;

        if (showHandCrsr)
        {
            _crs = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            _crs.transform.localScale = new Vector3(0.04f, 0.04f, 0.04f);
            _crs.GetComponent <Renderer>().material.color = Color.green;
            _crs.GetComponent <Collider>().enabled        = false;
            _crs.SetActive(false);
        }

        numOfPoints   = 0;
        tapRecognizer = new GestureRecognizer();
        poseTest      = new InteractionSourcePose();
        tapRecognizer.SetRecognizableGestures(GestureSettings.Tap);
        tapRecognizer.Tapped += TapRecognizer_Tapped;
        tapRecognizer.StartCapturingGestures();

        KeywordRecognizer keywordRecognizer_erase = new KeywordRecognizer(new[] { "erase" });

        keywordRecognizer_erase.OnPhraseRecognized += KeywordRecognizer_erase_OnPhraseRecognized;
        keywordRecognizer_erase.Start();

        KeywordRecognizer keywordRecognizer_restart = new KeywordRecognizer(new[] { "restart" });

        keywordRecognizer_restart.OnPhraseRecognized += KeywordRecognizer_restart_OnPhraseRecognized;
        keywordRecognizer_restart.Start();

        keywords.Add("Erase", () =>
        {
            Debug.Log("erase word recognized!");
            if (writeState == 0)
            {
                DeleteDrawing();
            }

            Debug.Log("restart recognized! THIS IS THE SECOND METHOD!");
        });
        keywords.Add("Clear all", () =>
        {
            Debug.Log("Clear all word recognized");
            if (writeState == 0)
            {
                DeleteAll();
            }
        });

        //Add Voice Recognition for Changing Color to: Blue
        keywords.Add("Color Blue", () =>
        {
            Debug.Log("Color changed to Blue");
            current_color = ColorBank[4];
            ////Keep Code below for example with Shading and Color.Lerp feature
            //if (writeState == 0)
            //{
            //    int ref_point;
            //    int last_index = drawingLengths.Count - 1;
            //    ref_point = numOfPoints - drawingLengths[last_index];

            //    for (int i = SingleDraw.Count - 1; i >= ref_point; i--)
            //    {
            //        Renderer rend = SingleDraw[i].GetComponent<Renderer>();
            //        m_Material = rend.material; ;
            //        m_Material.color = ColorBank[4];
            //    }
            //}
        });
        //Add Voice Recognition for Changing Color to: Red
        keywords.Add("Color Red", () =>
        {
            Debug.Log("Color changed to Red");
            rainbowActive = 0;
            current_color = ColorBank[1];
        });
        //Add Voice Recognition for Changing Color to: Green
        keywords.Add("Color Green", () =>
        {
            Debug.Log("Color changed to Green");
            rainbowActive = 0;
            current_color = ColorBank[3];
        });
        //Add Voice Recognition for Changing Color to: Yellow
        keywords.Add("Color Yellow", () =>
        {
            Debug.Log("Color changed to Yellow");
            rainbowActive = 0;
            current_color = ColorBank[2];
        });
        //Add Voice Recognition for Changing Color to: White
        keywords.Add("Color White", () =>
        {
            Debug.Log("Color changed to White");
            rainbowActive = 0;
            current_color = ColorBank[0];
        });
        keywords.Add("Color Grey", () =>
        {
            Debug.Log("Color changed to Grey");
            rainbowActive = 0;
            current_color = ColorBank[5];
        });
        keywords.Add("Color Gray", () =>
        {
            Debug.Log("Color changed to Gray");
            rainbowActive = 0;
            current_color = ColorBank[5];
        });

        //Add Rainbow Wheel of Colors
        keywords.Add("Color Rainbow", () =>
        {
            rainbowActive = 1;
        });
        //Add Voice Recognition for Start Drawing:
        keywords.Add("Start Drawing", () =>
        {
            Debug.Log("Start Drawing Initiated");
            if (writeState == 0) //Turn ON writing
            {
                writeState = 1;
            }
        });
        //Add Voice Recognition for Stop Drawing:
        keywords.Add("Stop Drawing", () =>
        {
            Debug.Log("Stop Drawing Initiated");
            if (writeState == 1)//Turn OFF writing
            {
                //Save the number of points for a single drawing in an int array
                addedPoints       = SingleDraw.Count - numOfPoints;
                previousNumPoints = previousNumPoints + addedPoints;
                drawingLengths.Add(SingleDraw.Count - numOfPoints);

                //Update numOfPoints
                numOfPoints = SingleDraw.Count;

                Debug.Log("Size of SingleDraw BEFORE clear: " + SingleDraw.Count());
                Debug.Log("Size of AllDrawings: " + AllDrawings.Count());
                Debug.Log("Size of SingleDraw AFTER clear: " + SingleDraw.Count());
                writeState = 0;
            }
        });

        //Save all of the Keywords into the KeywordRecognizer
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }