Exemplo n.º 1
0
 internal BSPTree(short rootId, BSPNode[] nodes)
 {
     this.rootId = rootId;
     this.nodes = nodes;
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        private void DumpBranchContents(TextWriter file, BSPNode startAt, Vector3[] vectors)
        {
            // Write the vertices referenced by the first
            var posVertList = new List<Vector3>();
            GetBranchContents(startAt.posChild, vectors, posVertList);
            file.WriteLine("Positive Polys: {0}", posVertList.Count);
            file.WriteLine("_______________");
            file.Write(file.NewLine);

            var min = new Vector3(float.MaxValue);
            var max = new Vector3(float.MinValue);
            foreach (var vert in posVertList)
            {
                min = Vector3.Min(min, vert);
                max = Vector3.Max(max, vert);
            }
            file.WriteLine("MinVals: {0}", min);
            file.WriteLine("MaxVals: {0}", max);
            file.WriteLine(file.NewLine);

            //Write the vertices referenced by the last
            var negVertList = new List<Vector3>();
            GetBranchContents(startAt.negChild, vectors, negVertList);
            file.WriteLine("Negative Polys: {0}", negVertList.Count);
            file.WriteLine("_______________");
            file.Write(file.NewLine);

            min = new Vector3(float.MaxValue);
            max = new Vector3(float.MinValue);
            foreach (var vert in negVertList)
            {
                min = Vector3.Min(min, vert);
                max = Vector3.Max(max, vert);
            }
            file.WriteLine("MinVals: {0}", min);
            file.WriteLine("MaxVals: {0}", max);
            file.WriteLine(file.NewLine);
        }
Exemplo n.º 4
0
        private static BSPTree ReadBSPTree(BinaryReader br)
        {
            var rootId = br.ReadInt16();
            BSPNode[] nodes;

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

            return new BSPTree(rootId, nodes);
        }