Beispiel #1
0
        public static Particles Load(string fileName, ParticleCallback particleCallback)
        {
            Particles part = new Particles();

            part.LoadParticles(fileName, particleCallback);
            return(part);
        }
Beispiel #2
0
 /// <summary>
 /// aseta partikkelikuva ja callback-metodi
 /// </summary>
 public void SetParticle(Billboard tex, bool isTransparent, bool castShadow, ParticleCallback particleCallback)
 {
     this.particleTex   = tex;
     this.IsTransparent = isTransparent;
     this.callBack      = particleCallback;
     this.CastShadow    = castShadow;
     ParticleGroups.Add(this);
 }
Beispiel #3
0
 public void Add(Particles particles, ParticleCallback particleCallback)
 {
     part.Add(particles);
     particles.callBack = particleCallback;
 }
Beispiel #4
0
 public void Add(Particles particles, ParticleCallback particleCallback)
 {
     part.Add(particles);
     particles.callBack = particleCallback;
 }
Beispiel #5
0
        void LoadParticles(string fileName, ParticleCallback particleCallback)
        {
            XmlDocument XMLDoc = null;
            XmlElement  XMLRoot;

            try
            {
                using (System.IO.StreamReader file = new System.IO.StreamReader(Settings.ParticleDir + fileName))
                {
                    // tiedosto muistiin
                    string data = file.ReadToEnd();
                    XMLDoc = new XmlDocument();
                    XMLDoc.LoadXml(data);
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
            // Validate the File
            XMLRoot = XMLDoc.DocumentElement;
            if (XMLRoot.Name != "particles")
            {
                Log.Error("Error [" + fileName + "] Invalid .particles.xml File. Missing <particles>");
            }

            Name = XML.GetAttrib(XMLRoot, "name");
            string billboard   = XML.GetAttrib(XMLRoot, "billboard");
            bool   translucent = XML.GetAttribBool(XMLRoot, "translucent", false);
            bool   castshadows = XML.GetAttribBool(XMLRoot, "castshadows", false);

            origValues.count               = (int)XML.GetAttribFloat(XMLRoot, "count", 0);
            origValues.life                = XML.GetAttribFloat(XMLRoot, "life", 0);
            origValues.life_max            = XML.GetAttribFloat(XMLRoot, "life_max", origValues.life);
            origValues.zrotation           = XML.GetAttribFloat(XMLRoot, "zrotation", 0);
            origValues.zrotation_max       = XML.GetAttribFloat(XMLRoot, "zrotation_max", origValues.zrotation);
            origValues.zrotation_adder     = XML.GetAttribFloat(XMLRoot, "zrotation_adder", 0);
            origValues.zrotation_adder_max = XML.GetAttribFloat(XMLRoot, "zrotation_adder_max", origValues.zrotation_adder);
            origValues.size                = XML.GetAttribFloat(XMLRoot, "size", 0);
            origValues.size_max            = XML.GetAttribFloat(XMLRoot, "size_max", origValues.size);

            XmlElement node = (XmlElement)XMLRoot.SelectSingleNode("position");

            origValues.pos = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                         XML.GetAttribFloat(node, "y", 0),
                                         XML.GetAttribFloat(node, "z", 0));
            origValues.posMax = new Vector3(XML.GetAttribFloat(node, "x_max", origValues.pos.X),
                                            XML.GetAttribFloat(node, "y_max", origValues.pos.Y),
                                            XML.GetAttribFloat(node, "z_max", origValues.pos.Z));


            node           = (XmlElement)XMLRoot.SelectSingleNode("direction");
            origValues.dir = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                         XML.GetAttribFloat(node, "y", 0),
                                         XML.GetAttribFloat(node, "z", 0));
            origValues.dirMax = new Vector3(XML.GetAttribFloat(node, "x_max", origValues.dir.X),
                                            XML.GetAttribFloat(node, "y_max", origValues.dir.Y),
                                            XML.GetAttribFloat(node, "z_max", origValues.dir.Z));

            node            = (XmlElement)XMLRoot.SelectSingleNode("gravitation");
            origValues.grav = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                          XML.GetAttribFloat(node, "y", 0),
                                          XML.GetAttribFloat(node, "z", 0));

            node             = (XmlElement)XMLRoot.SelectSingleNode("color");
            origValues.color = new Vector4(XML.GetAttribFloat(node, "r", 0),
                                           XML.GetAttribFloat(node, "g", 0),
                                           XML.GetAttribFloat(node, "b", 0),
                                           XML.GetAttribFloat(node, "a", 0));
            origValues.colorMax = new Vector4(XML.GetAttribFloat(node, "r_max", origValues.color.X),
                                              XML.GetAttribFloat(node, "g_max", origValues.color.Y),
                                              XML.GetAttribFloat(node, "b_max", origValues.color.Z),
                                              XML.GetAttribFloat(node, "a_max", origValues.color.W));

            SetParticle(Billboard.Load(billboard), translucent, castshadows, particleCallback);
            Reset();
        }
