コード例 #1
0
        private void ReadLeaves(InternalBspLump lump, BinaryReader reader)
        {
            reader.BaseStream.Seek(lump.offset, SeekOrigin.Begin);
            leaves = new InternalBspLeaf[lump.size / Marshal.SizeOf(typeof(InternalBspLeaf))];

            for (int i = 0; i < leaves.Length; i++)
            {
                leaves[i]         = new InternalBspLeaf();
                leaves[i].cluster = reader.ReadInt32();
                leaves[i].area    = reader.ReadInt32();

                leaves[i].bbox = new int[6];

                for (int j = 0; j < leaves[i].bbox.Length; j++)
                {
                    leaves[i].bbox[j] = reader.ReadInt32();
                }

                leaves[i].faceStart  = reader.ReadInt32();
                leaves[i].faceCount  = reader.ReadInt32();
                leaves[i].brushStart = reader.ReadInt32();
                leaves[i].brushCount = reader.ReadInt32();

                TransformBoundingBox(leaves[i].bbox);
            }
        }
コード例 #2
0
        private void CreateLeaves(Quake3Level q3lvl)
        {
            for (int i = 0; i < q3lvl.NumLeaves; ++i)
            {
                BspNode         node   = nodes[i + this.LeafStart];
                InternalBspLeaf q3leaf = q3lvl.Leaves[i];

                node.IsLeaf = true;
                node.Owner  = this;

                // Set bounding box
                node.BoundingBox.Minimum = new Vector3(
                    q3leaf.bbox[0],
                    q3leaf.bbox[1],
                    q3leaf.bbox[2]
                    );
                node.BoundingBox.Maximum = new Vector3(
                    q3leaf.bbox[3],
                    q3leaf.bbox[4],
                    q3leaf.bbox[5]
                    );

                // Set faces
                node.FaceGroupStart = q3leaf.faceStart;
                node.NumFaceGroups  = q3leaf.faceCount;
                node.VisCluster     = q3leaf.cluster;

                // Load Brushes for this leaf
                int realBrushIdx = 0, solidIdx = 0;
                int brushCount = q3leaf.brushCount;
                int brushIdx   = q3leaf.brushStart;

                node.SolidBrushes = new BspBrush[brushCount];

                while (brushCount-- > 0)
                {
                    realBrushIdx = q3lvl.LeafBrushes[brushIdx];
                    InternalBspBrush q3brush = q3lvl.Brushes[realBrushIdx];

                    // Only load solid ones, we don't care about any other types
                    // Shader determines this.
                    InternalBspShader brushShader = q3lvl.Shaders[q3brush.shaderIndex];

                    if ((brushShader.contentFlags & ContentFlags.Solid) == ContentFlags.Solid)
                    {
                        node.SolidBrushes[solidIdx] = brushes[realBrushIdx];
                    }

                    brushIdx++;
                    solidIdx++;
                }
            }
        }
コード例 #3
0
ファイル: Quake3Level.cs プロジェクト: WolfgangSt/axiom
		private void ReadLeaves( InternalBspLump lump, BinaryReader reader )
		{
			reader.BaseStream.Seek( lump.offset, SeekOrigin.Begin );

			for ( int i = 0; i < leaves.Length; i++ )
			{
				leaves[ i ] = new InternalBspLeaf();
				leaves[ i ].cluster = reader.ReadInt32();
				leaves[ i ].area = reader.ReadInt32();

				leaves[ i ].bbox = new int[ 6 ];

				for ( int j = 0; j < leaves[ i ].bbox.Length; j++ )
					leaves[ i ].bbox[ j ] = reader.ReadInt32();

				leaves[ i ].faceStart = reader.ReadInt32();
				leaves[ i ].faceCount = reader.ReadInt32();
				leaves[ i ].brushStart = reader.ReadInt32();
				leaves[ i ].brushCount = reader.ReadInt32();

				TransformBoundingBox( leaves[ i ].bbox );
			}
		}