123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef MESH_H
- #define MESH_H
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- class Mesh
- {
- public:
- Mesh(int mode);
- virtual ~Mesh();
-
- void addPosition(float x, float y, float z);
- void addColor(float r, float g, float b, float a);
- void addTexture(float tx, float ty);
- void addNormal(float nx, float ny, float nz);
-
- void build(bool print = false);
- void draw();
- void draw(unsigned int start, unsigned int count);
-
- static const int COLOR = 1;
- static const int TEXTURE = 2;
- static const int NORMAL = 4;
- private:
- void ensureCapacity(unsigned int index);
-
- GLuint vba = 0;
- GLuint vbo = 0;
-
- unsigned int positionStartIndex = 0;
- unsigned int colorStartIndex = 0;
- unsigned int textureStartIndex = 0;
- unsigned int normalStartIndex = 0;
-
- unsigned int positionIndex = 0;
- unsigned int colorIndex = 0;
- unsigned int textureIndex = 0;
- unsigned int normalIndex = 0;
-
- unsigned int vertexSize = 0;
- unsigned int vertices = 0;
- unsigned int dataSize = 3;
-
- float* data = nullptr;
- };
- class NormalTextureMesh : public Mesh
- {
- public:
- NormalTextureMesh();
-
- void addTriangle(float p1x, float p1y, float p1z, float p1nx, float p1ny, float p1nz, float p1texX, float p1texY,
- float p2x, float p2y, float p2z, float p2nx, float p2ny, float p2nz, float p2texX, float p2texY,
- float p3x, float p3y, float p3z, float p3nx, float p3ny, float p3nz, float p3texX, float p3texY);
- void addCuboid(float sx, float sy, float sz, float ex, float ey, float ez,
- float topTexStartX, float topTexStartY, float topTexEndX, float topTexEndY,
- float bottomTexStartX, float bottomTexStartY, float bottomTexEndX, float bottomTexEndY,
- float northTexStartX, float northTexStartY, float northTexEndX, float northTexEndY,
- float southTexStartX, float southTexStartY, float southTexEndX, float southTexEndY,
- float eastTexStartX, float eastTexStartY, float eastTexEndX, float eastTexEndY,
- float westTexStartX, float westTexStartY, float westTexEndX, float westTexEndY);
- };
- #endif
|