////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void Awake()
        {
            RandomUtil.Init(RandomSeed);

            vCubesObj = new GameObject("Cubes");
            vCubesObj.transform.SetParent(gameObject.transform, false);

            vLight     = GameObject.Find("Light").GetComponent <Light>();
            vSpotlight = GameObject.Find("Spotlight").GetComponent <Light>();
            vEnviro    = GameObject.Find("DemoEnvironment");

            for (int i = 0; i < Count; ++i)
            {
                BuildCube(i);
            }

            vSpotlight.enabled = false;

            ////

            GameObject ovrObj = GameObject.Find("LeapOVRPlayerController");

            if (ovrObj != null)
            {
                OVRPlayerController ovrPlayer = ovrObj.GetComponent <OVRPlayerController>();
                ovrPlayer.SetSkipMouseRotation(true);
            }
        }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("VR enabled: " + XRDevice.isPresent);
        XRSettings.enabled = XRDevice.isPresent;

        if (false == XRDevice.isPresent)
        {
            // Enable cursor if no vr device is connected
            // Otherwise the user couldn't click on our fancy HUD menu :)
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
        }
        else
        {
            Debug.Log("deactivate mosue");
            Transform           player     = GameObject.Find("OVRPlayerController").transform;
            OVRPlayerController controller = (OVRPlayerController)player.GetComponent("OVRPlayerController");
            controller.SetSkipMouseRotation(true);
        }

        // disable hands if no VR device connected (else we get spammed with error messages)
        vrHands.SetActive(XRDevice.isPresent);
        if (false == XRDevice.isPresent)
        {
            GameObject avatarMng = GameObject.Find("OvrAvatarSDKManager");
            if (null != avatarMng)
            {
                avatarMng.SetActive(false);
            }
        }

        configureVRControlability();
    }
    // Use this for initialization
    void Start()
    {
        OVRPlayerController playerController = FindObjectOfType <OVRPlayerController>();

        if (playerController)
        {
            playerController.SetSkipMouseRotation(true);
        }
    }
