-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRefinery.cpp
More file actions
140 lines (110 loc) · 3.3 KB
/
Copy pathRefinery.cpp
File metadata and controls
140 lines (110 loc) · 3.3 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "Refinery.h"
/**
* Refinery adapted from my first whisk assignment. May be too much for an older PC to run so choose 'n' on startup if it crashes.
*/
Refinery::Refinery(void) {
}
Refinery::~Refinery(void) {
}
/**
* Initialise by loading textures etc.
*/
void Refinery::Init(void) {
//load textures
RawLoader rawLoader;
Shapes shapes;
rustTexture = rawLoader.LoadTextureRAW("rusttexture.raw", 1, 600, 600);
angle = 0;
GLfloat pos[4] = {5.0f, 5.0f, 10.0f, 0.0f};
GLfloat whiteplastic[4] = {0.92f, 0.92f, 0.92f, 1.0f};
GLfloat whiskcolor[4] = {0.74f, 0.74f, 0.74f, 1.0f};
GLfloat handlecolor[4] = {0.2f, 0.2f, 0.2f, 1.0f};
GLfloat specReflection[4] = { 0.8f, 0.8f, 0.8f, 1.0f};
GLfloat handlespecular[4] = { 0.0f, 0.0f, 0.0f, 1.0f};
GLfloat specular[4] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat ambient[4] = {0.1f, 0.1f, 0.1f, 1.0f};
GLfloat diffuse[4] = {0.8f, 0.8f, 0.8f, 1.0f};
quadric = gluNewQuadric();
gluQuadricNormals(quadric, GL_TRUE);
/* whisk */
whisk = glGenLists(1);
glNewList(whisk, GL_COMPILE);
glPushMatrix();
glTranslatef(0, 0, 4.0f); // move down to the gear
shapes.cylinder(30.0, 1.0, 1.0, 10, 10, quadric); // thick cyclinder spacer
glTranslatef(0, 0, 30.0f);
shapes.cylinder(5.0, 3.0, 4.0, 20, 1, quadric);
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
for (int counter = 0; counter < 4; counter++) {
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
glPushMatrix();
glTranslatef(4.3f, 16.5f, 0.0f);
glRotatef(-5.0f, 0.0f, 0.0f, 1.0f);
shapes.cuboid(1.0f, 24.0f, 2.0f);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1f, 30.0f, 0.0f);
glRotatef(50.0f, 0.0f, 0.0f, 1.0f);
shapes.cuboid(1.0f, 6.6f, 2.0f);
glPopMatrix();
}
glPopMatrix();
glEndList();
}
void Refinery::Display(void) {
Shapes shapes;
angle += 0.40;
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, rustTexture); // bind the texture
glTranslatef(440.0f, 200.0f, 550.0f);
glPushMatrix();
glTranslatef(0.0f, 17.0f, 5.0f);
glRotatef((GLfloat)angle, 0.0f, 0.0f, 1.0f);
shapes.cylinder(190.0f, 1.6, 1.6, 8, 1, quadric);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0f, -50.0f, 6.0f);
shapes.cuboid(8.0f, 180.0f, 8.0f);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0f, 17.0f, 192.0f);
shapes.cuboid(12.0f, 14.0f, 18.0f);
glPopMatrix();
for (int i = 0; i < 5; i++) {
glTranslatef(0, 0, 25.0f);
// white plastic gears and whisks
glPushMatrix();
glTranslatef(0.0f, 0.0f, -5.0f);
shapes.drawWhisk(0, angle, smallgear, whisk, quadric);
glTranslatef(0.0f, 0.0f, 10.0f);
glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
shapes.drawWhisk(1, angle, smallgear, whisk, quadric);
glPopMatrix();
// bottom strut
glPushMatrix();
glTranslatef(0.0f, -61.5f, -5.0f);
shapes.cylinder(10.0, 0.5, 0.5, 5, 1, quadric);
glPopMatrix();
// big metal gear plus handle
glPushMatrix();
glTranslatef(0.0f, 17.0f, 0.0f);
glRotated(angle / 3.75, 0.0, 0.0, 1.0);
shapes.gear(11.0f, 15.0f, 3.0f, 50.0f, 2.0f);
//glCallList(innergearsupport);
shapes.innergearsupports();
glPopMatrix();
// side struts
glPushMatrix();
glTranslatef(0.0f, 20.0f, 5.0f);
shapes.cuboid(5.0f, 30.0f, 1.0f);
glTranslatef(0.0f, 0.0f, -10.0f);
shapes.cuboid(5.0f, 30.0f, 1.0f);
glPopMatrix();
// top joining struts
glPushMatrix();
glTranslatef(0.0f, 35.0f, 0.0f);
shapes.cuboid(5.0f, 1.0f, 12.0f);
glPopMatrix();
}
glPopMatrix();
}