| 620 | } |
| 621 | |
| 622 | std::vector<Entity> NFS3::ParseCOLModels(const std::shared_ptr<TRACK> &track) { |
| 623 | LOG(INFO) << "Parsing COL file into ONFS GL structures"; |
| 624 | |
| 625 | std::vector<Entity> col_entities; |
| 626 | glm::quat rotationMatrix = glm::normalize(glm::quat(glm::vec3(-SIMD_PI/2,0,0))); // All Vertices are stored so that the model is rotated 90 degs on X. Remove this at Vert load time. |
| 627 | |
| 628 | COLOBJECT *o = track->col.object; |
| 629 | /* COL DATA - TODO: Come back for VROAD AI/Collision data */ |
| 630 | for (uint32_t i = 0; i < track->col.objectHead.nrec; i++, o++) { |
| 631 | COLSTRUCT3D s = track->col.struct3D[o->struct3D]; |
| 632 | std::vector<unsigned int> indices; |
| 633 | std::vector<glm::vec2> uvs; |
| 634 | std::vector<unsigned int> texture_indices; |
| 635 | std::vector<glm::vec3> verts; |
| 636 | std::vector<glm::vec4> shading_data; |
| 637 | std::vector<glm::vec3> norms; |
| 638 | for (uint32_t j = 0; j < s.nVert; j++, s.vertex++) { |
| 639 | verts.emplace_back(rotationMatrix * glm::vec3(s.vertex->pt.x / 10, s.vertex->pt.y / 10, s.vertex->pt.z / 10)); |
| 640 | shading_data.emplace_back(glm::vec4(1.0, 1.0f, 1.0f, 1.0f)); |
| 641 | } |
| 642 | for (uint32_t k = 0; k < s.nPoly; k++, s.polygon++) { |
| 643 | // Remap the COL TextureID's using the COL texture block (XBID2) |
| 644 | COLTEXTUREINFO col_texture = track->col.texture[s.polygon->texture]; |
| 645 | TEXTUREBLOCK texture_for_block; |
| 646 | // Find the texture by it's file name, but use the Texture table to get the block. TODO: Not mapping this so, must do a manual search. |
| 647 | for (uint32_t t = 0; t < track->nTextures; t++) { |
| 648 | if (track->texture[t].texture == col_texture.texture) { |
| 649 | texture_for_block = track->texture[t]; |
| 650 | } |
| 651 | } |
| 652 | Texture gl_texture = track->textures[texture_for_block.texture]; |
| 653 | indices.emplace_back(s.polygon->v[0]); |
| 654 | indices.emplace_back(s.polygon->v[1]); |
| 655 | indices.emplace_back(s.polygon->v[2]); |
| 656 | indices.emplace_back(s.polygon->v[0]); |
| 657 | indices.emplace_back(s.polygon->v[2]); |
| 658 | indices.emplace_back(s.polygon->v[3]); |
| 659 | |
| 660 | glm::vec3 normal = rotationMatrix * calculateQuadNormal( pointToVec(verts[s.polygon->v[0]]), pointToVec(verts[s.polygon->v[1]]), pointToVec(verts[s.polygon->v[2]]), pointToVec(verts[s.polygon->v[3]])); |
| 661 | norms.emplace_back(normal); |
| 662 | norms.emplace_back(normal); |
| 663 | norms.emplace_back(normal); |
| 664 | norms.emplace_back(normal); |
| 665 | norms.emplace_back(normal); |
| 666 | norms.emplace_back(normal); |
| 667 | |
| 668 | uvs.emplace_back(texture_for_block.corners[0] * gl_texture.max_u, (1.0f - texture_for_block.corners[1]) * gl_texture.max_v); |
| 669 | uvs.emplace_back(texture_for_block.corners[2] * gl_texture.max_u, (1.0f - texture_for_block.corners[3]) * gl_texture.max_v); |
| 670 | uvs.emplace_back(texture_for_block.corners[4] * gl_texture.max_u, (1.0f - texture_for_block.corners[5]) * gl_texture.max_v); |
| 671 | uvs.emplace_back(texture_for_block.corners[0] * gl_texture.max_u, (1.0f - texture_for_block.corners[1]) * gl_texture.max_v); |
| 672 | uvs.emplace_back(texture_for_block.corners[4] * gl_texture.max_u, (1.0f - texture_for_block.corners[5]) * gl_texture.max_v); |
| 673 | uvs.emplace_back(texture_for_block.corners[6] * gl_texture.max_u, (1.0f - texture_for_block.corners[7]) * gl_texture.max_v); |
| 674 | texture_indices.emplace_back(texture_for_block.texture); |
| 675 | texture_indices.emplace_back(texture_for_block.texture); |
| 676 | texture_indices.emplace_back(texture_for_block.texture); |
| 677 | texture_indices.emplace_back(texture_for_block.texture); |
| 678 | texture_indices.emplace_back(texture_for_block.texture); |
| 679 | texture_indices.emplace_back(texture_for_block.texture); |
nothing calls this directly
no test coverage detected