mesh.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef MESH_H
  2. #define MESH_H
  3. // ===============================
  4. // AUTHOR : Angel Ortiz (angelo12 AT vt DOT edu)
  5. // CREATE DATE : 2018-07-03
  6. // PURPOSE : Container for all geometry information related to vertices and
  7. // faces. This information is what the renderer uses to build triangles.
  8. // ===============================
  9. // SPECIAL NOTES: Once again, this class uses a bunch of vectors instead of arrays and
  10. // it's something I would change if I had more time.
  11. // ===============================
  12. //Headers
  13. #include "vector3D.h"
  14. #include <vector>
  15. //Struct containing information relevant to the renderer about the vertices, normals and
  16. //texture coordinates of a model. Also keeps track of useful stuff for iterating.
  17. struct Mesh{
  18. //Per vertex values
  19. int numVertices = 0;
  20. std::vector<Vector3f> vertices;
  21. std::vector<Vector3f> normals;
  22. std::vector<Vector3f> texels;
  23. std::vector<Vector3f> tangents;
  24. std::vector<Vector3f> biTangents;
  25. //Per face values
  26. int numFaces = 0;
  27. std::vector<Vector3f> fNormals; //Normals for the whole face
  28. std::vector<Vector3i> vertexIndices;
  29. std::vector<Vector3i> textureIndices;
  30. std::vector<Vector3i> normalsIndices;
  31. //Simple mesh description for debugging.
  32. void describeMesh();
  33. //Builds facet normals used in early back face culling
  34. void buildFacetNormals();
  35. //Builds tangent and bitangent vectors for normal mapping
  36. void buildTangentSpace();
  37. };
  38. #endif