private static BuildingGroup ReadBuildingGroup(BinaryReader br) { var group = new BuildingGroup { Bounds = br.ReadBoundingBox() }; Vector3[] vertices; var numVerts = br.ReadInt32(); if (numVerts > 0) { vertices = new Vector3[numVerts]; for (var j = 0; j < numVerts; j++) { vertices[j] = br.ReadVector3(); } } else { vertices = null; } group.Vertices = vertices; group.Tree = ReadBSPTree(br); return group; }
private static void ReadBuildings(BinaryReader br, TreeReference<Building> tree) { var numBuildings = br.ReadInt32(); for (var i = 0; i < numBuildings; i++) { var bounds = br.ReadBoundingBox(); var invRot = br.ReadSingle(); var matrix = Matrix.CreateRotationY(((-1.0f*(invRot - 90)))*RadiansPerDegree); var center = br.ReadVector3(); BuildingGroup[] groups; var numGroups = br.ReadInt32(); if (numGroups > 0) { groups = new BuildingGroup[numGroups]; for (var j = 0; j < numGroups; j++) { groups[j] = ReadBuildingGroup(br); } } else { groups = null; } var building = new Building { Bounds = bounds, Center = center, InverseRotation = matrix, BuildingGroups = groups }; tree.Tree.Insert(building); } }