private static void ReadModels(BinaryReader br, TreeReference<Model> tree) { var numModels = br.ReadInt32(); for (var i = 0; i < numModels; i++) { var bounds = br.ReadBoundingBox(); Vector3[] vertices; var numVertices = br.ReadInt32(); if (numVertices > 0) { vertices = new Vector3[numVertices]; for (var j = 0; j < numVertices; j++) { vertices[j] = br.ReadVector3(); } } else { vertices = null; } Index3[] indices; var numIndices = br.ReadInt32(); if (numIndices > 0) { indices = new Index3[numIndices]; for (var j = 0; j < numIndices; j++) { indices[j] = br.ReadIndex3(); } } else { indices = null; } var model = new Model { Bounds = bounds, Vertices = vertices, Triangles = indices }; tree.Tree.Insert(model); } }
private static BSPNode ReadBSPNode(BinaryReader br) { var node = new BSPNode { flags = (BSPNodeFlags)br.ReadByte(), negChild = br.ReadInt16(), posChild = br.ReadInt16(), planeDist = br.ReadSingle() }; var numIndices = br.ReadInt32(); if (numIndices > 0) { var indices = new Index3[numIndices]; for (var i = 0; i < numIndices; i++) { indices[i] = br.ReadIndex3(); } node.TriIndices = indices; } else { node.TriIndices = null; } return node; }