Example #1
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Color/Ambient", true, out subEle);
            ColorAmbient.WriteXML(subEle, master);

            ele.TryPathTo("Color/Directional", true, out subEle);
            ColorDirectional.WriteXML(subEle, master);

            ele.TryPathTo("Fog/Color", true, out subEle);
            FogColor.WriteXML(subEle, master);

            ele.TryPathTo("Fog/Near", true, out subEle);
            subEle.Value = FogNear.ToString("G15");

            ele.TryPathTo("Fog/Far", true, out subEle);
            subEle.Value = FogFar.ToString("G15");

            ele.TryPathTo("DirectionalRotation/XY", true, out subEle);
            subEle.Value = DirectionalRotationXY.ToString();

            ele.TryPathTo("DirectionalRotation/Z", true, out subEle);
            subEle.Value = DirectionalRotationZ.ToString();

            ele.TryPathTo("DirectionalFade", true, out subEle);
            subEle.Value = DirectionalFade.ToString("G15");

            ele.TryPathTo("Fog/ClipDistance", true, out subEle);
            subEle.Value = FogClipDistance.ToString("G15");

            ele.TryPathTo("Fog/Power", true, out subEle);
            subEle.Value = FogPower.ToString("G15");
        }
Example #2
0
        protected override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("Color/Ambient", false, out subEle))
            {
                ColorAmbient.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Color/Directional", false, out subEle))
            {
                ColorDirectional.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Fog/Color", false, out subEle))
            {
                FogColor.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Fog/Near", false, out subEle))
            {
                FogNear = subEle.ToSingle();
            }

            if (ele.TryPathTo("Fog/Far", false, out subEle))
            {
                FogFar = subEle.ToSingle();
            }

            if (ele.TryPathTo("DirectionalRotation/XY", false, out subEle))
            {
                DirectionalRotationXY = subEle.ToInt32();
            }

            if (ele.TryPathTo("DirectionalRotation/Z", false, out subEle))
            {
                DirectionalRotationZ = subEle.ToInt32();
            }

            if (ele.TryPathTo("DirectionalFade", false, out subEle))
            {
                DirectionalFade = subEle.ToSingle();
            }

            if (ele.TryPathTo("Fog/ClipDistance", false, out subEle))
            {
                FogClipDistance = subEle.ToSingle();
            }

            if (ele.TryPathTo("Fog/Power", false, out subEle))
            {
                FogPower = subEle.ToSingle();
            }
        }
Example #3
0
 protected override void WriteData(ESPWriter writer)
 {
     ColorAmbient.WriteBinary(writer);
     ColorDirectional.WriteBinary(writer);
     FogColor.WriteBinary(writer);
     writer.Write(FogNear);
     writer.Write(FogFar);
     writer.Write(DirectionalRotationXY);
     writer.Write(DirectionalRotationZ);
     writer.Write(DirectionalFade);
     writer.Write(FogClipDistance);
     writer.Write(FogPower);
 }
Example #4
0
        public override Color Calculate(IViewport viewport, Vector point, Vector normal)
        {
            // Use dotproduct for diffuse lighting. Add point functionality as this now is a directional light.
            // Ambient light
            var ambient = ColorAmbient.ToVector() * Strength;

            // Diffuse light
            var lightDir = Position - point;

            lightDir.Normalize();
            normal.Normalize();
            var dfDot = lightDir.Dot(normal);

            MathHelper.Saturate(ref dfDot);
            var diffuse = ColorDiffuse.ToVector() * dfDot * Strength;

            // Specular highlight
            var Reflection = 2 * dfDot * normal - lightDir;

            Reflection.Normalize();
            var view = viewport.Camera.Position - point;

            view.Normalize();
            var spDot = Reflection.Dot(view);

            MathHelper.Saturate(ref spDot);
            var specular = ColorSpecular.ToVector() * spDot * Strength;

            // Compute self shadowing
            var shadow = 4.0f * lightDir.Dot(normal);

            MathHelper.Saturate(ref shadow);

            // Compute range for the light
            var attenuation = ((lightDir / Range).Dot(lightDir / Range));

            MathHelper.Saturate(ref attenuation);
            attenuation = 1 - attenuation;

            // Final result
            var colorVector = ambient + shadow * (diffuse + specular) * attenuation;

            //var colorVector = ambient + diffuse;

            return(colorVector.ToColorWithClamp());
        }
Example #5
0
 protected override void ReadData(ESPReader reader)
 {
     using (MemoryStream stream = new MemoryStream(reader.ReadBytes(size)))
         using (ESPReader subReader = new ESPReader(stream, reader.Plugin))
         {
             try
             {
                 ColorAmbient.ReadBinary(subReader);
                 ColorDirectional.ReadBinary(subReader);
                 FogColor.ReadBinary(subReader);
                 FogNear = subReader.ReadSingle();
                 FogFar  = subReader.ReadSingle();
                 DirectionalRotationXY = subReader.ReadInt32();
                 DirectionalRotationZ  = subReader.ReadInt32();
                 DirectionalFade       = subReader.ReadSingle();
                 FogClipDistance       = subReader.ReadSingle();
                 FogPower = subReader.ReadSingle();
             }
             catch
             {
                 return;
             }
         }
 }
Example #6
0
 public override int GetHashCode()
 {
     return(ColorAmbient.GetHashCode());
 }