-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.cpp
More file actions
61 lines (50 loc) · 1.14 KB
/
cube.cpp
File metadata and controls
61 lines (50 loc) · 1.14 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
#include "cube.h"
cube::cube(float _w, float _h, float _d, float _cubeHue)
{
w = _w;
h = _h;
d = _d;
cubeHue = _cubeHue;
GLfloat vdata[8][3] = {
{-w, -h, -d}, {-w, h, -d},
{w, h, -d}, {w, -h, -d},
{-w, -h, d}, {w, -h, d},
{-w, h, d}, {w, h, d}
};
GLint indices[6][4] = {
{3, 2, 1, 0},
{3, 5, 4, 0},
{3, 5, 7, 2},
{0, 4, 6, 1},
{1, 2, 7, 6},
{5, 4, 6, 7}
};
cubeColor = ofColor();
cubeColor.setHsb(cubeHue,ofRandom(500,255),ofRandom(100,255), 255);
for (int i=0; i<8; ++i)
{
mesh.addVertex(ofVec3f( vdata[i][0], vdata[i][1], vdata[i][2] ));
mesh.addColor(cubeColor);
for (int i=0; i<6; ++i)
{
mesh.addIndex(indices[i][0]);
mesh.addIndex(indices[i][1]);
mesh.addIndex(indices[i][2]);
mesh.addIndex(indices[i][3]);
}
}
myVbo.setMesh(mesh, GL_STATIC_DRAW);
}
void cube::draw()
{
myVbo.drawElements(GL_QUADS, 24);
}
void cube::update()
{
}
void cube::setLocation(float _x, float _y, float _z)
{
x = _x;
y = _y;
z = _z;
}