Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RoomMesh.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*!
  2. * \file include/RoomMesh.h
  3. * \brief World Room Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _ROOM_MESH_H_
  8. #define _ROOM_MESH_H_
  9. #include <cstdint>
  10. #include <vector>
  11. #include <glm/mat4x4.hpp>
  12. #include <glm/vec2.hpp>
  13. #include <glm/vec3.hpp>
  14. struct RoomVertexTR2 {
  15. int16_t x, y, z; // Vertex coordinates, relative to x/zOffset
  16. int16_t light1, light2; // Almost always equal
  17. // Set of flags for special rendering effects
  18. // 0x8000 - Something to do with water surface?
  19. // 0x4000 - Underwater lighting modulation/movement if seen from above
  20. // 0x2000 - Water/Quicksand surface movement
  21. // 0x0010 - Normal?
  22. uint16_t attributes;
  23. };
  24. struct IndexedRectangle {
  25. unsigned int v1, v2, v3, v4; // Vertex list indices
  26. unsigned int texture; // Index into object-texture list
  27. IndexedRectangle(uint16_t t, uint16_t _v1, uint16_t _v2, uint16_t _v3, uint16_t _v4 = 0)
  28. : v1(_v1), v2(_v2), v3(_v3), v4(_v4), texture(t) { }
  29. };
  30. class RoomMesh {
  31. public:
  32. RoomMesh(const std::vector<RoomVertexTR2>& vertices,
  33. const std::vector<IndexedRectangle>& rectangles,
  34. const std::vector<IndexedRectangle>& triangles);
  35. void prepare();
  36. void display(glm::mat4 model, glm::mat4 view, glm::mat4 projection);
  37. private:
  38. std::vector<unsigned short> indices;
  39. std::vector<glm::vec3> vertices;
  40. std::vector<glm::vec2> uvs;
  41. std::vector<unsigned int> textures;
  42. };
  43. #endif