public static TextureMapper Load(Utility utility)
        {
            var tm = new TextureMapper();

            CGFXDebug.LoadStart(tm, utility);

            tm.TypeId = utility.ReadU32();
            if (tm.TypeId != 0x80000000)
            {
                throw new InvalidOperationException($"TextureMapper: Expected type 0x80000000, got {tm.TypeId}");
            }

            tm.DynamicAllocator = utility.ReadU32();

            // Texture Reference
            tm.TextureReference = utility.LoadDICTObj <TextureReference>();

            // Sampler
            utility.LoadIndirect(() =>
            {
                tm.TextureSampler = TextureSampler.Load(tm, utility);
            });

            tm.Commands       = utility.ReadUInts(14);
            tm.CommandsLength = utility.ReadU32();  // Seems to be length of the aforementioned "Commands"?

            // I think this is a fair sanity check??
            if (tm.CommandsLength != (14 * 4))
            {
                throw new InvalidOperationException("CommandsLength mismatch");
            }

            return(tm);
        }
示例#2
0
        public static TextureSampler Load(TextureMapper parent, Utility utility)
        {
            var s = new TextureSampler();

            CGFXDebug.LoadStart(s, utility);

            // This has a TypeId here...
            s.TypeId = utility.ReadU32();
            if (s.TypeId != 0x80000000)
            {
                throw new InvalidOperationException($"TextureSampler: Expected type 0x80000000, got {s.TypeId}");
            }

            // Just reading the offset but we'll resolve this later
            var ownerModelOffset = utility.ReadOffset();

            s.Parent = parent;

            s.MinFilter = (TextureMinFilter)utility.ReadU32();

            s.BorderColor = ColorFloat.Read(utility);
            s.LODBias     = utility.ReadFloat();

            return(s);
        }