Beispiel #6
0
 /// <summary>
 /// aseta partikkelikuva ja callback-metodi
 /// </summary>
 public void SetParticle(Billboard tex, bool isTransparent, bool castShadow, ParticleCallback particleCallback)
 {
     this.particleTex = tex;
     this.IsTransparent = isTransparent;
     this.callBack = particleCallback;
     this.CastShadow = castShadow;
     ParticleGroups.Add(this);
 }
Beispiel #7
0
        void LoadParticles(string fileName, ParticleCallback particleCallback)
        {
            XmlDocument XMLDoc = null;
            XmlElement XMLRoot;
            try
            {
                using (System.IO.StreamReader file = new System.IO.StreamReader(Settings.ParticleDir + fileName))
                {
                    // tiedosto muistiin
                    string data = file.ReadToEnd();
                    XMLDoc = new XmlDocument();
                    XMLDoc.LoadXml(data);
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
            // Validate the File
            XMLRoot = XMLDoc.DocumentElement;
            if (XMLRoot.Name != "particles")
            {
                Log.Error("Error [" + fileName + "] Invalid .particles.xml File. Missing <particles>");
            }

            Name = XML.GetAttrib(XMLRoot, "name");
            string billboard = XML.GetAttrib(XMLRoot, "billboard");
            bool translucent = XML.GetAttribBool(XMLRoot, "translucent", false);
            bool castshadows = XML.GetAttribBool(XMLRoot, "castshadows", false);
            origValues.count = (int)XML.GetAttribFloat(XMLRoot, "count", 0);
            origValues.life = XML.GetAttribFloat(XMLRoot, "life", 0);
            origValues.life_max = XML.GetAttribFloat(XMLRoot, "life_max", origValues.life);
            origValues.zrotation = XML.GetAttribFloat(XMLRoot, "zrotation", 0);
            origValues.zrotation_max = XML.GetAttribFloat(XMLRoot, "zrotation_max", origValues.zrotation);
            origValues.zrotation_adder = XML.GetAttribFloat(XMLRoot, "zrotation_adder", 0);
            origValues.zrotation_adder_max = XML.GetAttribFloat(XMLRoot, "zrotation_adder_max", origValues.zrotation_adder);
            origValues.size = XML.GetAttribFloat(XMLRoot, "size", 0);
            origValues.size_max = XML.GetAttribFloat(XMLRoot, "size_max", origValues.size);

            XmlElement node = (XmlElement)XMLRoot.SelectSingleNode("position");
            origValues.pos = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                    XML.GetAttribFloat(node, "y", 0),
                                    XML.GetAttribFloat(node, "z", 0));
            origValues.posMax = new Vector3(XML.GetAttribFloat(node, "x_max", origValues.pos.X),
                                        XML.GetAttribFloat(node, "y_max", origValues.pos.Y),
                                        XML.GetAttribFloat(node, "z_max", origValues.pos.Z));


            node = (XmlElement)XMLRoot.SelectSingleNode("direction");
            origValues.dir = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                    XML.GetAttribFloat(node, "y", 0),
                                    XML.GetAttribFloat(node, "z", 0));
            origValues.dirMax = new Vector3(XML.GetAttribFloat(node, "x_max", origValues.dir.X),
                                        XML.GetAttribFloat(node, "y_max", origValues.dir.Y),
                                        XML.GetAttribFloat(node, "z_max", origValues.dir.Z));

            node = (XmlElement)XMLRoot.SelectSingleNode("gravitation");
            origValues.grav = new Vector3(XML.GetAttribFloat(node, "x", 0),
                                    XML.GetAttribFloat(node, "y", 0),
                                    XML.GetAttribFloat(node, "z", 0));

            node = (XmlElement)XMLRoot.SelectSingleNode("color");
            origValues.color = new Vector4(XML.GetAttribFloat(node, "r", 0),
                                    XML.GetAttribFloat(node, "g", 0),
                                    XML.GetAttribFloat(node, "b", 0),
                                    XML.GetAttribFloat(node, "a", 0));
            origValues.colorMax = new Vector4(XML.GetAttribFloat(node, "r_max", origValues.color.X),
                                        XML.GetAttribFloat(node, "g_max", origValues.color.Y),
                                        XML.GetAttribFloat(node, "b_max", origValues.color.Z),
                                        XML.GetAttribFloat(node, "a_max", origValues.color.W));

            SetParticle(Billboard.Load(billboard), translucent, castshadows, particleCallback);
            Reset();
        }
Beispiel #8
0
 public static Particles Load(string fileName, ParticleCallback particleCallback)
 {
     Particles part = new Particles();
     part.LoadParticles(fileName, particleCallback);
     return part;
 }