////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public DemoEnvironment() {
			vHolds = new GameObject[Count];
			vCubes = new GameObject[Count];

			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);

			vMotionMap = new Dictionary<MotionType, DemoMotion> {
				{ MotionType.Orbit,	vOrbitMotion },
				{ MotionType.Spin,	vSpinMotion },
				{ MotionType.Bob,	vBobMotion },
				{ MotionType.Grow,	vGrowMotion }
			};

			vCameraMap = new Dictionary<CameraPlacement, Vector3> {
				{ CameraPlacement.Center,	Vector3.zero },
				{ CameraPlacement.Back,	new Vector3(0, 0, 20) },
				{ CameraPlacement.Top,	new Vector3(0, 0, 20) }
			};

			vCameraRotMap = new Dictionary<CameraPlacement, Quaternion> {
				{ CameraPlacement.Center, Quaternion.identity },
				{ CameraPlacement.Back,	Quaternion.identity },
				{ CameraPlacement.Top,	Quaternion.FromToRotation(Vector3.forward, Vector3.up) }
			};
		}
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public DemoEnvironment()
        {
            vHolds = new GameObject[Count];
            vCubes = new GameObject[Count];

            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);

            vMotionMap = new Dictionary <MotionType, DemoMotion> {
                { MotionType.Orbit, vOrbitMotion },
                { MotionType.Spin, vSpinMotion },
                { MotionType.Bob, vBobMotion },
                { MotionType.Grow, vGrowMotion }
            };

            vCameraMap = new Dictionary <CameraPlacement, Vector3> {
                { CameraPlacement.Center, Vector3.zero },
                { CameraPlacement.Back, new Vector3(0, 0, 20) },
                { CameraPlacement.Top, new Vector3(0, 0, 20) }
            };

            vCameraRotMap = new Dictionary <CameraPlacement, Quaternion> {
                { CameraPlacement.Center, Quaternion.identity },
                { CameraPlacement.Back, Quaternion.identity },
                { CameraPlacement.Top, Quaternion.FromToRotation(Vector3.forward, Vector3.up) }
            };
        }
Example #3
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;
        }