Advertisement
illwieckz

first mesh last texture

Jan 31st, 2018
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.99 KB | None | 0 0
  1. diff --git a/plugins/iqmmodel/iqm.cpp b/plugins/iqmmodel/iqm.cpp
  2. index 96883c68..61c82f60 100644
  3. --- a/plugins/iqmmodel/iqm.cpp
  4. +++ b/plugins/iqmmodel/iqm.cpp
  5. @@ -141,6 +141,23 @@ void istream_read_iqmHeader(PointerInputStream &inputStream, iqmHeader_t &header
  6.  #undef READINT
  7.  }
  8.  
  9. +typedef struct iqmmesh_s {
  10. +    unsigned int name;
  11. +    unsigned int material;
  12. +    unsigned int first_vertex, num_vertexes;
  13. +       unsigned int first_triangle, num_triangles;
  14. +} iqmmesh_t;
  15. +
  16. +void istream_read_iqmMesh(PointerInputStream &inputStream, iqmmesh_t &iqmmesh)
  17. +{
  18. +    iqmmesh.name = istream_read_uint32_le(inputStream);
  19. +    iqmmesh.material = istream_read_uint32_le(inputStream);
  20. +    iqmmesh.first_vertex = istream_read_uint32_le(inputStream);
  21. +    iqmmesh.num_vertexes = istream_read_uint32_le(inputStream);
  22. +    iqmmesh.first_triangle = istream_read_uint32_le(inputStream);
  23. +    iqmmesh.num_triangles = istream_read_uint32_le(inputStream);
  24. +}
  25. +
  26.  typedef struct iqmvertexarray_s {
  27.      unsigned int type;
  28.      unsigned int flags;
  29. @@ -243,7 +260,25 @@ void IQMSurface_read(Model &model, const byte *buffer, ArchiveFile &file)
  30.          }
  31.      }
  32.  
  33. -    surface.setShader("");
  34. +       bool found = false;
  35. +       PointerInputStream iqmMesh(buffer + header.ofs_meshes);
  36. +       for ( unsigned int i = 0; i < header.num_meshes; i++ ) {
  37. +               iqmmesh_t iqmmesh;
  38. +               istream_read_iqmMesh(iqmMesh, iqmmesh);
  39. +               if ( iqmmesh.material <= header.num_text ) {
  40. +                       char *text;
  41. +                       text = (char*) buffer + header.ofs_text + iqmmesh.material;
  42. +                       printf("ll: %s\n", text);
  43. +                       if ( text[0] != '\0' ) {
  44. +                               surface.setShader(text);
  45. +                               found = true;
  46. +                       }
  47. +               }
  48. +       }
  49. +       if ( !found ) {
  50. +               surface.setShader("textures/radiant/notex");
  51. +       }
  52. +
  53.      surface.updateAABB();
  54.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement