-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathglplanemesh.cpp
More file actions
executable file
·39 lines (30 loc) · 999 Bytes
/
glplanemesh.cpp
File metadata and controls
executable file
·39 lines (30 loc) · 999 Bytes
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
#include "glplanemesh.h"
GLPlaneMesh::GLPlaneMesh(GLfloat maxRange, GLPlaneMesh::Plane plane)
: GLDrawable(), m_xInterval(1), m_yInterval(1), m_zInterval(1),
m_maxRange(maxRange), m_plane(plane) {
setMaxRange(m_maxRange);
setupMesh();
}
void GLPlaneMesh::setMaxRange(GLfloat maxRange)
{
m_maxRange = static_cast<int>(maxRange + 0.5f);
setupMesh();
}
GLenum GLPlaneMesh::polygonType() const
{
return GL_LINES;
}
void GLPlaneMesh::setupMesh()
{
m_points.clear();
if (m_plane == PlaneXY) {
for (GLfloat x = -m_maxRange; x <= m_maxRange; x += m_xInterval) {
m_points.push_back(GLfloat3({x, -m_maxRange, 0}));
m_points.push_back(GLfloat3({x, m_maxRange, 0}));
}
for (GLfloat y = -m_maxRange; y <= m_maxRange; y += m_yInterval) {
m_points.push_back(GLfloat3({-m_maxRange, y, 0}));
m_points.push_back(GLfloat3({m_maxRange, y, 0}));
}
}
}