mesh.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef _MESH_
  2. #define _MESH_
  3. #include <vector>
  4. #include <GL/glut.h>
  5. #include "vec3.h"
  6. #include "matrix.h"
  7. /* Creates a mesh that consists of:
  8. * a vector array for vertices,
  9. * a vector array for colors,
  10. * a vector for locations and
  11. * a vector for bound.
  12. */
  13. class Mesh
  14. {
  15. public:
  16. //Lifecycle
  17. bool load(const char *path, char mirror=0);
  18. virtual void draw();
  19. //Location and Bound box
  20. vec3 loc, bound;
  21. void add(Mesh);
  22. //protected:
  23. //Vertices and colors
  24. std::vector<vec3> v, c;
  25. };
  26. /* This is my experiment for a better mesh
  27. * Creates a mesh which has vertices and colors.
  28. */
  29. class Mesh2
  30. {
  31. private:
  32. //Buffer object
  33. GLuint vbo;
  34. //Vertices
  35. int vcount;
  36. float *vertices;
  37. float *colors;
  38. public:
  39. //Constructor - Destructor
  40. Mesh2();
  41. ~Mesh2();
  42. //Vertex count
  43. void set_vertex_count(int vcount);
  44. int get_vertex_count() const { return vcount; };
  45. //Getters to mesh data
  46. float *get_vertex_array() const { return vertices; };
  47. float *get_colors_array() const { return colors ; };
  48. //Load from file
  49. bool load(const char *path, char mirror=0);
  50. //Draw
  51. virtual void draw() const;
  52. //Bound (STILL WORKING ON THIS)
  53. vec3 pbound, nbound;
  54. };
  55. #endif