Beispiel #1
0
        public Template(PakFile Pak, PakFile.PakTag Item, bool loadMesh)
        {
            var reader = Pak.Reader;

            reader.EndianType   = EndianFormat.LittleEndian;
            reader.StreamOrigin = Item.Offset;
            reader.SeekTo(0);

            reader.ReadInt16(); //E402
            reader.ReadInt32(); //filesize (EOB offset?)

            #region Block E502
            reader.ReadInt16(); //E502
            reader.ReadInt32(); //EOB offset
            reader.ReadInt32(); //LPTA (probs part of the string)
            Name = reader.ReadNullTerminatedString();
            reader.ReadByte();  //00
            #endregion

            #region Block 1603
            reader.ReadInt16();  //1603
            reader.ReadInt32();  //EOB offset
            reader.ReadBytes(3); //02 01 01
            #endregion

            #region Block 5501
            reader.ReadInt16(); //5501
            reader.ReadInt32(); //address

            int count = reader.ReadInt32();
            Materials = new List <MatRefBlock_5601>();
            for (int i = 0; i < count; i++)
            {
                Materials.Add(new MatRefBlock_5601(reader));
            }
            #endregion

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            #region Block F000
            xF000 = reader.ReadInt16();
            reader.ReadInt32(); //EOB offset
            x2C01 = reader.ReadInt16();
            reader.ReadInt32(); //EOB offset

            count   = reader.ReadInt32();
            Objects = new List <Node>();
            for (int i = 0; i < count; i++)
            {
                Objects.Add(new Node(reader, loadMesh));
            }

            foreach (var obj in Objects)
            {
                if (obj.isInheritor)
                {
                    Objects[obj._2901.InheritID].isInherited = true;
                }
            }
            #endregion

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            #region Block E802
            reader.ReadInt16(); //E802
            reader.ReadInt32(); //address

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Bones.Add(new BoneBlock_E902(reader));
            }
            #endregion

            //havent mapped this block, assumed anim/sound related
            _E602 = new unkBlock_XXXX(reader, 0xE602);

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            if (reader.PeekUInt16() == 0xBA01)
            {
                unkStrBlk = new StringBlock_BA01(reader);
            }

            //contains data count, havent seen used
            _1D02 = new unkBlock_XXXX(reader, 0x1D02);

            //int16 count, [int16, int16] * count
            if (reader.PeekUInt16() == 0x1103)
            {
                _1103 = new unkBlock_XXXX(reader, 0x1103);
            }

            //contains null term string, used on IGA models
            _0403 = new unkBlock_XXXX(reader, 0x0403);

            if (reader.PeekUInt16() == 0x0503)
            {
                _0503 = new Block_0503(reader);
            }

            #region Block 0803
            reader.ReadInt16(); //0803
            reader.ReadInt32(); //address to end of bounds values
            reader.ReadInt32(); //bounds count?
            var min = new RealQuat(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            var max = new RealQuat(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

            RenderBounds         = new RealBoundingBox();
            RenderBounds.XBounds = new RealBounds(min.x, max.x);
            RenderBounds.YBounds = new RealBounds(min.y, max.y);
            RenderBounds.ZBounds = new RealBounds(min.z, max.z);
            #endregion

            _0E03 = new Block_0E03(reader);

            //contains length prefixed string
            if (reader.PeekUInt16() == 0x1203)
            {
                _1203 = new unkBlock_XXXX(reader, 0x1203);
            }

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address to EOF

            reader.StreamOrigin = 0;
        }
Beispiel #2
0
        public Scene(PakFile Pak, PakFile.PakTag Item, bool loadMesh)
        {
            var reader = Pak.Reader;

            reader.EndianType   = EndianFormat.LittleEndian;
            reader.StreamOrigin = Item.Offset;
            reader.SeekTo(0);

            Name = Item.Name;

            //contains 16bytes, maybe all uint16
            _C003 = new unkBlock_XXXX(reader, 0xC003);

            #region Block 5501
            reader.ReadInt16(); //5501
            reader.ReadInt32(); //address

            int count = reader.ReadInt32();
            Materials = new List <MatRefBlock_5601>();
            for (int i = 0; i < count; i++)
            {
                Materials.Add(new MatRefBlock_5601(Pak.Reader));
            }
            #endregion

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            #region Block 1F02
            reader.ReadInt16(); //1F02
            reader.ReadInt32(); //EOB offset

            _2002 = new Block_2002(reader);

            _2102 = new Block_2102(reader);

            _2202 = new Block_2202(reader, _2102.unk0);
            #endregion

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            #region Block 8204
            reader.ReadInt16(); //8204
            reader.ReadInt32(); //address

            count   = reader.ReadInt32();
            Scripts = new List <StringBlock_BA01>();
            for (int i = 0; i < count; i++)
            {
                Scripts.Add(new StringBlock_BA01(Pak.Reader));
            }
            #endregion

            _8404 = new unkBlock_XXXX(reader, 0x8404);

            #region Block F000
            xF000 = reader.ReadInt16();
            reader.ReadInt32();
            x2C01 = reader.ReadInt16();
            reader.ReadInt32(); //address to first object

            count   = reader.ReadInt32();
            Objects = new List <Node>();
            for (int i = 0; i < count; i++)
            {
                Objects.Add(new Node(Pak.Reader, loadMesh));
            }
            #endregion

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            //additional geometry, mainly sky objects
            _EA01 = new unkBlock_XXXX(reader, 0xEA01);

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            //additional objects, no geometry, lighting related
            _B801 = new unkBlock_XXXX(reader, 0xB801);

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            //additional objects, no geometry, lighting related
            _8002 = new unkBlock_XXXX(reader, 0x8002);

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            //6x int32
            _2504 = new unkBlock_XXXX(reader, 0x2504);

            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address

            //empty?
            _1D02 = new unkBlock_XXXX(reader, 0x1D02);

            foreach (var obj in Objects)
            {
                if (obj.isInheritor)
                {
                    Objects[obj._2901.InheritID].isInherited = true;
                }
            }

            reader.StreamOrigin = 0;
        }