コード例 #1
0
        static Model convertAndInsertModel(GeoSet tgt, Model32 v)
        {
            Model z = new Model();

            z.flags             = (ModelFlags)v.flg1;
            z.visibility_radius = v.radius;
            z.num_textures      = v.num_textures;
            z.m_id            = v.id;
            z.boneinfo_offset = v.boneinfo;

            z.BlendMode       = (CoHBlendMode)v.blend_mode;
            z.vertex_count    = v.vertex_count;
            z.model_tri_count = v.model_tri_count;
            z.scale           = v.m_scale;
            z.box.SetMinMax(v.m_min, v.m_max);
            for (byte i = 0; i < 7; ++i)
            {
                DeltaPack dp_blk = z.packed_data.get(i);
                PackInfo  pi     = v.pack_data[i];
                dp_blk.compressed_size = pi.compressed_size;
                dp_blk.uncomp_size     = pi.uncomp_size;
                dp_blk.compressed_data = null;
                dp_blk.buffer_offset   = pi.compressed_data_off;
            }

            tgt.subs.Add(z);
            return(z);
        }
コード例 #2
0
        private Model32[] readModel32(BinaryReader decompHdr, int header32NumSubs)
        {
            Model32[] res = new Model32[header32NumSubs];
            for (int i = 0; i < header32NumSubs; ++i)
            {
                var start = decompHdr.BaseStream.Position;
                res[i].flg1                 = decompHdr.ReadInt32();
                res[i].radius               = decompHdr.ReadSingle();
                res[i].vbo                  = decompHdr.ReadInt32();
                res[i].num_textures         = decompHdr.ReadUInt32();
                res[i].id                   = decompHdr.ReadInt16();
                res[i].blend_mode           = decompHdr.ReadByte();
                res[i].loadstate            = (char)decompHdr.ReadByte();
                res[i].boneinfo             = decompHdr.ReadInt32();
                res[i].trck_node            = decompHdr.ReadInt32();
                res[i].vertex_count         = decompHdr.ReadUInt32();
                res[i].model_tri_count      = decompHdr.ReadUInt32();
                res[i].texture_bind_offsets = decompHdr.ReadInt32();
                res[i].unpacked_1           = decompHdr.ReadInt32();
                res[i].grid_pos             = readVector3(decompHdr);
                res[i].grid_size            = decompHdr.ReadSingle();
                res[i].grid_invsize         = decompHdr.ReadSingle();
                res[i].grid_tag             = decompHdr.ReadSingle();
                res[i].grid_numbits         = decompHdr.ReadInt32();
                res[i].ctris                = decompHdr.ReadInt32();
                res[i].triangle_tags        = decompHdr.ReadInt32();
                res[i].bone_name_offset     = decompHdr.ReadInt32();
                res[i].num_altpivots        = decompHdr.ReadInt32();
                res[i].extra                = decompHdr.ReadInt32();
                res[i].m_scale              = readVector3(decompHdr);
                res[i].m_min                = readVector3(decompHdr);
                res[i].m_max                = readVector3(decompHdr);
                res[i].geoset_list_idx      = decompHdr.ReadInt32();
                res[i].pack_data            = new PackInfo[7];
                for (int j = 0; j < 7; ++j)
                {
                    res[i].pack_data[j].compressed_size     = decompHdr.ReadInt32();
                    res[i].pack_data[j].uncomp_size         = decompHdr.ReadInt32();
                    res[i].pack_data[j].compressed_data_off = decompHdr.ReadInt32();
                }
            }

            return(res);
        }
コード例 #3
0
        private void geosetLoadHeader(FileStream fp)
        {
            int          anm_hdr_size;
            int          headersize;
            BinaryReader br = new BinaryReader(fp, new ASCIIEncoding());

            anm_hdr_size  = br.ReadInt32();
            anm_hdr_size -= 4;
            headersize    = br.ReadInt32();

            byte[] zipmem = br.ReadBytes(anm_hdr_size);
            byte[] decompr;
            Tools.DecompressData(zipmem, out decompr, headersize);

            Stream       unc_arr    = new MemoryStream(decompr);
            BinaryReader decomp_hdr = new BinaryReader(unc_arr, new ASCIIEncoding());

            //const uint8_t * mem = (const uint8_t *)unc_arr.data();
            TexBlockInfo info = readTexBlock(decomp_hdr);

            this.geo_data_size = info.size1;

            var ver = decomp_hdr.BaseStream.Position;

            tex_names = convertTextureNames(decomp_hdr);


            decomp_hdr.BaseStream.Seek(ver + info.texname_blocksize, SeekOrigin.Begin);

            MemoryStream bone_name_stream = new MemoryStream(decomp_hdr.ReadBytes(info.bone_names_size));
            BinaryReader bone_name_reader = new BinaryReader(bone_name_stream, new ASCIIEncoding());

            MemoryStream tex_binds_stream = new MemoryStream(decomp_hdr.ReadBytes(info.tex_binds_size));
            BinaryReader tex_bind_reader  = new BinaryReader(tex_binds_stream, new ASCIIEncoding());


            GeosetHeader32 header32 = readGeosetHeader(decomp_hdr);

            Model32[] ptr_subs = readModel32(decomp_hdr, header32.num_subs);
            parent_geoset = this;
            name          = new string(header32.name);
            name          = name.Substring(0, Math.Max(0, name.IndexOf('\0')));
            bool has_alt_pivot = false;

            for (int idx = 0; idx < header32.num_subs; ++idx)
            {
                Model32            sub_model = ptr_subs[idx];
                List <TextureBind> binds     = new List <TextureBind>();
                if (info.tex_binds_size != 0)
                {
                    binds = convertTexBinds(sub_model.num_textures, sub_model.texture_bind_offsets, tex_bind_reader);
                }

                if (sub_model.num_altpivots > 0)
                {
                    has_alt_pivot |= true;
                }
                Model m = convertAndInsertModel(this, sub_model);
                m.texture_bind_info = binds;
                m.geoset            = this;
                m.name        = readCStringAtOffset(bone_name_reader, sub_model.bone_name_offset);
                ptr_subs[idx] = sub_model;
            }

            if (this.subs.Count != 0)
            {
                addModelStubs(this);
            }
            if (has_alt_pivot)
            {
                Debug.Log("Alternate model pivots were not converted");
            }
        }