-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyramid_gl.cpp
83 lines (66 loc) · 2.46 KB
/
pyramid_gl.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
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
#include "pyramid_gl.h"
#include "object_gl.h"
#include "quad_gl.h"
#include "triangle_gl.h"
PyramidGL::PyramidGL() : ObjectGL()
{
GLfloat size = 1.f;
this->FaceMode = GL_LINE;
this->q1 = new QuadGL();
this->q1->setColor(this->color[0], this->color[1], this->color[2]);
this->q1->frontFaceMode = this->FaceMode;
this->q1->backFaceMode = this->FaceMode;
this->q1->translate(0.f, -sqrt(3) * size / 6.f, 0.f);
this->q1->rotate(90.0f, 1.f, 0.f, 0.f);
this->t1 = new TriangleGL();
this->t1->setColor(this->color[0], this->color[1], this->color[2]);
this->t1->frontFaceMode = this->FaceMode;
this->t1->backFaceMode = this->FaceMode;
this->t1->translate(0.0f, -0.052f, size/2.f - 0.17f);
this->t1->rotate(-35.0f, 1.f, 0.f, 0.f);
this->t2 = new TriangleGL();
this->t2->setColor(this->color[0], this->color[1], this->color[2]);
this->t2->frontFaceMode = this->FaceMode;
this->t2->backFaceMode = this->FaceMode;
this->t2->translate(0.0f, -0.052f, -(size / 2.f - 0.17f));
this->t2->rotate(35.0f, 1.f, 0.f, 0.f);
this->t2->rotate(-180.0f, 0.f, 1.f, 0.f);
this->t3 = new TriangleGL();
this->t3->setColor(this->color[0], this->color[1], this->color[2]);
this->t3->frontFaceMode = this->FaceMode;
this->t3->backFaceMode = this->FaceMode;
this->t3->translate(-(size / 2.f - 0.17f), -0.052f, 0.0f);
this->t3->rotate(-90.0f, 0.f, 1.f, 0.f);
this->t3->rotate(-35.0f, 1.f, 0.f, 0.f);
this->t4 = new TriangleGL();
this->t4->setColor(this->color[0], this->color[1], this->color[2]);
this->t4->frontFaceMode = this->FaceMode;
this->t4->backFaceMode = this->FaceMode;
this->t4->translate(size / 2.f - 0.17f, -0.052f, 0.0f);
this->t4->rotate(90.0f, 0.f, 1.f, 0.f);
this->t4->rotate(-35.0f, 1.f, 0.f, 0.f);
}
PyramidGL::~PyramidGL()
{
}
void PyramidGL::render()
{
glPolygonMode(GL_FRONT, this->FaceMode);
glPolygonMode(GL_BACK, this->FaceMode);
//glPolygonMode(GL_BACK, GL_FILL);
//glColor3f(this->color[0], this->color[1], this->color[2]);
glPushMatrix();
GLfloat *ptrM = glm::value_ptr(this->m);
glMultMatrixf(ptrM);
this->q1->setColor(this->color[0], this->color[1], this->color[2]);
this->q1->render();
this->t1->setColor(this->color[0], this->color[1], this->color[2]);
this->t1->render();
this->t2->setColor(this->color[0], this->color[1], this->color[2]);
this->t2->render();
this->t3->setColor(this->color[0], this->color[1], this->color[2]);
this->t3->render();
this->t4->setColor(this->color[0], this->color[1], this->color[2]);
this->t4->render();
glPopMatrix();
}