public static Sdf LoadSdf(string filename) { filename = filename.ToLower(); if (SdfCache.ContainsKey(filename)) { return(SdfCache[filename]); } using (var br = new Bwd2Reader(filename)) { var sdf = new Sdf(); br.FindNext("SDFC"); sdf.Name = br.ReadCString(16); var one = br.ReadUInt32(); var size = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); var unk1 = br.ReadUInt32(); var unk2 = br.ReadUInt32(); var fifty = br.ReadUInt32(); var xdf = br.ReadCString(13); var wav = br.ReadCString(13); br.FindNext("SGEO"); var numParts = br.ReadUInt32(); sdf.Parts = new SdfPart[numParts]; for (int i = 0; i < numParts; i++) { var sdfPart = new SdfPart(); sdfPart.Name = br.ReadCString(8); sdfPart.Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.ParentName = br.ReadCString(8); br.BaseStream.Seek(56, SeekOrigin.Current); sdf.Parts[i] = sdfPart; } SdfCache.Add(filename, sdf); return(sdf); } }
public static Wdf ParseWdf(string filename) { using (var br = new Bwd2Reader(filename)) { var wdf = new Wdf(); br.FindNext("WDFC"); wdf.Name = br.ReadCString(20); wdf.Float1 = br.ReadSingle(); //160 wdf.Float2 = br.ReadSingle(); //100 wdf.Float3 = br.ReadSingle(); //70 wdf.Float4 = br.ReadSingle(); //30 wdf.Byte1 = br.ReadByte(); // 255 wdf.Byte2 = br.ReadByte(); // 255 wdf.Byte3 = br.ReadByte(); // 127 wdf.Byte4 = br.ReadByte(); // 127 wdf.Int1 = br.ReadUInt32(); // 100 wdf.Float5 = br.ReadSingle(); //10 wdf.Radius = br.ReadSingle(); br.FindNext("WGEO"); var numParts = br.ReadUInt32(); wdf.Parts = new SdfPart[numParts]; for (int i = 0; i < numParts; i++) { var sdfPart = new SdfPart(); sdfPart.Name = br.ReadCString(8); sdfPart.Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.ParentName = br.ReadCString(8); br.BaseStream.Seek(36, SeekOrigin.Current); wdf.Parts[i] = sdfPart; } return(wdf); } }
public static Vdf ParseVdf(string filename) { using (var br = new Bwd2Reader(filename)) { var vdf = new Vdf(); br.FindNext("VDFC"); vdf.Name = br.ReadCString(16); vdf.Unk0 = br.ReadUInt32(); vdf.Unk1 = br.ReadUInt32(); vdf.Unk2 = br.ReadUInt32(); vdf.Unk70f = br.ReadSingle(); vdf.Unk35f = br.ReadSingle(); vdf.Unk30f = br.ReadSingle(); vdf.Unk25f = br.ReadSingle(); vdf.Unk255b = br.ReadByte(); vdf.Unk255b2 = br.ReadByte(); vdf.Unk127b = br.ReadByte(); vdf.Unk127b2 = br.ReadByte(); vdf.Unk1320f = br.ReadSingle(); vdf.Unk1f = br.ReadSingle(); vdf.Unk63b = br.ReadByte(); vdf.Unk82b = br.ReadByte(); vdf.Unk73b = br.ReadByte(); vdf.Unk157b = br.ReadByte(); vdf.Unk57b = br.ReadByte(); vdf.Unk4 = br.ReadUInt32(); br.FindNext("SOBJ"); vdf.SOBJGeoName = br.ReadCString(8); vdf.VLocs = new List <VLoc>(); br.FindNext("VLOC"); while (br.Current != null && br.Current.Name != "EXIT") { var vloc = new VLoc { Number = br.ReadUInt32(), Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()) }; vdf.VLocs.Add(vloc); br.Next(); } br.FindNext("VGEO"); var numParts = br.ReadUInt32(); vdf.PartsThirdPerson = new List <SdfPart[]>(4); for (int damageState = 0; damageState < 4; damageState++) { var parts = new SdfPart[numParts]; for (int i = 0; i < numParts; i++) { var sdfPart = new SdfPart(); sdfPart.Name = br.ReadCString(8); sdfPart.Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.ParentName = br.ReadCString(8); br.BaseStream.Seek(36, SeekOrigin.Current); parts[i] = sdfPart; } vdf.PartsThirdPerson.Add(parts); } br.BaseStream.Seek(100 * numParts * 12, SeekOrigin.Current); vdf.PartsFirstPerson = new SdfPart[numParts]; for (int i = 0; i < numParts; i++) { var sdfPart = new SdfPart(); sdfPart.Name = br.ReadCString(8); sdfPart.Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); sdfPart.ParentName = br.ReadCString(8); br.BaseStream.Seek(36, SeekOrigin.Current); vdf.PartsFirstPerson[i] = sdfPart; } br.FindNext("WLOC"); vdf.WheelLoc = new WheelLoc[6]; for (int i = 0; i < 6; i++) { var wheelLoc = vdf.WheelLoc[i] = new WheelLoc(); var unk1 = br.ReadUInt32(); wheelLoc.Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); wheelLoc.Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); wheelLoc.Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); wheelLoc.Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); var unk2 = br.ReadSingle(); } vdf.HLocs = new List <HLoc>(); br.FindNext("HLOC"); while (br.Current != null && br.Current.Name != "EXIT") { var hloc = new HLoc { Label = br.ReadCString(16), Num1 = br.ReadUInt32(), Num2 = br.ReadUInt32(), Num3 = br.ReadUInt32(), Right = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Up = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Forward = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()), Unk = br.ReadSingle() }; vdf.HLocs.Add(hloc); br.Next(); } return(vdf); } }