Пример #1
0
        private static Model ReadModel(BinaryReader br, int offset)
        {
            br.BaseStream.Seek(offset, SeekOrigin.Begin);

            MDLModel mdl = new MDLModel();
            string model_name = ASCIIEncoding.ASCII.GetString(br.ReadBytes(64));
            int nullindex = model_name.IndexOf('\0');
            if (nullindex != -1)
                model_name = model_name.Substring(0, nullindex);
            mdl.model_name = model_name;
            mdl.model_type = br.ReadInt32();
            mdl.bounding_radius = br.ReadSingle();
            mdl.num_meshes= br.ReadInt32();
            mdl.mesh_offset= br.ReadInt32();
            mdl.num_vertices= br.ReadInt32();
            mdl.vertex_index= br.ReadInt32();
            mdl.tangents_index= br.ReadInt32();
            mdl.num_attachments= br.ReadInt32();
            mdl.attachment_offset= br.ReadInt32();
            mdl.num_eyeballs= br.ReadInt32();
            mdl.eyeball_offset= br.ReadInt32();
            mdl.vertex_data = new MDLModelVertexData();
            mdl.vertex_data.vertex_data_ptr = br.ReadInt32();
            mdl.vertex_data.tangent_data_ptr = br.ReadInt32();

            mdl.unused_array = new int[8]; // 8
            for (int i = 0; i < 8; i++)
            {
                mdl.unused_array[i] = br.ReadInt32();
            }

            Model model = new Model(mdl);
            if (mdl.num_meshes >1)
            {
                int test = 2;
            }
            for (int i = 0; i < mdl.num_meshes; i++)
            {
                MDLMesh mesh = ReadMesh(br, offset + mdl.mesh_offset + (i * 116)); // 88 bytes for MDLMesh

                model.Meshes.Add(mesh);
            }
            if (mdl.num_meshes > 1)
            {
                int test = 2;
            }
            return model;
        }
Пример #2
0
 public Model(MDLModel model)
 {
     this.MDLModel = model;
     Meshes = new List<MDLMesh>();
 }