Exemplo n.º 1
0
        public void Read(BinaryReaderEx br)
        {
            pos = br.BaseStream.Position;

            for (int i = 0; i < 9; i++)
            {
                ind[i] = br.ReadInt16();
            }

            quadFlags = (QuadFlags)br.ReadUInt16();

            bitvalue = br.ReadUInt32(); //big endian or little??
            {
                drawOrderLow = (byte)(bitvalue & 0xFF);

                for (int i = 0; i < 4; i++)
                {
                    byte val = (byte)((bitvalue >> 8 + 5 * i) & 0x1F);
                    faceFlags[i] = new FaceFlags(val);
                }

                //extradata = (byte)(bitvalue & 0xF0000000 >> 28);
                extradata = (bitvalue & 0xFFF);
            }

            drawOrderHigh = br.ReadBytes(4);

            for (int i = 0; i < 4; i++)
            {
                ptrTexMid[i] = br.ReadUInt32();

                if (Helpers.TestPointer(ptrTexMid[i]) != 0)
                {
                    Console.WriteLine("mid " + Helpers.TestPointer(ptrTexMid[i]).ToString("x2"));
                    // Console.ReadKey();
                }
            }



            bb = new BoundingBox(br);

            byte tf = br.ReadByte();

            if (tf > 20)
            {
                Helpers.Panic(this, "unexpected terrain flag value -> " + tf);
            }

            terrainFlag        = (TerrainFlags)tf;
            WeatherIntensity   = br.ReadByte();
            WeatherType        = br.ReadByte();
            TerrainFlagUnknown = br.ReadByte();

            id = br.ReadInt16();

            trackPos = br.ReadByte();
            midunk   = br.ReadByte();

            //midflags = br.ReadBytes(2);

            ptrTexLow = br.ReadUInt32();

            if (Helpers.TestPointer(ptrTexLow) != 0)
            {
                Console.WriteLine("ptrTexLow " + Helpers.TestPointer(ptrTexLow).ToString("x2"));
                //Console.ReadKey();
            }

            mosaicStruct = br.ReadUInt32();

            if (Helpers.TestPointer(mosaicStruct) != 0)
            {
                Console.WriteLine("offset2 " + Helpers.TestPointer(mosaicStruct).ToString("x2"));
                //Console.ReadKey();
            }

            for (int i = 0; i < 5; i++)
            {
                unk3.Add(new Vector2s(br));
            }



            /*
             * //this is some value per tirangle
             * foreach(var val in unk3)
             * {
             *  Console.WriteLine(val.X / 4096f + " " + val.Y / 4096f);
             * }
             */

            //struct done

            //read texture layouts
            int texpos = (int)br.BaseStream.Position;

            br.Jump(ptrTexLow);
            texlow = TextureLayout.FromStream(br);


            foreach (uint u in ptrTexMid)
            {
                if (u != 0)
                {
                    br.Jump(u);
                    tex.Add(new CtrTex(br, (int)mosaicStruct));
                }
                else
                {
                    if (ptrTexLow != 0)
                    {
                        Console.WriteLine("!");
                    }
                }
            }

            if (mosaicStruct != 0)
            {
                br.BaseStream.Position = mosaicStruct;

                mosaicPtr1 = br.ReadUInt32();
                mosaicPtr2 = br.ReadUInt32();
                mosaicPtr3 = br.ReadUInt32();
                mosaicPtr4 = br.ReadUInt32();
            }

            br.BaseStream.Position = texpos;
        }
Exemplo n.º 2
0
        public void Read(BinaryReaderEx br)
        {
            long pos = br.BaseStream.Position;

            for (int i = 0; i < 9; i++)
            {
                ind[i] = br.ReadInt16();
            }

            quadFlags = (QuadFlags)br.ReadUInt16();

            bitvalue = br.ReadUInt32Big();
            {
                drawOrderLow = (byte)(bitvalue & 0xFF);

                for (int i = 0; i < 4; i++)
                {
                    byte val = (byte)(bitvalue >> 8 + 5 * i & 0x1F);
                    faceFlags[i] = new FaceFlags(val);
                }

                extradata = (byte)(bitvalue & 0xF0000000 >> 28);
            }

            drawOrderHigh = br.ReadBytes(4);

            for (int i = 0; i < 4; i++)
            {
                ptrTexMid[i] = br.ReadUInt32();
            }

            bb = new BoundingBox(br);

            byte tf = br.ReadByte();

            if (tf > 20)
            {
                Helpers.Panic(this, "unexpected terrain flag value -> " + tf);
            }

            terrainFlag        = (TerrainFlags)tf;
            WeatherIntensity   = br.ReadByte();
            WeatherType        = br.ReadByte();
            TerrainFlagUnknown = br.ReadByte();

            id = br.ReadInt16();

            trackPos = br.ReadByte();
            midunk   = br.ReadByte();

            //midflags = br.ReadBytes(2);

            ptrTexLow = br.ReadInt32();
            offset2   = br.ReadInt32();

            for (int i = 0; i < 10; i++)
            {
                unk3[i] = br.ReadUInt16();
            }

            //struct done

            //read texture layouts
            int texpos = (int)br.BaseStream.Position;

            br.Jump(ptrTexLow);
            texlow = TextureLayout.FromStream(br);


            foreach (uint u in ptrTexMid)
            {
                if (u != 0)
                {
                    br.Jump(u);
                    tex.Add(new CtrTex(br));
                }
                else
                {
                    if (ptrTexLow != 0)
                    {
                        Console.WriteLine("!");
                    }
                }
            }

            br.BaseStream.Position = texpos;
        }