-
Notifications
You must be signed in to change notification settings - Fork 9
/
cpu_motherboard.h
155 lines (137 loc) · 4.23 KB
/
cpu_motherboard.h
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef CPU_MOTHERBOARD
#define CPU_MOTHERBOARD
#include <GL/glut.h>
#include "dragHandler.h"
#include "parameter.h"
class cpu_motherboard {
private:GLfloat boardThickness = 0.025;
point3D move;
bool visible = true;
bool objMove = false;
void draw_surface();
void motionHandle();
void draw_components(GLfloat, GLfloat, GLfloat, GLfloat,int);
public:void render();
};
void cpu_motherboard::motionHandle() {
if (((enterPressed && objIndex == REMOVE_MOTHERBOARD) || objMove == true) && !assemble)
{
objMove = true;
move.x -= 0.007;
if (move.x < disapphereLimit)
{
objMove = false;
enterPressed = false;
visible = false;
}
}
else if (((enterPressed && objIndex == REMOVE_MOTHERBOARD -1) || objMove == true) && assemble)
{
objMove = true;
visible = true;
move.x += 0.007;
if (move.x >= 0.)
{
objMove = false;
enterPressed = false;
}
}
}
void cpu_motherboard::render() {
motionHandle();
if (!visible) return;
glPushMatrix();
glTranslatef(move.x, move.y, move.z);
glTranslatef(9., 3.55, -3.7);
glTranslatef(move.x-1., 1.1+move.y, move.z - .9);
glRotatef(-90., 0., 1., 0.);
glScalef(.6, .6, .7);
draw_surface();
draw_components(0., 0.7, 0.3, 0.4, MOTHERBOARD_USB);
draw_components(-.2, 0.7, 0.3, 0.2, MOTHERBOARD_USB);
draw_components(-.65, 1.1, 0.15, 0.25, MOTHERBOARD_VGA);
glPopMatrix();
}
void cpu_motherboard::draw_surface() {
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glColor3f(1., 1., 1.);
// Motherboard front
glBindTexture(GL_TEXTURE_2D, textures[MOTHERBOARD_FRONT]);
glBegin(GL_QUADS);
glTexCoord2f(0., 0.); glVertex3f(-1., -1., 0.);
glTexCoord2f(0., 1.); glVertex3f(-1., 1., 0.);
glTexCoord2f(1., 1.); glVertex3f(1., 1., 0.);
glTexCoord2f(1., 0.); glVertex3f(1., -1., 0.);
glEnd();
// Motherboard back
glBindTexture(GL_TEXTURE_2D, textures[MOTHERBOARD_BACK]);
glBegin(GL_QUADS);
glTexCoord2f(0., 0.); glVertex3f(-1., -1., -boardThickness);
glTexCoord2f(0., 1.); glVertex3f(-1., 1., -boardThickness);
glTexCoord2f(1., 1.); glVertex3f(1., 1., -boardThickness);
glTexCoord2f(1., 0.); glVertex3f(1., -1., -boardThickness);
glEnd();
glDisable(GL_TEXTURE_2D);
// Thicknes Sides (fillings)
glColor3f(0., 0.06, 0.05);
glBegin(GL_QUAD_STRIP);
glVertex3f(-1., -1., 0.); glVertex3f(-1., -1., -boardThickness);
glVertex3f(-1., 1., 0.); glVertex3f(-1., 1., -boardThickness);
glVertex3f(1., 1., 0.); glVertex3f(1., 1., -boardThickness);
glVertex3f(1., -1., 0.); glVertex3f(1., -1., -boardThickness);
glVertex3f(-1., -1., 0.); glVertex3f(-1., -1., -boardThickness);
glEnd();
glPopMatrix();
}
void cpu_motherboard::draw_components(GLfloat xCord, GLfloat scaleX, GLfloat scaleY, GLfloat scaleZ, int id) {
glPushMatrix();
glRotatef(-90., 0., 1., 0.);
glRotatef(-90., 0., 0., 1.);
glTranslatef(xCord, 0., 1.);
glScalef(scaleX, scaleY, scaleZ);
glColor3f(1., 1., 1.);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[id]);
glBegin(GL_POLYGON);
glTexCoord2f(0., 0.);
glVertex3f(0., 0., .001);
glTexCoord2f(0., 1.);
glVertex3f(0., .4, .001);
glTexCoord2f(1., 1.);
glVertex3f(.2, .4, .001);
glTexCoord2f(1., 0.);
glVertex3f(.2, 0., .001);
glEnd();
glBindTexture(GL_TEXTURE_2D, textures[STEEL_FINISH]);
glColor3f(1., 1., 1.);
glRotatef(90., 0., 1., 0.);
glTranslatef(0., 0., .2);
glBegin(GL_QUAD_STRIP);
glTexCoord2f(0., 0.); glVertex3f(0., 0., 0.);
glTexCoord2f(0., 1.); glVertex3f(0., .4, 0.);
glTexCoord2f(1., 0.); glVertex3f(.6, 0., 0.);
glTexCoord2f(1., 1.); glVertex3f(.6, .4, 0.);
glTexCoord2f(1., 0.); glVertex3f(.6, 0., -.2);
glTexCoord2f(1., 1.); glVertex3f(.6, .4, -.2);
glTexCoord2f(0., 0.); glVertex3f(.0, .0, -.2);
glTexCoord2f(0., 1.); glVertex3f(.0, .4, -.2);
glTexCoord2f(0., 0.); glVertex3f(.0, .0, 0.);
glTexCoord2f(0., 1.); glVertex3f(.0, .4, 0.);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0., 0., 0.);
glVertex3f(.6, .0, 0.);
glVertex3f(.6, .0, -.2);
glVertex3f(.0, 0., -.2);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(0., .4, 0.);
glVertex3f(.6, .4, 0.);
glVertex3f(.6, .4, -.2);
glVertex3f(.0, .4, -.2);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
#endif CPU_MOTHERBOARD