-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminicube.cpp
More file actions
75 lines (60 loc) · 1.53 KB
/
Copy pathminicube.cpp
File metadata and controls
75 lines (60 loc) · 1.53 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
#include <minicube.h>
// Constructor
Minicube::Minicube (Object *parent) : Cube()
{
// Se usa proyeccion ortogonal
ortho = true;
// Posicion, escala y rotacion
offset = glm::vec2((GLfloat) Object::win_h * 0.080F);
scale_1 = glm::vec3((GLfloat) Object::win_h * 0.075F);
rot_ref = parent->rotPointer();
// Crea cada calcomania con las texturas
for (GLubyte i = 0; i < 6; i++)
{
const Sticker::FACE dir = (Sticker::FACE) i;
sticker_texture[dir] = new Texture(path + "/minicube_" + std::string(1, i + '0') + ".png");
sticker[dir]->side = dir;
sticker[dir]->diffuse = glm::vec4(1.0F);
sticker[dir]->texture_sd = sticker_texture[i];
}
// Debe dibujarse
drawable = true;
}
// Asigna la informacion de la pantalla
void Minicube::updatePosition ()
{
// Actualiza valores
offset = glm::vec2((GLfloat) Object::win_h * 0.080F);
scale_1 = glm::vec3((GLfloat) Object::win_h * 0.075F);
// Reubicacion
pos_1.x = (GLfloat) win_w - offset.x;
pos_1.y = offset.y;
}
void Minicube::draw() const
{
// Respaldo la matriz actual
glPushMatrix();
glLoadIdentity();
// Transformaciones
glTranslatef(pos_1.x, pos_1.y, pos_1.z);
glMultMatrixf(glm::value_ptr(glm::mat4_cast(*rot_ref)));
glScalef(scale_1.x, scale_1.y, scale_1.z);
// Dibujar caras
for (GLubyte i = 0; i < 6; i++)
{
sticker[i]->draw();
}
// Carga material y dibujar objeto
loadMaterial();
Cube::cube_sd->draw();
// Regresa a la matriz anterior
glPopMatrix();
}
// Destructor
Minicube::~Minicube()
{
for (GLubyte i = 0; i < 6; i++)
{
delete sticker_texture[i];
}
}