Exemplo n.º 1
0
        //#region IXmlSerializable Members

        //XmlSchema IXmlSerializable.GetSchema()
        //{
        //    return null;
        //}

        //void IXmlSerializable.ReadXml(XmlReader reader)
        //{
        //    Radius = DataConverter.FieldValueToInt32(reader.GetAttribute("Radius"));
        //    FovShape = (FovShapeType)Enum.Parse(typeof(FovShapeType), reader.GetAttribute("FovShape"));

        //    reader.Read();
        //    Location = new Point(DataConverter.FieldValueToInt32(reader.GetAttribute("X")), DataConverter.FieldValueToInt32(reader.GetAttribute("Y")));
        //    reader.Read();
        //    Colour = Color.FromArgb(DataConverter.FieldValueToInt32(reader.GetAttribute("Alpha")), DataConverter.FieldValueToInt32(reader.GetAttribute("Red")), DataConverter.FieldValueToInt32(reader.GetAttribute("Green")), DataConverter.FieldValueToInt32(reader.GetAttribute("Blue")));
        //    reader.Read();

        //    Attenuation = (AttenuationFunction)new XmlSerializer(typeof(AttenuationFunction)).Deserialize(reader);

        //    reader.ReadEndElement();
        //}

        //void IXmlSerializable.WriteXml(XmlWriter writer)
        //{
        //    writer.WriteAttributeString("Radius", Radius.ToString());
        //    writer.WriteAttributeString("FovShape", FovShape.ToString());

        //    writer.WriteStartElement("Location");
        //    writer.WriteAttributeString("X", Location.X.ToString());
        //    writer.WriteAttributeString("Y", Location.Y.ToString());
        //    writer.WriteEndElement();

        //    writer.WriteStartElement("Colour");
        //    writer.WriteAttributeString("Alpha", Colour.A.ToString());
        //    writer.WriteAttributeString("Red", Colour.R.ToString());
        //    writer.WriteAttributeString("Green", Colour.G.ToString());
        //    writer.WriteAttributeString("Blue", Colour.B.ToString());
        //    writer.WriteEndElement();

        //    var attenuationSerializer = new XmlSerializer(typeof(AttenuationFunction));
        //    var xsn = new XmlSerializerNamespaces();
        //    xsn.Add(string.Empty, string.Empty);
        //    attenuationSerializer.Serialize(writer, Attenuation, xsn);
        //}

        //#endregion

        #region IEquatable<LightSource> Members

        bool IEquatable <LightSource> .Equals(LightSource other)
        {
            if (Location != other.Location)
            {
                return(false);
            }
            if (FovProfile != other.FovProfile)
            {
                return(false);
            }
            if (!Attenuation.Equals(other.Attenuation))
            {
                return(false);
            }
            if (Red != other.Red)
            {
                return(false);
            }
            if (Green != other.Green)
            {
                return(false);
            }
            if (Blue != other.Blue)
            {
                return(false);
            }
            return(Alpha == other.Alpha);
        }
Exemplo n.º 2
0
 public UniformBuffer(Vector4 pos)
 {
     _position    = pos;
     _ambient     = new Vector4(1f, 1f, 1f, 1f);
     _diffuse     = new Vector4(1f, 1f, 1f, 1f);
     _specular    = new Vector4(1f, 1f, 1f, 1f);
     _k           = new K(0.2f, 0.7f, 0.4f);
     _attenuation = new Attenuation(1f, 0.0f, 0.000f);
 }
Exemplo n.º 3
0
 protected override void AssignDefaultValuesToSceneNode(SceneNode core)
 {
     base.AssignDefaultValuesToSceneNode(core);
     if (core is PointLightNode n)
     {
         n.Attenuation = Attenuation.ToVector3();
         n.Range       = (float)Range;
         n.Position    = Position.ToVector3();
     }
 }
Exemplo n.º 4
0
        public Light()
            : base()
        {
            Attenuation = Attenuation.None;

            Range = 5.3f;

            Intensity = 1;

            Color = new Vector4(1, 0, 0, 1);

            FarAttenStart = 2;
        }
Exemplo n.º 5
0
 public PsyiaForceSettings(PsyiaForceSettings copyTarget)
 {
     ForceShape             = copyTarget.ForceShape;
     ForceAttenuation       = copyTarget.ForceAttenuation;
     ForceStrength          = copyTarget.ForceStrength;
     ForceStrengthVis       = copyTarget.ForceStrengthVis;
     AttenuationDistance    = copyTarget.AttenuationDistance;
     AttenuationDistanceVis = copyTarget.AttenuationDistanceVis;
     SofteningFactor        = copyTarget.SofteningFactor;
     SofteningFactorVis     = copyTarget.SofteningFactorVis;
     Wavelength             = copyTarget.Wavelength;
     WavelengthVis          = copyTarget.WavelengthVis;
 }
Exemplo n.º 6
0
        protected override void ParseElements()
        {
            cast_shadow = GetValue <bool>("cast_shadows");

            if (IsValidNode("intensity"))
            {
                intensity = GetValue <double>("intensity");
            }

            if (IsValidNode("diffuse"))
            {
                diffuse.FromString(GetValue <string>("diffuse"));
            }

            if (IsValidNode("specular"))
            {
                diffuse.FromString(GetValue <string>("specular"));
            }

            if (IsValidNode("attenuation"))
            {
                attenuation           = new Attenuation();
                attenuation.range     = GetValue <double>("attenuation/range");
                attenuation.linear    = GetValue <double>("attenuation/linear");
                attenuation.constant  = GetValue <double>("attenuation/constant");
                attenuation.quadratic = GetValue <double>("attenuation/quadratic");
            }

            if (IsValidNode("direction"))
            {
                direction.FromString(GetValue <string>("direction"));
            }

            if (IsValidNode("spot"))
            {
                spot             = new Spot();
                spot.inner_angle = GetValue <double>("spot/inner_angle");
                spot.outer_angle = GetValue <double>("spot/outer_angle");
                spot.falloff     = GetValue <double>("spot/falloff");
            }
        }
Exemplo n.º 7
0
    public List <Attenuation> getShuaijian(List <string[]> r)
    {
        List <Attenuation> list = new List <Attenuation>();

        for (int i = 0; i < r.Count; i++)
        {
            Attenuation a = new Attenuation();
            for (int j = 0; j < r[i].Length; j++)
            {
                switch (j)
                {
                case 0:
                    a.level = int.Parse(r[i][j]);
                    break;

                case 1:
                    a.attenuation = int.Parse(r[i][j]);
                    break;
                }
            }
            list.Add(a);
        }
        return(list);
    }
Exemplo n.º 8
0
 public static void SetAttenuation(this ShaderProgram shader, string name, Attenuation atten)
 {
     shader[name + ".constant"] = atten.constant;
     shader[name + ".linear"]   = atten.linear;
     shader[name + ".exponent"] = atten.exponent;
 }
Exemplo n.º 9
0
        public HIRCObject(BNK mainBnk, BinaryReader br)
        {
            Bnk = mainBnk;
            if (!hircError.errorOccured)
            {
                int type = br.ReadByte();
                LastPos = br.BaseStream.Position;
                switch (type)
                {
                case 1:
                    SettingsObject = new Settings(br, type);
                    break;

                case 2:
                    SoundSFXObject = new SoundSFX(this, br, type);
                    break;

                case 3:
                    EventAction = new EventAction(this, br, type);
                    break;

                case 4:
                    Event = new Event(this, br, type);
                    break;

                case 5:
                    RandomContainer = new RandomContainer(this, br, type);
                    break;

                case 6:
                    SwitchContainer = new SwitchContainer(this, br, type);
                    break;

                case 7:
                    ActorMixer = new ActorMixer(this, br, type);
                    break;

                case 8:
                    AudioBus = new AudioBus(this, br, type);
                    break;

                case 9:
                    BlendContainer = new BlendContainer(this, br, type);
                    break;

                case 10:
                    MusicSegment = new MusicSegment(this, br, type);
                    break;

                case 11:
                    MusicTrack = new MusicTrack(this, br, type);
                    break;

                case 12:
                    MusicSwitchContainer = new MusicSwitchContainer(this, br, type);
                    break;

                case 13:
                    MusicSequence = new MusicSequence(this, br, type);
                    break;

                case 14:
                    Attenuation = new Attenuation(br, type);
                    break;

                case 16:
                    FeedbackBus = new FeedbackBus(this, br, type);
                    break;

                case 17:
                    FeedbackNode = new FeedbackNode(this, br, type);
                    break;

                case 18:
                    FxShareSet = new FxShareSet(this, br, type);
                    break;

                case 19:
                    FxCustom = new FxCustom(this, br, type);
                    break;

                case 20:
                    AuxiliaryBus = new AuxiliaryBus(this, br, type);
                    break;

                case 21:
                    LFO = new LFO(br, type);
                    break;

                case 22:
                    Envelope = new Envelope(br, type);
                    break;

                default:
                    int length = br.ReadInt32();
                    br.BaseStream.Position -= 5;
                    Data = br.ReadBytes(length + 5);
                    System.Windows.MessageBox.Show("Detected unkown HIRC Object type at: " + (LastPos - 1).ToString("X"), "Toolkit");
                    break;
                }
            }
        }
Exemplo n.º 10
0
        public int GetLength()
        {
            int length = 5;

            if (SettingsObject != null)
            {
                length += SettingsObject.GetLength();
            }
            else if (SoundSFXObject != null)
            {
                length += SoundSFXObject.GetLength();
            }
            else if (EventAction != null)
            {
                length += EventAction.GetLength();
            }
            else if (Event != null)
            {
                length += Event.GetLength();
            }
            else if (RandomContainer != null)
            {
                length += RandomContainer.GetLength();
            }
            else if (SwitchContainer != null)
            {
                length += SwitchContainer.GetLength();
            }
            else if (ActorMixer != null)
            {
                length += ActorMixer.GetLength();
            }
            else if (AudioBus != null)
            {
                length += AudioBus.GetLength();
            }
            else if (BlendContainer != null)
            {
                length += BlendContainer.GetLength();
            }
            else if (MusicSegment != null)
            {
                length += MusicSegment.GetLength();
            }
            else if (MusicTrack != null)
            {
                length += MusicTrack.GetLength();
            }
            else if (MusicSwitchContainer != null)
            {
                length += MusicSwitchContainer.GetLength();
            }
            else if (MusicSequence != null)
            {
                length += MusicSequence.GetLength();
            }
            else if (Attenuation != null)
            {
                length += Attenuation.GetLength();
            }
            else if (FeedbackNode != null)
            {
                length += FeedbackNode.GetLength();
            }
            else if (FxShareSet != null)
            {
                length += FxShareSet.GetLength();
            }
            else if (FxCustom != null)
            {
                length += FxCustom.GetLength();
            }
            else if (AuxiliaryBus != null)
            {
                length += AuxiliaryBus.GetLength();
            }
            else if (LFO != null)
            {
                length += LFO.GetLength();
            }
            else if (Envelope != null)
            {
                length += Envelope.GetLength();
            }
            else if (FeedbackBus != null)
            {
                length += FeedbackBus.GetLength();
            }
            else
            {
                if (Data != null)
                {
                    length += Data.Length;
                }
                else
                {
                    length = -1;
                }
            }

            return(length);
        }
Exemplo n.º 11
0
 public override void SetUniforms(int i, ShaderProgram program)
 {
     program.Use();
     Gl.ProgramUniform3fv(program.ProgramID, Gl.GetUniformLocation(program.ProgramID, "pointLight[" + i + "]"), 3, Position.ToFloat());
     Gl.ProgramUniform3fv(program.ProgramID, Gl.GetUniformLocation(program.ProgramID, "pointLightColor[" + i + "]"), 3, Color.ToFloat());
     Gl.ProgramUniform3fv(program.ProgramID, Gl.GetUniformLocation(program.ProgramID, "attenuation[" + i + "]"), 3, Attenuation.ToFloat());
 }
Exemplo n.º 12
0
        //--------------------//

        #region Constructor
        /// <summary>
        /// Creates a new point light with a <see cref="Range"/> of 1000 and no attenuation
        /// </summary>
        public PointLight()
        {
            Range       = 1000;
            Attenuation = new Attenuation(1, 0, 0);
        }
Exemplo n.º 13
0
 public static bool AreEqual(Attenuation a1, Attenuation a2) => a1.x0 == a2.x0 && a1.x1 == a2.x1 && a1.x2 == a2.x2;