Ejemplo n.º 1
0
        void Parse(Stream s)
        {
            int tgiPosn;

            BinaryReader r = new BinaryReader(s);

            version               = r.ReadUInt32();
            tgiPosn               = r.ReadInt32() + 8;
            presets               = new PresetList(OnResourceChanged, s);
            unknown1              = BigEndianUnicodeString.Read(s);
            sortPriority          = r.ReadSingle();
            unknown2              = r.ReadByte();
            clothing              = (ClothingType)r.ReadUInt32();
            dataType              = (DataTypeFlags)r.ReadUInt32();
            ageGender             = new AgeGenderFlags(0, OnResourceChanged, s);
            clothingCategory      = (ClothingCategoryFlags)r.ReadUInt32();
            casPart1Index         = r.ReadByte();
            casPart2Index         = r.ReadByte();
            blendInfoFatIndex     = r.ReadByte();
            blendInfoFitIndex     = r.ReadByte();
            blendInfoThinIndex    = r.ReadByte();
            blendInfoSpecialIndex = r.ReadByte();
            overlayPriority       = r.ReadUInt32();
            vpxyIndexes           = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            lodInfo               = new LODInfoEntryList(OnResourceChanged, s);
            diffuse1Indexes       = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            specular1Indexes      = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            diffuse2Indexes       = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            specular2Indexes      = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            bondIndexes           = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte);
            unknown4              = BigEndianUnicodeString.Read(s);

            if (checking)
            {
                if (tgiPosn != s.Position)
                {
                    throw new InvalidDataException(String.Format("Position of TGIBlock read: 0x{0:X8}, actual: 0x{1:X8}",
                                                                 tgiPosn, s.Position));
                }
            }

            byte count = r.ReadByte();

            tgiBlocks = new CountedTGIBlockList(OnResourceChanged, "IGT", count, s);

            vpxyIndexes.ParentTGIBlocks         = diffuse1Indexes.ParentTGIBlocks = specular1Indexes.ParentTGIBlocks =
                diffuse2Indexes.ParentTGIBlocks = specular2Indexes.ParentTGIBlocks = bondIndexes.ParentTGIBlocks = tgiBlocks;
        }
Ejemplo n.º 2
0
        protected override Stream UnParse()
        {
            long         posn, tgiPosn, end;
            MemoryStream s = new MemoryStream();
            BinaryWriter w = new BinaryWriter(s);

            w.Write(version);
            posn = s.Position;
            w.Write((int)0); //offset

            if (presets == null)
            {
                presets = new PresetList(OnResourceChanged);
            }
            presets.UnParse(s);

            BigEndianUnicodeString.Write(s, unknown1);
            w.Write(sortPriority);
            w.Write(unknown2);
            w.Write((uint)clothing);
            w.Write((uint)dataType);
            if (ageGender == null)
            {
                ageGender = new AgeGenderFlags(0, OnResourceChanged);
            }
            ageGender.UnParse(s);
            w.Write((uint)clothingCategory);
            w.Write(casPart1Index);
            w.Write(casPart2Index);
            w.Write(blendInfoFatIndex);
            w.Write(blendInfoFitIndex);
            w.Write(blendInfoThinIndex);
            w.Write(blendInfoSpecialIndex);
            w.Write(overlayPriority);

            if (tgiBlocks == null)
            {
                tgiBlocks = new CountedTGIBlockList(OnResourceChanged, "IGT");
            }
            if (vpxyIndexes == null)
            {
                vpxyIndexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            vpxyIndexes.UnParse(s);
            if (lodInfo == null)
            {
                lodInfo = new LODInfoEntryList(OnResourceChanged);
            }
            lodInfo.UnParse(s);
            if (diffuse1Indexes == null)
            {
                diffuse1Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            diffuse1Indexes.UnParse(s);
            if (specular1Indexes == null)
            {
                specular1Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            specular1Indexes.UnParse(s);
            if (diffuse2Indexes == null)
            {
                diffuse2Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            diffuse2Indexes.UnParse(s);
            if (specular2Indexes == null)
            {
                specular2Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            specular2Indexes.UnParse(s);
            if (bondIndexes == null)
            {
                bondIndexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks);
            }
            bondIndexes.UnParse(s);
            BigEndianUnicodeString.Write(s, unknown4);

            tgiPosn = s.Position;
            w.Write((byte)tgiBlocks.Count);
            tgiBlocks.UnParse(s);

            end = s.Position;

            s.Position = posn;
            w.Write((int)(tgiPosn - posn - sizeof(int)));
            s.Position = end;

            vpxyIndexes.ParentTGIBlocks         = diffuse1Indexes.ParentTGIBlocks = specular1Indexes.ParentTGIBlocks =
                diffuse2Indexes.ParentTGIBlocks = specular2Indexes.ParentTGIBlocks = bondIndexes.ParentTGIBlocks = tgiBlocks;

            s.Flush();
            return(s);
        }