Beispiel #1
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            var buffersize = file.ReadUInt32();

            var d = CalculateBufferSize();

            if (buffersize != CalculateBufferSize())
            {
                throw new InvalidParsingException("Calculated buffersize is not equal actual buffersize.");
            }

            using (var ms = new MemoryStream(file.ReadBytes((int)buffersize)))
                using (var br = new BinaryReader(ms))
                {
                    waypoints.Read(br, (uint)waypointsCount * 20, waypointsCount);
                    componentsMappings.Read(br, (uint)componentsMappingsCount * 32, componentsMappingsCount);
                    waypointsGroups.Read(br, (uint)waypointsGroupsCount * 12, waypointsGroupsCount);
                    indexes.Read(br, (uint)indexesCount * 2, (int)indexesCount);

                    if (buffersize - ms.Position > 0)
                    {
                        throw new InvalidParsingException("Did not read buffer to the end.");
                    }
                }
        }
Beispiel #2
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            unk.Read(file, 4);
            MipsCount.Read(file, 4);

            // Imported and Cooked xbms have a different file structure.
            // Imported xbms can be identified by their Sourcedata being not null
            var SourceData = this.GetVariableByName("sourceData");

            if (SourceData != null)
            {
                //dbg
                var ResidentMipIndex = this.GetVariableByName("residentMipIndex");
                if (ResidentMipIndex != null)
                {
                    throw new NotImplementedException();
                }

                for (int i = 0; i < MipsCount.val; i++)
                {
                    var mipdata = new SMipData(cr2w);
                    mipdata.Read(file, 16);
                    Mipdata.AddVariable(mipdata);

                    var img = new CByteArray(cr2w);
                    //img.SetParent(this);
                    img.Read(file, 0);
                    Mips.AddVariable(img);
                }
                unk2.Read(file, 4);
            }
            else
            {
                //if (ResidentMipIndex == null)
                //throw new NotImplementedException();


                Mipdata.Read(file, size, (int)MipsCount.val);

                ResidentmipSize.Read(file, 4);

                unk2.Read(file, 4);

                //Residentmip.SetParent(this);
                Residentmip.Read(file, ResidentmipSize.val);
            }

            //if (MipsCount.val > 0)
            //    mips.Read(file, size, (int)MipsCount.val);
            //else
            //    mips.Read(file, size, 1);

            //ResidentmipSize.Read(file, 4);
            //unk2.Read(file, 4);

            //Residentmip.Bytes = file.ReadBytes((int)ResidentmipSize.val);
        }
Beispiel #3
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            buffername.Read(file, 2);
            count.Read(file, size);
            unk.Read(file, 1);
            buffer.Read(file, 0, count.val);
        }
Beispiel #4
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            // get bonecount for compressed buffers
            CArray bones     = variables.FirstOrDefault(_ => _.Name == "bones") as CArray;
            int    bonecount = bones.array.Count;

            rigdata.Read(file, (uint)bonecount * 48, bonecount);
        }
Beispiel #5
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            unk.Read(file, 4);
            MipsCount.Read(file, 4);

            if (MipsCount.val > 0)
            {
                mips.Read(file, size, (int)MipsCount.val);
            }
            else
            {
                mips.Read(file, size, 1);
            }

            filesize.Read(file, 4);
            unk2.Read(file, 4);

            Image.Bytes = file.ReadBytes((int)filesize.val);
        }
Beispiel #6
0
        public override void Read(BinaryReader file, uint size)
        {
            var startpos = file.BaseStream.Position;

            base.Read(file, size);

            var endpos = file.BaseStream.Position;

            var bytesread = endpos - startpos;

            if (bytesread < size)
            {
                buffername.Read(file, 2);
                count.Read(file, size);
                unk.Read(file, 1);
                buffer.Read(file, 0, count.val);
            }
            else if (bytesread > size)
            {
            }
        }