Ejemplo n.º 1
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++;
                }
            }
        }
Ejemplo n.º 2
0
        private void ReadBrushes(InternalBspLump lump, BinaryReader reader)
        {
            reader.BaseStream.Seek(lump.offset, SeekOrigin.Begin);
            brushes = new InternalBspBrush[lump.size / Marshal.SizeOf(typeof(InternalBspBrush))];

            for (int i = 0; i < brushes.Length; i++)
            {
                brushes[i]             = new InternalBspBrush();
                brushes[i].firstSide   = reader.ReadInt32();
                brushes[i].numSides    = reader.ReadInt32();
                brushes[i].shaderIndex = reader.ReadInt32();
            }
        }
Ejemplo n.º 3
0
        private void CreateBrushes(Quake3Level q3lvl)
        {
            // Reserve enough memory for all brushes, solid or not (need to maintain indexes)
            brushes = new BspBrush[q3lvl.NumBrushes];

            for (int i = 0; i < q3lvl.NumBrushes; i++)
            {
                InternalBspBrush q3brush = q3lvl.Brushes[i];

                // Create a new OGRE brush
                BspBrush brush         = new BspBrush();
                int      numBrushSides = q3brush.numSides;
                int      brushSideIdx  = q3brush.firstSide;

                // Iterate over the sides and create plane for each
                while (numBrushSides-- > 0)
                {
                    InternalBspPlane side = q3lvl.Planes[q3lvl.BrushSides[brushSideIdx].planeNum];

                    // Notice how we normally invert Q3A plane distances, but here we do not
                    // Because we want plane normals pointing out of solid brushes, not in.
                    Plane brushSide = new Plane(
                        new Vector3(
                            q3lvl.Planes[q3lvl.BrushSides[brushSideIdx].planeNum].normal[0],
                            q3lvl.Planes[q3lvl.BrushSides[brushSideIdx].planeNum].normal[1],
                            q3lvl.Planes[q3lvl.BrushSides[brushSideIdx].planeNum].normal[2]
                            ), q3lvl.Planes[q3lvl.BrushSides[brushSideIdx].planeNum].distance);

                    brush.Planes.Add(brushSide);
                    brushSideIdx++;
                }

                // Build world fragment
                brush.Fragment.FragmentType = WorldFragmentType.PlaneBoundedRegion;
                brush.Fragment.Planes       = brush.Planes;

                brushes[i] = brush;
            }
        }
Ejemplo n.º 4
0
		private void ReadBrushes( InternalBspLump lump, BinaryReader reader )
		{
			reader.BaseStream.Seek( lump.offset, SeekOrigin.Begin );

			for ( int i = 0; i < brushes.Length; i++ )
			{
				brushes[ i ] = new InternalBspBrush();
				brushes[ i ].firstSide = reader.ReadInt32();
				brushes[ i ].numSides = reader.ReadInt32();
				brushes[ i ].shaderIndex = reader.ReadInt32();
			}
		}