示例#1
0
文件: BspUtils.cs 项目: Exactol/Forge
        private static void ReadPlaneLump()
        {
            Console.WriteLine("\n\n-----PLANES-----");
            Console.WriteLine("Lump offset: {0}", PLANE_DATA.fileOffset);
            Console.WriteLine("Lump length: {0}", PLANE_DATA.fileLength);
            Console.WriteLine("Lump version: {0}", PLANE_DATA.version);

            byte[] tempByte = new byte[20];             //Temporary byte array to hold each plane lump which is 20 bytes

            PlaneLump tempLump = new PlaneLump();

            //Add each plane to the list
            for (int i = 0; i < PLANE_DATA.fileLength;)
            {
                Array.Copy(PLANE_DATA.data, i, tempByte, 0, 20);                 //copy 20 bytes to temp array

                tempLump.FillLump(tempByte);

                planeList.Add(tempLump);
                //Console.WriteLine(tempLump.dist);
                //Console.WriteLine(tempLump.normal);
                i += 20;
            }

            //foreach (var item in planeList)
            //{
            //    Console.WriteLine(item.normal);
            //}
        }
示例#2
0
        public static Vertex[] PlaneLumpToVertices(PlaneLump plane)
        {
            List <Vertex> vertList = new List <Vertex>();

            //plane.dist / plane.normal
            //plane.

            return(vertList.ToArray());
        }
示例#3
0
        //Fill lump info from byte array
        public void FillLump(byte[] input)
        {
            this.planeNum           = BitConverter.ToUInt16(input, 0);
            this.side               = input[2];
            this.onNode             = input[3];
            this.firstEdge          = BitConverter.ToInt32(input, 4);
            this.numEdges           = BitConverter.ToInt16(input, 8);
            this.texInfo            = BitConverter.ToInt16(input, 10);
            this.dispInfo           = BitConverter.ToInt16(input, 12);
            this.surfaceFogVolumeId = BitConverter.ToInt16(input, 14);
            this.styles             = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                this.styles[i] = input[16 + i];
            }
            this.lightOffset = BitConverter.ToInt32(input, 18);
            this.area        = BitConverter.ToSingle(input, 22);
            this.lightmapTexturesMinsInLuxels    = new int[2];
            this.lightmapTexturesMinsInLuxels[0] = BitConverter.ToInt32(input, 28);
            this.lightmapTexturesMinsInLuxels[1] = BitConverter.ToInt32(input, 32);
            this.lightmapTextureSizeInLuxels     = new int[2];
            this.lightmapTextureSizeInLuxels[0]  = BitConverter.ToInt32(input, 36);
            this.lightmapTextureSizeInLuxels[1]  = BitConverter.ToInt32(input, 40);
            this.originalFace    = BitConverter.ToInt32(input, 44);
            this.numPrims        = BitConverter.ToUInt16(input, 48);
            this.firstPrimID     = BitConverter.ToUInt16(input, 50);
            this.smoothingGroups = BitConverter.ToUInt32(input, 52);


            //Copy the portion of the edge list relevant to this face
            edgesContained = new List <Edge>();

            foreach (int index in BSP.surfList.GetRange(firstEdge, numEdges))
            {
                if (index > 0)
                {
                    edgesContained.Add(BSP.edgeList[index]);
                }                 //If index is -, reverse the direction of edges
                else
                {
                    edgesContained.Add(BSP.edgeList[Math.Abs(index)].Reverse());
                }
            }

            plane = BSP.planeList[planeNum];
            //foreach (var item in edgesContained)
            //{
            //    Console.WriteLine(item.vert1);
            //    Console.WriteLine(item.vert2+"\n");
            //}
        }