Exemple #1
0
        public void Read(BinaryReaderEx br)
        {
            Name  = br.ReadStringFixed(16);
            Index = br.ReadUInt32();
            tl    = TextureLayout.FromReader(br, true);

            Console.WriteLine(Name);
        }
Exemple #2
0
        public void Read(BinaryReaderEx br, int mosaic)
        {
            int pos = (int)br.BaseStream.Position;

            if ((pos & 2) > 0)
            {
                Console.WriteLine("!!!");
                Console.ReadKey();
            }

            //this apparently defines animated texture, really
            if ((pos & 1) == 1)
            {
                isAnimated = true;

                br.BaseStream.Position -= 1;

                uint texpos    = br.ReadUInt32();
                int  numFrames = br.ReadInt16();
                int  whatsthat = br.ReadInt16();

                if (whatsthat != 0)
                {
                    Helpers.Panic(this, PanicType.Assume, $"whatsthat is not null! {whatsthat}");
                }

                if (br.ReadUInt32() != 0)
                {
                    Helpers.Panic(this, PanicType.Assume, "not 0!");
                }

                uint[] ptrs = br.ReadArrayUInt32(numFrames);

                foreach (uint ptr in ptrs)
                {
                    br.Jump(ptr);
                    animframes.Add(TextureLayout.FromReader(br));
                }

                br.Jump(texpos);
            }

            for (int i = 0; i < 3; i++)
            {
                midlods[i] = TextureLayout.FromReader(br);
            }

            //Console.WriteLine(br.BaseStream.Position.ToString("X8"));
            //Console.ReadKey();

            //if (mosaic != 0)
            {
                ptrHi = br.ReadUInt32();

                if (Scene.ReadHiTex)
                {
                    //loosely assume we got a valid pointer
                    if (ptrHi > 0x30000 && ptrHi < 0xB0000)
                    {
                        br.Jump(ptrHi);

                        for (int i = 0; i < 16; i++)
                        {
                            hi[i] = TextureLayout.FromReader(br);
                        }
                    }
                }
            }
        }
Exemple #3
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.ReadUIntPtr();

                if (Helpers.TestPointer(ptrTexMid[i].ToUInt32()) != 0)
                {
                    Helpers.Panic(this, PanicType.Assume, $"ptrTexMid[{i}] {ptrTexMid[i].ToUInt32().ToString("X8")} - {Helpers.TestPointer(ptrTexMid[i].ToUInt32()).ToString("x2")}");
                }
                // Console.ReadKey();
            }



            bb = new BoundingBox(br);

            byte tf = br.ReadByte();

            if (tf > 20)
            {
                Helpers.Panic(this, PanicType.Assume, "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 = (UIntPtr)br.ReadUInt32();

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

            mosaicStruct = br.ReadUIntPtr();

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

            for (int i = 0; i < 5; i++)
            {
                unk3.Add(br.ReadVector2s(1 / 4096f));
            }



            /*
             * //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.FromReader(br);


            foreach (uint u in ptrTexMid)
            {
                if (u == 0)
                {
                    if (ptrTexLow != UIntPtr.Zero)
                    {
                        Helpers.Panic(this, PanicType.Assume, $"Got low tex without mid tex at {br.HexPos()}.");
                    }

                    continue;
                }

                br.Jump(u);
                tex.Add(new CtrTex(br, (int)mosaicStruct));
            }

            if (mosaicStruct != UIntPtr.Zero)
            {
                br.Jump(mosaicStruct);

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

            br.BaseStream.Position = texpos;
        }