Exemple #1
0
		public static BSPTree ReadBSPTree(BinaryReader reader)
		{
			var rootId = reader.ReadInt16();
			BSPNode[] nodes;

			var numNodes = reader.ReadUInt16();
			if (numNodes > 0)
			{
				nodes = new BSPNode[numNodes];
				for (var i = 0; i < numNodes; i++)
				{
					nodes[i] = ReadBSPNode(reader);
				}
			}
			else
			{
				nodes = null;
			}

			return new BSPTree(rootId, nodes);
		}
Exemple #2
0
		public static BSPNode ReadBSPNode(BinaryReader reader)
		{
			var node = new BSPNode
			{
				flags = ((BSPNodeFlags)reader.ReadByte()),
				negChild = reader.ReadInt16(),
				posChild = reader.ReadInt16(),
				planeDist = reader.ReadPackedFloat()
			};

			var numIndices = reader.ReadUInt16();
			if (numIndices > 0)
			{
				var indices = new Index3[numIndices];
				for (var i = 0; i < numIndices; i++)
				{
					indices[i] = reader.ReadIndex3();
				}
				node.TriIndices = indices;
			}
			else
			{
				node.TriIndices = null;
			}

			return node;
		}
Exemple #3
0
 public BSPTree(short rootId, BSPNode[] nodes)
 {
     this.rootId = rootId;
     this.nodes = nodes;
 }