| 289 | } |
| 290 | |
| 291 | void LoadModel_car( const Vfs::FileContent& model_file, Model& out_model ) |
| 292 | { |
| 293 | ClearModel( out_model ); |
| 294 | |
| 295 | const unsigned int c_textures_offset= 0x486Cu; |
| 296 | |
| 297 | unsigned short vertex_count; |
| 298 | unsigned short polygon_count; |
| 299 | unsigned short texture_texels; |
| 300 | std::memcpy( &vertex_count, model_file.data() + 0x4866u, sizeof(unsigned short) ); |
| 301 | std::memcpy( &polygon_count, model_file.data() + 0x4868u, sizeof(unsigned short) ); |
| 302 | std::memcpy( &texture_texels, model_file.data() + 0x486Au, sizeof(unsigned short) ); |
| 303 | |
| 304 | out_model.texture_size[0u]= g_car_model_texture_width; |
| 305 | out_model.texture_size[1u]= texture_texels / g_car_model_texture_width; |
| 306 | |
| 307 | out_model.texture_data.resize( texture_texels ); |
| 308 | std::memcpy( |
| 309 | out_model.texture_data.data(), |
| 310 | model_file.data() + c_textures_offset, |
| 311 | texture_texels ); |
| 312 | |
| 313 | const CARHeader* const header= reinterpret_cast<const CARHeader*>( model_file.data() ); |
| 314 | |
| 315 | out_model.frame_count= 0u; |
| 316 | for( unsigned int i= 0u; i < 20u; i++ ) |
| 317 | { |
| 318 | const unsigned int animation_frame_count= header->animations[i] / ( sizeof(Vertex_o3) * vertex_count ); |
| 319 | if( animation_frame_count == 0u ) continue; |
| 320 | |
| 321 | out_model.animations.emplace_back(); |
| 322 | Model::Animation& anim= out_model.animations.back(); |
| 323 | |
| 324 | anim.id= i; |
| 325 | anim.first_frame= out_model.frame_count; |
| 326 | anim.frame_count= animation_frame_count; |
| 327 | |
| 328 | out_model.frame_count+= animation_frame_count; |
| 329 | } |
| 330 | |
| 331 | const auto prepare_model= |
| 332 | [&out_model]( |
| 333 | const unsigned int vertex_count, const unsigned int polygon_count, |
| 334 | const Vertex_o3* const vertices, const Polygon_o3* const polygons, |
| 335 | Submodel& out_submodel ) |
| 336 | { |
| 337 | out_submodel.animations_vertices.resize( out_submodel.frame_count * vertex_count ); |
| 338 | for( unsigned int v= 0u; v < out_submodel.animations_vertices.size(); v++ ) |
| 339 | { |
| 340 | for( unsigned int j= 0u; j < 3; j++ ) |
| 341 | out_submodel.animations_vertices[v].pos[j]= vertices[v].xyz[j]; |
| 342 | } |
| 343 | |
| 344 | unsigned int current_vertex_index= 0u; |
| 345 | |
| 346 | for( unsigned int p= 0u; p < polygon_count; p++ ) |
| 347 | { |
| 348 | const Polygon_o3& polygon= polygons[p]; |
no test coverage detected