-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.h
70 lines (52 loc) · 1.65 KB
/
Mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef MESH_H
#define MESH_H
#include <QVector>
#include <QColor>
#include "Node.h"
#include "Material.h"
class QGLBuffer;
class Mesh : public Node
{
public:
enum DrawMode{
Fill,
Line
};
Mesh(Node* parent);
virtual ~Mesh();
virtual void init();
virtual void draw();
void setVertices(const QVector<float>& vertices);
const QVector<float> vertices() const;
float vertex(int i) const;
void setNormals(const QVector<float>& normals);
const QVector<float> normals() const;
float normal(int i) const;
void setTexCoords(const QVector<float>& texCoords);
const QVector<float> texCoords() const;
float texCoord(int i) const;
QGLBuffer* GLVertices() const;
void setFaces(const QVector<int>& faces);
const QVector<int> faces() const;
int face(int i) const;
QGLBuffer* GLFaces() const;
void setDrawMode(DrawMode mode);
DrawMode drawMode() const;
bool isWireFrame() const;
Material* material() const;
float intersects(QVector3D const& pos, QVector3D const& direction) const;
protected:
float _triangleIntersection(QVector3D const& pos, QVector3D const& direction, QVector3D const& p0, QVector3D const& p1, QVector3D const& p2) const;
void _updateVerticesNormalsBuffer();
QVector<float> _vertices;
QVector<float> _normals;
QVector<float> _texCoords;
QVector<float> _buffer;
QGLBuffer* _GLVertices;
QVector<int> _faces;
QGLBuffer* _GLFaces;
DrawMode _drawMode;
bool _isWireFrame;
Material* _material;
};
#endif // MESH_H