Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. * \file include/Mesh.h
  3. * \brief Textured/Colored Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _MESH_H_
  8. #define _MESH_H_
  9. #include <vector>
  10. #include "system/Shader.h"
  11. struct IndexedRectangle {
  12. unsigned int v1, v2, v3, v4; // Vertex list indices
  13. unsigned int texture; // Index into object-texture list
  14. IndexedRectangle(unsigned int t, unsigned int _v1,
  15. unsigned int _v2, unsigned int _v3, unsigned int _v4 = 0)
  16. : v1(_v1), v2(_v2), v3(_v3), v4(_v4), texture(t) { }
  17. };
  18. struct IndexedColoredRectangle {
  19. unsigned int v1, v2, v3, v4, index;
  20. IndexedColoredRectangle(unsigned int paletteIndex,
  21. unsigned int _v1, unsigned int _v2,
  22. unsigned int _v3, unsigned int _v4 = 0)
  23. : v1(_v1), v2(_v2), v3(_v3), v4(_v4), index(paletteIndex) { }
  24. };
  25. // --------------------------------------
  26. class Mesh {
  27. public:
  28. Mesh(const std::vector<glm::vec3>& vertices,
  29. const std::vector<IndexedRectangle>& rectangles,
  30. const std::vector<IndexedRectangle>& triangles,
  31. const std::vector<IndexedColoredRectangle>& coloredRectangles,
  32. const std::vector<IndexedColoredRectangle>& coloredTriangles);
  33. void prepare();
  34. void display(glm::mat4 MVP, ShaderTexture* shaderTexture = nullptr);
  35. private:
  36. std::vector<unsigned short> indicesBuff;
  37. std::vector<glm::vec3> verticesBuff;
  38. std::vector<glm::vec2> uvsBuff;
  39. std::vector<unsigned int> texturesBuff;
  40. std::vector<unsigned short> indicesColorBuff;
  41. std::vector<glm::vec3> verticesColorBuff;
  42. std::vector<glm::vec3> colorsBuff;
  43. std::vector<unsigned int> colorsIndexBuff;
  44. };
  45. #endif