public IEnumerable <PartFileInfo> GetPrimitiveFiles() { if (PrimitiveDir != null) { foreach (var fi in PrimitiveDir.GetFiles("*.xml")) { yield return(new PartFileInfo(fi.Name, fi.FullName, fi.LastWriteTime, PartFileType.Primitive)); } } if (Lif != null) { foreach (var fi in Lif.GetFolder("Primitives").Files) //.GetFiles("*.xml") { yield return(new PartFileInfo(fi.Name, fi.FullName, fi.ModifiedDate, PartFileType.Primitive)); } } }
public static PartWrapper GetPartFromLif(LifFile lif, int partID, bool loadMeshes) { var primitiveFolder = lif.GetFolder("Primitives"); var meshesFolder = primitiveFolder.GetFolder("LOD0"); var primitiveEntry = primitiveFolder.GetFile($"{partID}.xml"); if (primitiveEntry == null) { throw new FileNotFoundException($"Primitive file not found. ({partID}.xml)"); } var surfaces = new List <PartSurfaceMesh>(); foreach (var meshEntry in meshesFolder.GetFiles($"{partID}.g*")) { if (!PartSurfaceMesh.ParseSurfaceID(meshEntry.Name, out int surfID)) { surfID = surfaces.Count; } var surfaceInfo = new PartSurfaceMesh(partID, surfID, loadMeshes ? MeshFile.Read(meshEntry.GetStream()) : null); surfaces.Add(surfaceInfo); } if (!surfaces.Any()) { throw new FileNotFoundException($"Mesh file not found. ({partID}.g)"); } var primitive = Primitive.Load(primitiveEntry.GetStream()); primitive.ID = partID; return(new PartWrapper(primitive, surfaces) { PartID = partID }); }