Ejemplo n.º 1
0
        /// <summary>
        /// Initialize services :
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            LoadContent();
            Reloading += (s, e) => LoadContent();

            CreateTargets();
            GraphicsDevice.DisplayBoundsChanged += (s, e) => CreateTargets();


            var lr   = GetService <LightRenderer>();
            var rand = new Random(542);

            for (int i = 0; i < 1024; i++)
            {
                var light = new OmniLight();
                light.RadiusOuter = rand.NextFloat(3, 4);
                light.RadiusInner = light.RadiusOuter * 0.5f;
                light.Position    = rand.NextVector3(new Vector3(-50, 3, -50), new Vector3(50, 6, 50));
                //light.Position		=	Vector3.Up * 3; //new Vector3(10,2,20);
                //light.Position		=	new Vector3( (i/32)*3-48, 2.5f, (i%32)*3-48 );
                light.Intensity = rand.NextColor4() * 50;                            // new Color4(10,10,5,0);
                lr.OmniLights.Add(light);
            }

            var names = spotAtlas.SubImageNames;

            lr.MaskAtlas = spotAtlas;

            for (int i = 0; i < 16; i++)
            {
                var light = new SpotLight();

                var position = rand.NextVector3(new Vector3(-30, 20, -30), new Vector3(30, 20, 30));
                var target   = position + rand.NextVector3(new Vector3(-10, -35, -10), new Vector3(10, -35, 10));

                //position			=	rand.NextVector3( new Vector3(-50,50,-50), new Vector3(50,50,50) );
                //target				=	Vector3.Down * 20;

                light.Intensity   = rand.NextColor4() * 100;                          // new Color4(10,10,5,0);
                light.SpotView    = Matrix.LookAtRH(position, target, Vector3.Up);
                light.RadiusOuter = (target - position).Length() * 1.5f;
                light.RadiusInner = light.RadiusOuter * 0.5f;
                light.MaskName    = names[rand.Next(0, names.Length)];
                light.Projection  = Matrix.PerspectiveFovRH(MathUtil.DegreesToRadians(45), 1, 1f, light.RadiusOuter);

                lr.SpotLights.Add(light);
            }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Initialize services :
		/// </summary>
		protected override void Initialize ()
		{
			base.Initialize();

			LoadContent();
			Reloading += (s,e) => LoadContent();

			CreateTargets();
			GraphicsDevice.DisplayBoundsChanged += (s,e) => CreateTargets();


			var lr = GetService<LightRenderer>();
			var rand = new Random(542);
			
			for (int i=0; i<1024; i++) {
				var light = new OmniLight();
				light.RadiusOuter	=	rand.NextFloat(3, 4);
				light.RadiusInner	=	light.RadiusOuter * 0.5f;
				light.Position		=	rand.NextVector3( new Vector3(-50,3,-50), new Vector3(50,6,50) );
				//light.Position		=	Vector3.Up * 3; //new Vector3(10,2,20);
				//light.Position		=	new Vector3( (i/32)*3-48, 2.5f, (i%32)*3-48 );
				light.Intensity		=	rand.NextColor4()*50;// new Color4(10,10,5,0);
				lr.OmniLights.Add( light );
			}

			var names = spotAtlas.SubImageNames;

			lr.MaskAtlas	=	spotAtlas;

			for (int i=0; i<16; i++) {
				var light = new SpotLight();

				var position		=	rand.NextVector3( new Vector3(-30,20,-30), new Vector3(30,20,30) );
				var target			=	position + rand.NextVector3( new Vector3(-10, -35,-10), new Vector3(10, -35,10) );

				//position			=	rand.NextVector3( new Vector3(-50,50,-50), new Vector3(50,50,50) );
				//target				=	Vector3.Down * 20;

				light.Intensity		=	rand.NextColor4()*100;// new Color4(10,10,5,0);
				light.SpotView		=	Matrix.LookAtRH( position, target, Vector3.Up );
				light.RadiusOuter	=	(target - position).Length() * 1.5f;
				light.RadiusInner	=	light.RadiusOuter * 0.5f;
				light.MaskName		=	names[ rand.Next(0, names.Length) ];
				light.Projection	=	Matrix.PerspectiveFovRH( MathUtil.DegreesToRadians(45), 1, 1f, light.RadiusOuter );

				lr.SpotLights.Add( light );
			}
		}