Beispiel #4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void Awake()
        {
            RandomUtil.Init(RandomSeed);

            vCubesObj = new GameObject("Cubes");
            vCubesObj.transform.SetParent(gameObject.transform, false);

            vLight     = GameObject.Find("Light").GetComponent <Light>();
            vSpotlight = GameObject.Find("Spotlight").GetComponent <Light>();
            vEnviro    = GameObject.Find("DemoEnvironment");

//			for ( int i = 0 ; i < Count ; ++i ) {
//				BuildCube(i);
//			}

            vSpotlight.enabled = false;

            ////

            GameObject ovrObj = GameObject.Find("LeapOVRPlayerController");

            if (ovrObj != null)
            {
                OVRPlayerController ovrPlayer = ovrObj.GetComponent <OVRPlayerController>();
                ovrPlayer.SetSkipMouseRotation(true);
            }

            vCameraMap = new Dictionary <CameraPlacement, Vector3> {
                { CameraPlacement.Sun, planets[0].transform.position },
                { CameraPlacement.Mercury, planets[1].transform.position },
                { CameraPlacement.Venus, planets[2].transform.position },
                { CameraPlacement.Earth, planets[3].transform.position },
                { CameraPlacement.Mars, planets[4].transform.position },
                { CameraPlacement.Jupiter, planets[5].transform.position },
                { CameraPlacement.Saturn, planets[6].transform.position },
                { CameraPlacement.Uranus, planets[7].transform.position },
                { CameraPlacement.Neptune, planets[8].transform.position },
                { CameraPlacement.Pluto, planets[9].transform.position }
            };

            vCameraRotMap = new Dictionary <CameraPlacement, Quaternion> {
                { CameraPlacement.Sun, Quaternion.identity },
                { CameraPlacement.Mercury, Quaternion.identity },
                { CameraPlacement.Venus, Quaternion.identity },
                { CameraPlacement.Earth, Quaternion.identity },
                { CameraPlacement.Mars, Quaternion.identity },
                { CameraPlacement.Jupiter, Quaternion.identity },
                { CameraPlacement.Saturn, Quaternion.identity },
                { CameraPlacement.Uranus, Quaternion.identity },
                { CameraPlacement.Neptune, Quaternion.identity },
                { CameraPlacement.Pluto, Quaternion.identity }
            };
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void Awake()
        {
            RandomUtil.Init(RandomSeed);

            ////

            var lightObj = new GameObject("Light");

            lightObj.transform.SetParent(gameObject.transform, false);
            lightObj.transform.localPosition = new Vector3(0, 1.5f, 0);

            vLight           = lightObj.AddComponent <Light>();
            vLight.type      = LightType.Point;
            vLight.range     = LightRange;
            vLight.intensity = 1;

            ////

            var pixObj = new GameObject("PixelLabel");

            pixObj.transform.SetParent(gameObject.transform, false);

            UiLabel pix = pixObj.AddComponent <UiLabel>();

            pixObj.SetActive(false);

            vPixels = new DemoTextPixels(pix);

            ////

            /*var boxesObj = new GameObject("Boxes");
             * boxesObj.transform.SetParent(gameObject.transform, false);
             * boxesObj.transform.localPosition = new Vector3(0, 0, 3.5f);
             * boxesObj.transform.localRotation =
             *      Quaternion.FromToRotation(Vector3.up, new Vector3(0, 1, -1.5f).normalized);
             * boxesObj.transform.localScale = Vector3.one*0.2f;
             *
             * vBoxes = boxesObj.AddComponent<DemoBoxes>();*/

            for (int i = 0; i < 6; ++i)
            {
                var lettHoldObj = new GameObject("LetterHold" + i);
                lettHoldObj.transform.SetParent(gameObject.transform, false);

                var lettObj = new GameObject("Letter");
                lettObj.transform.SetParent(lettHoldObj.transform, false);
                lettObj.transform.localScale = Vector3.one * 0.3f;

                var lett = lettObj.AddComponent <DemoLetter>();
                lett.RandomAxis = Random.onUnitSphere;
                vLetterCache.Add(lett);

                lettObj.SetActive(false);
            }

            ////

            for (int i = 0; i < 40; ++i)
            {
                var ringObj = new GameObject("Ring" + i);
                ringObj.transform.SetParent(gameObject.transform, false);
                ringObj.transform.localPosition = Random.onUnitSphere * 2;
                ringObj.transform.localRotation = Random.rotation;

                DemoRing ring = ringObj.AddComponent <DemoRing>();
                ring.Radius = RandomUtil.Float(LightRange * 0.4f) + 3;
            }

            ////

            GameObject ovrObj = GameObject.Find("LeapOVRPlayerController");

            if (ovrObj != null)
            {
                OVRPlayerController ovrPlayer = ovrObj.GetComponent <OVRPlayerController>();
                ovrPlayer.SetSkipMouseRotation(true);
            }
        }
Beispiel #6
0
    /// <summary>
    /// The GUI crosshair event.
    /// </summary>
    public void  OnGUICrosshair()
    {
        if ((DisplayCrosshair == true) && (CollisionWithGeometry == false))
        {
            FadeVal += Time.deltaTime / FadeTime;
        }
        else
        {
            FadeVal -= Time.deltaTime / FadeTime;
        }

        FadeVal = Mathf.Clamp(FadeVal, 0.0f, 1.0f);

        // Check to see if crosshair influences mouse rotation
        if (PlayerController != null)
        {
            PlayerController.SetSkipMouseRotation(false);
        }

        if ((ImageCrosshair != null) && (FadeVal != 0.0f))
        {
            // Assume cursor is on-screen (unless it goes into the dead-zone)
            // Other systems will check this to see if it is false for example
            // allowing rotation to take place
            if (PlayerController != null)
            {
                PlayerController.SetSkipMouseRotation(true);
            }

            GUI.color = new Color(1, 1, 1, FadeVal * FadeScale);

            // Calculate X
            XL += Input.GetAxis("Mouse X") * ScaleSpeedX;
            if (XL < DeadZoneX)
            {
                if (PlayerController != null)
                {
                    PlayerController.SetSkipMouseRotation(false);
                }

                XL = DeadZoneX - 0.001f;
            }
            else if (XL > (Screen.width - DeadZoneX))
            {
                if (PlayerController != null)
                {
                    PlayerController.SetSkipMouseRotation(false);
                }

                XL = ScreenWidth - DeadZoneX + 0.001f;
            }

            // Calculate Y
            YL -= Input.GetAxis("Mouse Y") * ScaleSpeedY;
            if (YL < DeadZoneY)
            {
                //CursorOnScreen = false;
                if (YL < 0.0f)
                {
                    YL = 0.0f;
                }
            }
            else if (YL > ScreenHeight - DeadZoneY)
            {
                //CursorOnScreen = false;
                if (YL > ScreenHeight)
                {
                    YL = ScreenHeight;
                }
            }

            // Finally draw cursor
            bool skipMouseRotation = true;
            if (PlayerController != null)
            {
                PlayerController.GetSkipMouseRotation(ref skipMouseRotation);
            }

            if (skipMouseRotation == true)
            {
                // Left
                GUI.DrawTexture(new Rect(XL - (ImageCrosshair.width * 0.5f),
                                         YL - (ImageCrosshair.height * 0.5f),
                                         ImageCrosshair.width,
                                         ImageCrosshair.height),
                                ImageCrosshair);
            }

            GUI.color = Color.white;
        }
    }
Beispiel #7
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void Start()
        {
            vHolds     = new GameObject[Count];
            vCubes     = new GameObject[Count];
            vLight     = GameObject.Find("Light").GetComponent <Light>();
            vSpotlight = GameObject.Find("Spotlight").GetComponent <Light>();
            vEnviro    = GameObject.Find("DemoEnvironment");
            vRandom    = new System.Random();

            for (int i = 0; i < Count; ++i)
            {
                BuildCube(i);
            }

            ////

            GameObject ovrPlayerObj = GameObject.Find("LeapOVRPlayerController");

            if (ovrPlayerObj != null)
            {
                OVRPlayerController ovrPlayer = ovrPlayerObj.GetComponent <OVRPlayerController>();
                ovrPlayer.SetSkipMouseRotation(true);
            }

            ////

            vOrbitMotion = new DemoMotion(10, 600);
            vSpinMotion  = new DemoMotion(45, 600);
            vBobMotion   = new DemoMotion(0.5f, 600);
            vGrowMotion  = new DemoMotion(0.5f, 600);

            vLightSpotAnim = new DemoAnimFloat(600);
            vCameraAnim    = new DemoAnimVector3(6000);
            vCameraRotAnim = new DemoAnimQuaternion(6000);

            ////

            DemoNavDelegate navDel = DemoNavComponent.NavDelegate;

            vNavItems = navDel.Items;

            vMotionMap = new Dictionary <int, DemoMotion> {
                { vNavItems.MotionOrbit.Id, vOrbitMotion },
                { vNavItems.MotionSpin.Id, vSpinMotion },
                { vNavItems.MotionBob.Id, vBobMotion },
                { vNavItems.MotionGrow.Id, vGrowMotion }
            };

            vCameraMap = new Dictionary <int, Vector3> {
                { vNavItems.CameraCenter.Id, Vector3.zero },
                { vNavItems.CameraBack.Id, new Vector3(0, 0, 20) },
                { vNavItems.CameraTop.Id, new Vector3(0, 0, 20) }
            };

            vCameraRotMap = new Dictionary <int, Quaternion> {
                { vNavItems.CameraCenter.Id, Quaternion.identity },
                { vNavItems.CameraBack.Id, Quaternion.identity },
                { vNavItems.CameraTop.Id, Quaternion.FromToRotation(Vector3.forward, Vector3.up) }
            };

            navDel.OnMotionChange += HandleMotionChange;
            navDel.OnCameraChange += HandleCameraChange;

            vNavItems.ColorWhite.OnValueChanged  += HandleColorWhiteToggle;
            vNavItems.ColorRandom.OnValueChanged += HandleColorRandomToggle;
            vNavItems.ColorCustom.OnValueChanged += HandleColorCustomToggle;
            vNavItems.LightSpot.OnSelected       += HandleLightSpotSelected;
            vNavItems.LightSpot.OnDeselected     += HandleLightSpotSelected;
            vNavItems.CameraReorient.OnSelected  += HandleCameraReorient;

            ////

            vNavItems.ColorWhite.Value      = true;
            vNavItems.ColorHue.IsEnabled    = false;
            vNavItems.ColorHue.ValueToLabel = ((v, sv) => "Hue: " + Math.Round(sv * 360));
            vNavItems.ColorHue.Value        = 0.333f;

            vNavItems.LightPos.Snaps        = 4;
            vNavItems.LightPos.Ticks        = 4;
            vNavItems.LightPos.Value        = 2 / 3f;
            vNavItems.LightPos.ValueToLabel = ((v, sv) => {
                string lbl = "";

                switch ((int)Math.Round(sv * 3))
                {
                case 0: lbl = "Lowest"; break;

                case 1: lbl = "Low"; break;

                case 2: lbl = "High"; break;

                case 3: lbl = "Highest"; break;
                }

                return("Pos: " + lbl);
            });

            vNavItems.LightInten.Value        = 0.5f;
            vNavItems.LightInten.ValueToLabel = ((v, sv) => "Power: " + Math.Round((sv * 120) + 20));

            vNavItems.CameraCenter.Value = true;

            vNavItems.MotionSpeed.Value        = (1 - SpeedMin) / SpeedRange;
            vNavItems.MotionSpeed.ValueToLabel =
                ((v, sv) => "Speed: " + ((sv * SpeedRange) + SpeedMin).ToString("0.0") + "x");

            UpdateLightPos();
            UpdateLightInten();
            UpdateMotionSpeed();
            vSpotlight.enabled = false;
        }