public abstract void AddMesh(ANZFile path);
static void Main(string[] args) { if (args.Length == 0 || args[0] == "-h") { printHelp(); return; } List <string> fileList = new List <string>(); FileInfo dest = null; string format = ""; var settings = Settings.None; for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (arg.StartsWith("-") || arg.Length == 1) { var option = arg.Last(); // Handle as argument switch (option) { case 'o': if (i + 1 >= args.Length) { Console.Error.WriteLine("No value for {0}", arg); printHelp(); return; } string path = args[++i]; int idx = path.LastIndexOf('.'); if (idx >= 0) { if (format == "") { format = path.Substring(idx + 1); } path = path.Substring(0, idx); } dest = new FileInfo(path); break; case 'h': printHelp(); return; case 'u': settings |= Settings.Compatibility; break; case 'b': settings |= Settings.Skin; break; case 's': settings |= Settings.SliceAnimations; break; case 'm': settings |= Settings.Morphs; break; case 'a': settings |= Settings.Animations | Settings.Skin; break; case 'c': settings |= Settings.Merge; break; case 'f': if (i + 1 >= args.Length) { Console.Error.WriteLine("No value for {0}", arg); printHelp(); return; } format = args[++i]; if (format != "dae" && format != "obj") { Console.Error.WriteLine("Invalid format: {0}", format); printHelp(); return; } break; default: Console.Error.WriteLine("Unknown option {0}", arg); printHelp(); return; } } else { // Handle as input file var info = new FileInfo(arg); if (info.Exists) { if (arg.EndsWith(".anz")) { fileList.Add(info.FullName); if (dest == null) { dest = new FileInfo(info.FullName.Replace(".anz", "")); } } else { Console.Error.WriteLine("File {0} is not an *.anz file.", arg); } } else { Console.Error.WriteLine("Could not find file {0}", arg); } } } if (settings == Settings.None) { settings = Settings.All; } // settings = Settings.Animations | Settings.SliceAnimations | Settings.Compress; if (format == "") { format = "dae"; } dest = new FileInfo(dest.FullName + "." + format); IConvertTarget target; if (format == "dae") { target = new ColladaFile(); } else { target = new ObjFile(); } target.Options = settings; int processed = 0; foreach (var file in fileList) { var anz = ANZFile.FromFile(file); if (!anz.HasAnimation || anz.Anims.Any(a => a.Objects == null || a.Objects.All(o => o.Name == null))) { Console.WriteLine("{0}: mesh", file); target.AddMesh(anz); processed++; } else if (target is IMotionSupport) { Console.WriteLine("{0}: anim", file); ((IMotionSupport)target).AddMotion(anz); processed++; } else { Console.Error.WriteLine("{0} does not support animations. Skipping: {1}", format, file); } } if (processed > 0) { target.Save(dest.FullName); } else { Console.Error.WriteLine("Got nothing to do..."); } }