Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Not enough arguments!");
            }
            else
            {
                /*
                 * if (args[0] == "adt")
                 * {
                 *  if (args.Length != 2)
                 *      throw new Exception("Not enough arguments. Need mode, file");
                 *
                 *  var adt = new WoWFormatLib.FileReaders.ADTReader();
                 *
                 *  adt.LoadADT(File.OpenRead(args[1]));
                 *
                 *  for (var i = 0; i < adt.adtfile.chunks.Length; i++)
                 *  {
                 *      adt.adtfile.chunks[i].vertices = new WoWFormatLib.Structs.ADT.MCVT();
                 *      adt.adtfile.chunks[i].normals = new WoWFormatLib.Structs.ADT.MCNR();
                 *      adt.adtfile.chunks[i].vertexShading = new WoWFormatLib.Structs.ADT.MCCV();
                 *  }
                 *
                 *  Console.WriteLine(JsonConvert.SerializeObject(adt, Formatting.Indented));
                 * }
                 */
                if (args[0] == "wmo")
                {
                    if (args.Length != 2)
                    {
                        throw new Exception("Not enough arguments. Need mode, file");
                    }

                    var reader = new WoWFormatLib.FileReaders.WMOReader();

                    var wmo = reader.LoadWMO(File.OpenRead(args[1]));

                    Console.WriteLine(JsonConvert.SerializeObject(wmo, Formatting.Indented));
                }

                if (args[0] == "m2")
                {
                    if (args.Length != 2)
                    {
                        throw new Exception("Not enough arguments. Need mode, file");
                    }

                    var m2 = new WoWFormatLib.FileReaders.M2Reader();

                    m2.LoadM2(File.OpenRead(args[1]));

                    m2.model.vertices = new WoWFormatLib.Structs.M2.Vertice[0];

                    Console.WriteLine(JsonConvert.SerializeObject(m2, Formatting.Indented));
                }
            }
        }
Beispiel #2
0
        private void fileworker_DoWork(object sender, DoWorkEventArgs e)
        {
            var results   = new List <string>();
            var remaining = new List <string>();
            var progress  = 0;

            remaining.Add((string)e.Argument);

            while (remaining.Count > 0)
            {
                var filename = remaining[0];
                if (filename.EndsWith(".wmo"))
                {
                    var wmo = new WoWFormatLib.FileReaders.WMOReader();
                    wmo.LoadWMO(filename);


                    // Loop through filenames from WMO
                }
                else if (filename.EndsWith(".adt"))
                {
                    var adt = new WoWFormatLib.FileReaders.ADTReader();
                    adt.LoadADT(filename);

                    foreach (var entry in adt.adtfile.objects.wmoNames.filenames)
                    {
                        results.Add(entry.ToLower());
                    }

                    foreach (var entry in adt.adtfile.objects.m2Names.filenames)
                    {
                        results.Add(entry.ToLower());
                    }
                }

                remaining.Remove(filename);
            }

            fileworker.ReportProgress(progress, results);
        }