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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef HMPLANE_H
#define HMPLANE_H
#include <vector>
#include "glm/gtc/matrix_transform.hpp"
#include <wx/geometry.h>
class VertexBuffer;
class IndexBuffer;
class VertexBufferLayout;
class VertexArray;
class OpenGLUtils;
class Shader;
class Renderer;
class OpenGLText;
struct BufferMeshCoords
{
float x = 0.0;
float y = 0.0;
float z = 0.0;
};
class HMPlane
{
public:
HMPlane(Shader* shader, Shader* labelShader, const float& width, const float& height, const float limits[2]);
virtual ~HMPlane();
virtual void Draw(const Renderer& renderer, const glm::mat4& projectionViewMatrix) const;
virtual void DrawLabel(const Renderer& renderer, const glm::mat4& projectionViewMatrix, const float& x = 0.0, const float& y = 0.0) const;
virtual void SetLabelLimits(const float& min, const float& max);
virtual float GetMaxLimit() { return m_limits[0]; }
virtual float GetMinLimit() { return m_limits[1]; }
virtual void SetRectSlope(const wxRect2DDouble& rect, const float& angle, const float& depth);
virtual void UpdateCoords() { FillIndexBuffer(); }
virtual void Resize(const float& width, const float& height);
virtual void SmoothPlane(const unsigned int& iterations);
virtual void Clear();
protected:
void FillCoordsBuffer();
void FillIndexBuffer();
void BindOpenGLBuffers();
void CreateLabel();
const float m_meshSize = 15.0f;
unsigned int m_meshTickX = 0;
unsigned int m_meshTickY = 0;
float m_width = 0.0;
float m_height = 0.0;
std::vector< std::vector<BufferMeshCoords*> > m_coords;
std::vector<float> m_bufferCoords;
std::vector<unsigned int> m_indexBuffer;
// OpenGL shader
Shader* m_shader = nullptr;
Shader* m_labelShader = nullptr;
// Buffers
VertexBuffer* m_vb = nullptr;
VertexBufferLayout* m_layout = nullptr;
IndexBuffer* m_ib = nullptr;
VertexArray* m_va = nullptr;
// Label
float m_vertexBufferLabel[4 * 3];
unsigned int m_indexBufferLabel[6];
VertexBuffer* m_vbL = nullptr;
VertexBufferLayout* m_layoutL = nullptr;
IndexBuffer* m_ibL = nullptr;
VertexArray* m_vaL = nullptr;
std::vector<OpenGLText*> m_glTexts;
float m_limits[2] = {1.1, 0.9};
bool m_isClear = true;
};
#endif
|