public void GenerateRooms(OctTree tree) { if (tree.GetChildCount() != 0) { foreach (OctTree subTree in tree.children) { if (subTree != null) { GenerateRooms(subTree); } } } else { RoomNode newRoom = new RoomNode(tree.boundary); newRoom.roomBounds.extents -= Vector3.one * minSeparation; newRoom.RandomizeBounds(Vector3.one, minRoomSize, maxRoomSize); newRoom.QuantizeBounds(corridorSize); /*Vector3 center, extents; * * extents.x = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.x)); * extents.y = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.y)); * extents.z = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.z)); * * center = tree.boundary.center; * center.x = Mathf.Round (center.x + Random.Range (extents.x - tree.boundary.extents.x, tree.boundary.extents.x - extents.x)); * center.y = Mathf.Round (center.y + Random.Range (extents.y - tree.boundary.extents.y, tree.boundary.extents.y - extents.y)); * center.z = Mathf.Round (center.z + Random.Range (extents.z - tree.boundary.extents.z, tree.boundary.extents.z - extents.z)); * * newRoom.roomBounds.center = center; * newRoom.roomBounds.extents = extents;*/ newRoom.octTreeNode = tree; roomNodeList.AddFirst(newRoom); tree.roomNode = newRoom; } }
public void GenerateRooms(OctTree tree) { if (tree.GetChildCount () != 0) { foreach (OctTree subTree in tree.children) { if (subTree != null) { GenerateRooms (subTree); } } } else { RoomNode newRoom = new RoomNode (tree.boundary); newRoom.roomBounds.extents -= Vector3.one * minSeparation; newRoom.RandomizeBounds (Vector3.one, minRoomSize, maxRoomSize); newRoom.QuantizeBounds (corridorSize); /*Vector3 center, extents; extents.x = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.x)); extents.y = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.y)); extents.z = Mathf.Floor (Random.Range (minRoomSize / 2, tree.boundary.extents.z)); center = tree.boundary.center; center.x = Mathf.Round (center.x + Random.Range (extents.x - tree.boundary.extents.x, tree.boundary.extents.x - extents.x)); center.y = Mathf.Round (center.y + Random.Range (extents.y - tree.boundary.extents.y, tree.boundary.extents.y - extents.y)); center.z = Mathf.Round (center.z + Random.Range (extents.z - tree.boundary.extents.z, tree.boundary.extents.z - extents.z)); newRoom.roomBounds.center = center; newRoom.roomBounds.extents = extents;*/ newRoom.octTreeNode = tree; roomNodeList.AddFirst (newRoom); tree.roomNode = newRoom; } }