Ejemplo n.º 1
0
    public void FixedUpdate()
    {
        /*
         * Objet utilisé pour un test : il faut créer une sphère, ou tout autre objet, dans Unity, et l'appeler BOULE.
         * Si ce script est présent quelque part, e.g. attaché à la sphère en question, quand on bouge la souris verticalement
         * ça fera bouger la sphère en conséquence.
         */
        //GameObject testBoule = GameObject.Find("BOULE");
        float   rotation = 0.0f;
        vrMouse mouse    = null;

        if (MiddleVR.VRDeviceMgr.GetMouse() != null)
        {
            mouse = MiddleVR.VRDeviceMgr.GetMouse();
        }

        if (Math.Abs(mouse.GetAxisValue(1)) > 0.1f)
        {
            rotation = mouse.GetAxisValue(1);
        }
        else if (Math.Abs(Input.GetAxis("Mouse Y")) > 0)
        {
            rotation = Input.GetAxis("Mouse Y");
        }

        /*
         * A décommenter pour le test de la boule, cf plus haut
         */
        //testBoule.transform.Translate(0,rotation*sensibility, 0);
        transform.Rotate(0, 0, rotation * sensibility);
    }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        vrMouse mouse = null;
        float   rotation = 0.0f; float rotVert = 0;

        //Checking if MiddleVR is tracking the mouse
        if (MiddleVR.VRDeviceMgr.GetMouse() != null)
        {
            mouse = MiddleVR.VRDeviceMgr.GetMouse();
        }
        GameObject cam = GameObject.Find("Tete");

        //we don't want to rely on the wand here

        /*float wandHorizontal = MiddleVR.VRDeviceMgr.GetWandHorizontalAxisValue();
         * if (Math.Abs(wandHorizontal) > 0.1f)
         * {
         *      rotation = wandHorizontal;
         * }*/
        //GetAxisValue gives the position offset on the given axis since last update
        //0 means axis X
        if (Math.Abs(mouse.GetAxisValue(0)) > 0.001f)
        {
            rotation = mouse.GetAxisValue(0);
        }
        else if (Math.Abs(Input.GetAxis("Mouse X")) > 0)
        {
            rotation = Input.GetAxis("Mouse X");
        }

        if (Math.Abs(mouse.GetAxisValue(1)) > 0.001f)
        {
            rotVert = mouse.GetAxisValue(1);
        }
        else if (Math.Abs(Input.GetAxis("Mouse Y")) > 0)
        {
            rotVert = Input.GetAxis("Mouse Y");
        }

        transform.Rotate(0, rotation * sensibility, 0, Space.World);
        transform.Rotate(rotVert * sensibility, 0, 0, Space.Self);
    }
Ejemplo n.º 3
0
        // Mouse
        public static Vector3 Position()
        {
            vrMouse mouse = MiddleVR.VRDeviceMgr.GetMouse();

            if (mouse == null)
            {
                Error("MiddleVR Mouse not found!");
                return(new Vector3());
            }
            var pos = mouse.GetCursorPosition();

#if UNITY_EDITOR
            // Convert absolute mouse coords from MVR to Unitys game window coordinates (   abs |_ vs. rel |- )
            var gameView         = GetMainGameView();
            var gameViewRect     = gameView.position;
            var gameViewMousePos = new Vector2(pos.x() - gameViewRect.x, (pos.y() - gameViewRect.yMax + 1) * -1);
            //Debug.Log(gameViewMousePos + " | Unity: " + Input.mousePosition);
            return(gameViewMousePos);
#else //Debug.Log("Mouse : " + pos.x() + ", " + pos.y() + " | Unity: " + Input.mousePosition);
            return(new Vector2(pos.x(), pos.y() * -1));
#endif
        }
 void Start()
 {
     obj   = GameObject.Find("Cube");
     mouse = MiddleVR.VRDeviceMgr.GetMouse();
 }
 void Start()
 {
     obj = GameObject.Find ("Cube");
     mouse = MiddleVR.VRDeviceMgr.GetMouse ();
 }