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++; } } }
private void ReadShaders(InternalBspLump lump, BinaryReader reader) { reader.BaseStream.Seek(lump.offset, SeekOrigin.Begin); shaders = new InternalBspShader[lump.size / Marshal.SizeOf(typeof(InternalBspShader))]; for (int i = 0; i < shaders.Length; i++) { char[] name = Encoding.ASCII.GetChars(reader.ReadBytes(64)); shaders[i] = new InternalBspShader(); shaders[i].surfaceFlags = (SurfaceFlags)Enum.Parse(typeof(SurfaceFlags), reader.ReadInt32().ToString()); shaders[i].contentFlags = (ContentFlags)Enum.Parse(typeof(ContentFlags), reader.ReadInt32().ToString()); foreach (char c in name) { if (c == '\0') { break; } shaders[i].name += c; } } }
private void ReadShaders( InternalBspLump lump, BinaryReader reader ) { reader.BaseStream.Seek( lump.offset, SeekOrigin.Begin ); shaders = new InternalBspShader[ lump.size / Marshal.SizeOf( typeof( InternalBspShader ) ) ]; for ( int i = 0; i < shaders.Length; i++ ) { char[] name = Encoding.ASCII.GetChars( reader.ReadBytes( 64 ) ); shaders[ i ] = new InternalBspShader(); shaders[ i ].surfaceFlags = (SurfaceFlags)Enum.Parse( typeof( SurfaceFlags ), reader.ReadInt32().ToString() ); shaders[ i ].contentFlags = (ContentFlags)Enum.Parse( typeof( ContentFlags ), reader.ReadInt32().ToString() ); foreach ( char c in name ) { if ( c == '\0' ) break; shaders[ i ].name += c; } } }