public SCBFile(Stream stream) { using (BinaryReader br = new BinaryReader(stream)) { string magic = Encoding.ASCII.GetString(br.ReadBytes(8)); if (magic != "r3d2Mesh") { throw new Exception("This is not a valid SCB file"); } ushort major = br.ReadUInt16(); ushort minor = br.ReadUInt16(); if (major != 3 && major != 2 && minor != 1) { throw new Exception(string.Format("The Version: {0}.{1} is not supported", major, minor)); } string Name = Encoding.ASCII.GetString(br.ReadBytes(128)).Replace("\0", ""); uint vertexCount = br.ReadUInt32(); uint faceCount = br.ReadUInt32(); SCBFlags flags = (SCBFlags)br.ReadUInt32(); Vector3 Org = new Vector3(br); Vector3 Size = new Vector3(br); bool hasTangents = false; if (major == 3 && minor == 2) { hasTangents = br.ReadUInt32() == 1; } for (int i = 0; i < vertexCount; i++) { Vertices.Add(new Vector3(br)); } if (major == 3 && minor == 2 && flags.HasFlag(SCBFlags.TANGENTS) && hasTangents) { for (int i = 0; i < vertexCount; i++) { byte o = br.ReadByte(); byte k = br.ReadByte(); byte m = br.ReadByte(); byte n = br.ReadByte(); } } float u = br.ReadSingle(); float j = br.ReadSingle(); float b = br.ReadSingle(); for (int i = 0; i < faceCount; i++) { SCBFace face = new SCBFace(br); if (!Materials.ContainsKey(face.Material)) { Materials.Add(face.Material, new List <SCBFace>()); } Materials[face.Material].Add(face); } } }
public SCOFace(SCBFace face) { this.Indices = face.Indices; this.Material = face.Material; this.UVs = face.UVs; }