Example #1
0
        private void ReadPlanes(InternalBspLump lump, BinaryReader reader)
        {
            reader.BaseStream.Seek(lump.offset, SeekOrigin.Begin);
            planes = new InternalBspPlane[lump.size / Marshal.SizeOf(typeof(InternalBspPlane))];

            for (int i = 0; i < planes.Length; i++)
            {
                planes[i]          = new InternalBspPlane();
                planes[i].normal   = new float[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
                planes[i].distance = reader.ReadSingle();

                TransformPlane(planes[i].normal, ref planes[i].distance);
            }
        }
Example #2
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;
            }
        }
Example #3
0
		private void ReadPlanes( InternalBspLump lump, BinaryReader reader )
		{
			reader.BaseStream.Seek( lump.offset, SeekOrigin.Begin );

			for ( int i = 0; i < planes.Length; i++ )
			{
				planes[ i ] = new InternalBspPlane();
				planes[ i ].normal = new float[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() };
				planes[ i ].distance = reader.ReadSingle();

				TransformPlane( planes[ i ].normal, ref planes[ i ].distance );
			}
		}