コード例 #1
0
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every frame
 /// until RemoveLight is called. Has priority over normal lights.
 /// </summary>
 /// <param name="light"></param>
 public override void AddSceneLight(Light light)
 {
     sceneLights.Add(light);
 }
コード例 #2
0
 /// <summary>
 /// Removes a light from the scene.
 /// </summary>
 /// <param name="light">Light</param>
 public override void RemoveLight(Light light)
 {
     dynamicLights.Remove(light);
     sceneLights.Remove(light);
 }
コード例 #3
0
        /// <summary>
        /// Applies contribution from a point light.
        /// </summary>
        /// <param name="light">Light</param>
        private void RenderPointLight(Light light, bool shadow)
        {
            pointLightEffect.CurrentTechnique = pointLightEffect.Techniques["PointLight"];
            //pointLightEffect.Parameters["xLightTex"].SetValue(lightMap);
            //pointLightEffect.Parameters["xLightViewProjection"].SetValue(cameraViewProjection);
            pointLightEffect.Parameters["xLightColorAndIntensity"].SetValue(light.Color.ToVector3() * light.Intensity);
            pointLightEffect.Parameters["xLightPosition"].SetValue(light.Location);

            // TODO: light volume shapes

            RenderEffectToScreen(pointLightEffect);
        }
コード例 #4
0
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every
 /// frame until RemoveLight is called.
 /// </summary>
 /// <param name="light">Light</param>
 public override void AddDynamicLight(Light light)
 {
     if (light.Type == LightType.Directional)
         throw new ArgumentException("Dynamic lights can't be directional");
     dynamicLights.Add(light);
 }
コード例 #5
0
        /// <summary>
        /// Applies contribution from a directional light.
        /// </summary>
        /// <param name="light">Light</param>
        private void RenderDirectionalLight(Light light, bool shadow)
        {
            if (light.Intensity != 0)
            {
                directionalLightEffect.CurrentTechnique = shadow
                    ? directionalLightEffect.Techniques["DirectionalLightShadow"]
                    : directionalLightEffect.Techniques["DirectionalLight"];
                directionalLightEffect.Parameters["xLightViewProjection"].SetValue(lightViewProjection);
                directionalLightEffect.Parameters["xLightColorAndIntensity"].SetValue(light.Color.ToVector3() * light.Intensity);
                directionalLightEffect.Parameters["xLightNormal"].SetValue(Vector3.Normalize(light.Location));

                RenderEffectToScreen(directionalLightEffect);
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes a light from a binary stream, version 0.
        /// </summary>
        /// <param name="light">Light being initialized</param>
        /// <param name="reader">Binary stream</param>
        private static Light ReadVer0(BinaryReader reader)
        {
            Light light = new Light();

            light.Type = (LightType)reader.ReadUInt32();
            light.Color.R = reader.ReadByte();
            light.Color.G = reader.ReadByte();
            light.Color.B = reader.ReadByte();
            light.Intensity = reader.ReadSingle();

            return light;
        }
コード例 #7
0
 /// <summary>
 /// Removes a light from the scene.
 /// </summary>
 /// <param name="light">Light</param>
 public abstract void RemoveLight(Light light);
コード例 #8
0
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every frame
 /// until RemoveLight is called. Has priority over normal lights.
 /// </summary>
 /// <param name="light"></param>
 public abstract void AddSceneLight(Light light);
コード例 #9
0
 /// <summary>
 /// Adds a dynamic light to the scene. Will be rendered every
 /// frame until RemoveLight is called.
 /// </summary>
 /// <param name="light">Light</param>
 public abstract void AddDynamicLight(Light light);