Ejemplo n.º 1
0
        public int setMeshFile(string path)
        {
            BrushList ggfe = new BrushList();

            ggfe.Reader(path);
            StreamReader sr = new StreamReader(path.Replace(".cgf", ".mesh"));

            string line;
            int    cor  = 0;
            int    fg   = 0;
            bool   cors = false;

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();

                int inde  = line.IndexOf("(");
                int inder = line.IndexOf(")");
                if (inde != -1 && inder != -1)
                {
                    if (cors == false)
                    {
                        cor++; cors = true;
                    }

                    string got  = line.Substring(inde + 1, inder - 1);
                    int    xind = got.IndexOf(",");
                    string gotx = got.Substring(0, xind);
                    /////////////////////////////X
                    string goty  = got.Substring(xind + 1);
                    int    yind  = goty.IndexOf(",");
                    string gotyy = goty.Substring(0, yind);
                    /////////////////////////////y
                    string gotz = goty.Substring(yind + 1);
                    /////////////////////////////z
                }
                else
                {
                    cors = false;
                    if (cor == 3)
                    {
                        cor = 0;
                        fg++;
                    }
                }
            }
            if (cors)
            {
                fg++;
            }
            sr.Close();
            return(fg);
        }
Ejemplo n.º 2
0
        public void TerainConvert()
        {
            BrushList bry = new BrushList();

            XmlDocument document = new XmlDocument();

            document.Load(fileNames);
            XmlNodeList nodeList = document.GetElementsByTagName("data");

            foreach (XmlNode xmlnode in nodeList)
            {
                if (File.Exists("levels\\" + xmlnode.InnerText + "\\terrain\\land_map.h32"))
                {
                    FileStream   fso = new FileStream("levels\\" + xmlnode.InnerText + "\\terrain\\land_map.h32", FileMode.Open, FileAccess.Read);
                    BinaryReader fds = new BinaryReader(fso);

                    FileStream   fs  = new FileStream(xmlnode.Attributes["id"].InnerText + ".geo", FileMode.OpenOrCreate, FileAccess.Write);
                    BinaryWriter fda = new BinaryWriter(fs);
                    byte         yyt = 1;
                    int          yyr = Convert.ToInt32(fso.Length / 3);
                    fda.Write(yyt);
                    fda.Write(yyr);
                    int i;
                    for (i = 0; fso.Length / 3 > i; i++)
                    {
                        fda.Write(fds.ReadInt16());
                        fds.ReadByte();
                    }
                    fda.Close();
                }
                else
                {
                    FileStream   fs  = new FileStream(xmlnode.Attributes["id"].InnerText + ".geo", FileMode.OpenOrCreate, FileAccess.Write);
                    BinaryWriter fda = new BinaryWriter(fs);
                    byte         yyt = 1;
                    fda.Write(yyt);
                    fda.Write(yyt);
                    fda.Write(yyt);
                    fda.Close();
                }

                bry.Brush(xmlnode.Attributes["id"].InnerText, xmlnode.InnerText);

                Console.WriteLine("OK- " + xmlnode.Attributes["id"].InnerText);
                Console.WriteLine(bry.name_model.Count);
            }

            foreach (string name in bry.name_model)
            {
                MeshsGeo ghd = new MeshsGeo();

                Meshs rtry = new Meshs();

                if (File.Exists(name.Replace(".cgf", ".mesh")))
                {
                    rtry.ReadMeshs(name);
                }
                else
                {
                    ghd.ComMeshs(name);
                }

                Console.WriteLine("OK");
            }
        }