Ejemplo n.º 1
0
        protected void InstallLights() {

            masterRoom.NumOfLights = 4;
            LiteSource = new AmbDiffSpecLights[4];

            // Set up a diffuse/specular light source
            // Due to the room model is too simplified, the light will 
            // have pretty much similar effect on all pixls
            LiteSource[0] = new AmbDiffSpecLights(this, 256);
            LiteSource[0].Position = new Vector4(0.0f, 128f, 0.0f, 1.0f);
            LiteSource[0].Coefficient_ambient = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);
            LiteSource[0].Coefficient_diffuse = new Vector4(0.7f, 0.7f, 0.7f, 1.0f);
            LiteSource[0].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[0].Shininess = 1.0f;
            LiteSource[0].Is_on = 1;
            LiteSource[0].Is_PointLight = 1;
            LiteSource[0].LightDirection = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); // Not used if this is a point light.
            LiteSource[0].Attenuation = new Vector4(1.0f, 0.000005f, 0.0f, 0.0f); // no attenuation

            // Set up a point light source

            LiteSource[1] = new AmbDiffSpecLights(this, 256);
            LiteSource[1].Position = new Vector4(-180.0f, 20.0f, -180.0f, 1.0f);
            LiteSource[1].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[1].Coefficient_diffuse = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
            LiteSource[1].Coefficient_specular = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
            LiteSource[1].Shininess = 4.0f;
            LiteSource[1].Is_on = 1;
            LiteSource[1].Is_PointLight = 1;
            LiteSource[1].LightDirection = new Vector4(-180.0f, 100.0f, -180.0f, 0.0f); // Not used if this is a point light.
            LiteSource[1].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

            // Set up a second point light source

            LiteSource[2] = new AmbDiffSpecLights(this, 256);
            LiteSource[2].Position = new Vector4(180.0f, 180.0f, 180.0f, 1.0f);
            LiteSource[2].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[2].Coefficient_diffuse = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
            LiteSource[2].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[2].Shininess = 8.0f;
            LiteSource[2].Is_on = 1;
            LiteSource[2].Is_PointLight = 1;
            LiteSource[2].LightDirection = new Vector4(1.0f, 0.0f, 1.0f, 0.0f); // Not used if this is a point light.
            LiteSource[2].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

            // Set up a third point light source

            LiteSource[3] = new AmbDiffSpecLights(this, 256);
            LiteSource[3].Position = new Vector4(0.0f, 60.0f, 170.0f, 1.0f);
            LiteSource[3].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[3].Coefficient_diffuse = new Vector4(0.3f, 0.3f, 1.0f, 1.0f);
            LiteSource[3].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            LiteSource[3].Shininess = 8.0f;
            LiteSource[3].Is_on = 1;
            LiteSource[3].Is_PointLight = 1;
            LiteSource[3].LightDirection = new Vector4(0.0f, 0.0f, 1.0f, 0.0f); // Not used if this is a point light.
            LiteSource[3].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

            for (int i = 0; i < masterRoom.NumOfLights; i++) {
                Components.Add(LiteSource[i]);
            }
        }
Ejemplo n.º 2
0
Archivo: Room.cs Proyecto: aliuy/MPG
        // Mostly copied from Game1.cs
        public void InstallLights()
        {
            NumOfLights = 4;
              LiteSource = new AmbDiffSpecLights[NumOfLights];

              // Set up a diffuse/specular light source
              // Due to the room model is too simplified, the light will
              // have pretty much similar effect on all pixels
              LiteSource[0] = new AmbDiffSpecLights(game);
              LiteSource[0].Position = new Vector4(0.0f, 100.0f, 0.0f, 1.0f);
              LiteSource[0].Coefficient_ambient = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);
              LiteSource[0].Coefficient_diffuse = new Vector4(0.1f, 0.1f, 0.1f, 1.0f);
              LiteSource[0].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[0].Shininess = 8.0f;
              LiteSource[0].Is_on = 1;
              LiteSource[0].Is_PointLight = 0;
              LiteSource[0].LightDirection = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); // will not be used if it is not a point light
              LiteSource[0].Attenuation = new Vector4(1.0f, 0.000005f, 0.0f, 0.0f); // no attenuation

              // Set up a point light source

              LiteSource[1] = new AmbDiffSpecLights(game);
              LiteSource[1].Position = new Vector4(-180.0f, 20.0f, -180.0f, 1.0f);
              LiteSource[1].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[1].Coefficient_diffuse = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
              LiteSource[1].Coefficient_specular = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
              LiteSource[1].Shininess = 4.0f;
              LiteSource[1].Is_on = 1;
              LiteSource[1].Is_PointLight = 1;
              LiteSource[1].LightDirection = new Vector4(-180.0f, 100.0f, -180.0f, 0.0f); // will not be used if it is not a point light
              LiteSource[1].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

              // Set up a second point light source

              LiteSource[2] = new AmbDiffSpecLights(game);
              LiteSource[2].Position = new Vector4(180.0f, 180.0f, 180.0f, 1.0f);
              LiteSource[2].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[2].Coefficient_diffuse = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
              LiteSource[2].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[2].Shininess = 8.0f;
              LiteSource[2].Is_on = 1;
              LiteSource[2].Is_PointLight = 1;
              LiteSource[2].LightDirection = new Vector4(1.0f, 0.0f, 1.0f, 0.0f); // will not be used if it is not a point light
              LiteSource[2].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

              // Set up a third point light source

              LiteSource[3] = new AmbDiffSpecLights(game);
              LiteSource[3].Position = new Vector4(0.0f, 60.0f, 170.0f, 1.0f);
              LiteSource[3].Coefficient_ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[3].Coefficient_diffuse = new Vector4(0.3f, 0.3f, 1.0f, 1.0f);
              LiteSource[3].Coefficient_specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
              LiteSource[3].Shininess = 8.0f;
              LiteSource[3].Is_on = 1;
              LiteSource[3].Is_PointLight = 1;
              LiteSource[3].LightDirection = new Vector4(0.0f, 0.0f, 1.0f, 0.0f);
              LiteSource[3].Attenuation = new Vector4(1.0f, 0.000075f, 0.0f, 0.0f); // smooth attenuation

              for (int i = 0; i < NumOfLights; i++)
              {
            game.Components.Add(LiteSource[i]);
              }

              // For Normal Mapping
              light.Type = Light.LightType.DirectionalLight;
              light.Direction = Vector3.Down;
              light.Position = new Vector3(0, 100, 0);
              light.Ambient = Color.White;
              light.Diffuse = Color.White;
              light.Specular = Color.White;
              light.SpotInnerConeRadians = MathHelper.ToRadians(20.0f);
              light.SpotOuterConeRadians = MathHelper.ToRadians(30.0f);
              light.Radius = LIGHT_RADIUS;
              globalAmbient = new Color(new Vector4(0.2f, 0.2f, 0.2f, 1.0f));
        }