public void ReadFromCAR(Stream stream) { ushort vertexCount = stream.ReadUShort(); // at 0x80 ushort normalCount = stream.ReadUShort(); ushort triangleCount = stream.ReadUShort(); ushort quadCount = stream.ReadUShort(); stream.Position += sizeof(ushort) * 2; ushort uvTriangleCount = stream.ReadUShort(); ushort uvQuadCount = stream.ReadUShort(); stream.Position += sizeof(ushort) * 10; // at 0x90 Scale = stream.ReadUShort(); stream.Position += 2; Vertices = new List <Vertex>(vertexCount); // at 0xA8 Normals = new List <Normal>(normalCount); Triangles = new List <Polygon>(triangleCount); Quads = new List <Polygon>(quadCount); UVTriangles = new List <UVPolygon>(uvTriangleCount); UVQuads = new List <UVPolygon>(uvQuadCount); for (int i = 0; i < vertexCount; i++) { var vertex = new Vertex(); vertex.ReadFromCAR(stream); Vertices.Add(vertex); } for (int i = 0; i < normalCount; i++) { var normal = new Normal(); normal.ReadFromCAR(stream); Normals.Add(normal); } for (int i = 0; i < triangleCount; i++) { var triangle = new Polygon(); triangle.ReadFromCAR(stream, false, Vertices, Normals); Triangles.Add(triangle); } for (int i = 0; i < quadCount; i++) { var quad = new Polygon(); quad.ReadFromCAR(stream, true, Vertices, Normals); Quads.Add(quad); } for (int i = 0; i < uvTriangleCount; i++) { var uvTriangle = new UVPolygon(); uvTriangle.ReadFromCAR(stream, false, Vertices, Normals); UVTriangles.Add(uvTriangle); } for (int i = 0; i < uvQuadCount; i++) { var uvQuad = new UVPolygon(); uvQuad.ReadFromCAR(stream, true, Vertices, Normals); UVQuads.Add(uvQuad); } // calculate model bounds - can't spot this sort of data in CAR GenerateBoundingBox(); }
public void ReadFromCAR(Stream stream) { ushort vertexCount = stream.ReadUShort(); ushort normalCount = stream.ReadUShort(); ushort triangleCount = stream.ReadUShort(); ushort quadCount = stream.ReadUShort(); stream.Position += sizeof(ushort) * 2; ushort uvTriangleCount = stream.ReadUShort(); ushort uvQuadCount = stream.ReadUShort(); stream.Position += sizeof(ushort) * 12; Vertices = new List <Vertex>(vertexCount); Normals = new List <Normal>(normalCount); Triangles = new List <Polygon>(triangleCount); Quads = new List <Polygon>(quadCount); UVTriangles = new List <UVPolygon>(uvTriangleCount); UVQuads = new List <UVPolygon>(uvQuadCount); for (int i = 0; i < vertexCount; i++) { var vertex = new Vertex(); vertex.ReadFromCAR(stream); Vertices.Add(vertex); } for (int i = 0; i < normalCount; i++) { var normal = new Normal(); normal.ReadFromCAR(stream); Normals.Add(normal); } for (int i = 0; i < triangleCount; i++) { var triangle = new Polygon(); triangle.ReadFromCAR(stream, false, Vertices, Normals); Triangles.Add(triangle); } for (int i = 0; i < quadCount; i++) { var quad = new Polygon(); quad.ReadFromCAR(stream, true, Vertices, Normals); Quads.Add(quad); } for (int i = 0; i < uvTriangleCount; i++) { var uvTriangle = new UVPolygon(); uvTriangle.ReadFromCAR(stream, false, Vertices, Normals); UVTriangles.Add(uvTriangle); } for (int i = 0; i < uvQuadCount; i++) { var uvQuad = new UVPolygon(); uvQuad.ReadFromCAR(stream, true, Vertices, Normals); UVQuads.Add(uvQuad); } }