private void Convert() { string skeletonfile = string.Empty; OgreSkeleton skeleton = null; zmd.Clear(); if (!string.IsNullOrEmpty(ZMDFile)) { zmd.Load(ZMDFile); skeleton = new OgreSkeleton(zmd); skeletonfile = Path.ChangeExtension(Path.GetFileName(ZMDFile), ".skeleton"); } zms.Clear(); for (int i = 0; i < ZMSFiles.Count; i++) { zms.Add(new ZMS(ZMSFiles[i])); OgreMesh mesh = new OgreMesh(zms[i]); if (!string.IsNullOrEmpty(ZMDFile) && zms[i].BonesCount > 0) { XmlElement xmlmesh = mesh.XMLDoc.DocumentElement; XmlNode xmlskeletonlink = mesh.XMLDoc.CreateNode(XmlNodeType.Element, "skeletonlink", null); XmlAttribute xmlskeletonname = mesh.XMLDoc.CreateAttribute("name"); xmlskeletonname.Value = skeletonfile; xmlskeletonlink.Attributes.Append(xmlskeletonname); xmlmesh.AppendChild(xmlskeletonlink); } mesh.XMLDoc.Save(Path.ChangeExtension(ZMSFiles[i], ".mesh.xml")); } if (!string.IsNullOrEmpty(ZMDFile)) { zmo.Clear(); if ((zmd.Bone.Count > 0) && (ZMOFiles.Count > 0)) { for (int i = 0; i < ZMOFiles.Count; i++) { zmo.Add(new ZMO(ZMOFiles[i], zmd)); OgreAnimation ogreanim = new OgreAnimation(zmd, zmo[i], skeleton.XMLDoc, Path.GetFileNameWithoutExtension(ZMOFiles[i])); } } skeleton.XMLDoc.Save(Path.ChangeExtension(ZMDFile, ".skeleton.xml")); } }
private static void ProcessFileList(List <string> FileNameList) { // Get only files that exist var existing = from f in FileNameList where File.Exists(f) select f; // Separate by types IEnumerable <string> zmss = from f in existing where Path.GetExtension(f).IndexOf("ZMS", StringComparison.OrdinalIgnoreCase) >= 0 select f; IEnumerable <string> zmos = from f in existing where Path.GetExtension(f).IndexOf("ZMO", StringComparison.OrdinalIgnoreCase) >= 0 select f; IEnumerable <string> zmds = from f in existing where Path.GetExtension(f).IndexOf("ZMD", StringComparison.OrdinalIgnoreCase) >= 0 select f; // Fill in the listboxes and lists if (zmds.Any()) { ZMDFile = zmds.ToArray()[0]; Console.WriteLine("Loading ZMD: {0}", ZMDFile); zmd.Load(ZMDFile); } if (zmss.Any()) { ZMSFiles.AddRange(zmss.ToList()); ZMSFiles = ZMSFiles.Distinct().ToList(); foreach (string zms_filename in ZMSFiles) { Console.WriteLine("Loading ZMS: {0}", zms_filename); zms.Add(new ZMS(zms_filename)); } } if (zmos.Any() && zmds.Any()) { ZMOFiles.AddRange(zmos.ToList()); ZMOFiles = ZMOFiles.Distinct().ToList(); foreach (string zmo_filename in ZMOFiles) { Console.WriteLine("Loading ZMO: {0}", zmo_filename); zmo.Add(new ZMO(zmo_filename, zmd)); } } }