-
Notifications
You must be signed in to change notification settings - Fork 7
/
glaxisarrow.cpp
executable file
·50 lines (44 loc) · 2.19 KB
/
glaxisarrow.cpp
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
#include "glaxisarrow.h"
namespace {
GLuint axisArrowIndices[] = {0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 1};
const GLfloat defaultAxisLength = 0.5;
const GLfloat defaultArrowSize = defaultAxisLength / 7;
const GLfloat defaultHalfArrowSize = defaultArrowSize / 2;
GLDrawable::GLfloat3 xyzArrowPointTable[3][5] =
{
{
{defaultAxisLength, 0, 0},
{defaultAxisLength - defaultArrowSize, defaultHalfArrowSize, defaultHalfArrowSize},
{defaultAxisLength - defaultArrowSize, -defaultHalfArrowSize, defaultHalfArrowSize},
{defaultAxisLength - defaultArrowSize, -defaultHalfArrowSize, -defaultHalfArrowSize},
{defaultAxisLength - defaultArrowSize, defaultHalfArrowSize, -defaultHalfArrowSize}
},
{
{0, defaultAxisLength, 0},
{-defaultHalfArrowSize, defaultAxisLength - defaultArrowSize, -defaultHalfArrowSize},
{defaultHalfArrowSize, defaultAxisLength - defaultArrowSize, -defaultHalfArrowSize},
{defaultHalfArrowSize, defaultAxisLength - defaultArrowSize, defaultHalfArrowSize},
{-defaultHalfArrowSize, defaultAxisLength - defaultArrowSize, defaultHalfArrowSize}
},
{
{0, 0, defaultAxisLength},
{-defaultHalfArrowSize, defaultHalfArrowSize, defaultAxisLength - defaultArrowSize},
{-defaultHalfArrowSize, -defaultHalfArrowSize, defaultAxisLength - defaultArrowSize},
{defaultHalfArrowSize, -defaultHalfArrowSize, defaultAxisLength - defaultArrowSize},
{defaultHalfArrowSize, defaultHalfArrowSize, defaultAxisLength - defaultArrowSize}
}
};
}
GLAxisArrow::GLAxisArrow(GLAxis::Axis axis)
: m_axis(axis) {
auto idxCount = sizeof(axisArrowIndices) / sizeof(axisArrowIndices[0]);
m_indices = std::vector<GLuint>(axisArrowIndices, axisArrowIndices + idxCount);
m_points = std::vector<GLfloat3>(xyzArrowPointTable[m_axis],
xyzArrowPointTable[m_axis] + 5);
}
bool GLAxisArrow::hasIndexBuffer() const {
return true;
}
GLenum GLAxisArrow::polygonType() const {
return GL_TRIANGLES;
}