-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCube.h
More file actions
67 lines (55 loc) · 1.89 KB
/
Cube.h
File metadata and controls
67 lines (55 loc) · 1.89 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
#ifndef CUBE
#define CUBE
#include <glm/glm.hpp>
#include <GL/glew.h>
#include "Primitive.h"
class Cube : public Primitive {
public:
Cube(float x, float y, float z, float rx, float ry, float rz,
float sx, float sy, float sz, Material& mat);
Cube(float x, float y, float z, float rx, float ry, float rz,
float sx, float sy, float sz);
Cube();
~Cube();
void render() override;
void setScale(glm::vec3 newScale)
{
scale = newScale;
boundingBox.aabbMin = glm::vec3(-0.5f*newScale.x*newScale.x, -0.5f*newScale.y*newScale.y, -0.5f*newScale.z*newScale.z);
boundingBox.aabbMax = glm::vec3(0.5f*newScale.x*newScale.x, 0.5f*newScale.y*newScale.y, 0.5f*newScale.z*newScale.z);
}
private:
float verts[144] = {
//Front
-0.5, -0.5, -0.5, 0.0, 0.0, -1.0,
-0.5, 0.5, -0.5, 0.0, 0.0, -1.0,
0.5, 0.5, -0.5, 0.0, 0.0, -1.0,
0.5, -0.5, -0.5, 0.0, 0.0, -1.0,
//Back
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0,
0.5, -0.5, 0.5, 0.0, 0.0, 1.0,
0.5, 0.5, 0.5, 0.0, 0.0, 1.0,
-0.5, 0.5, 0.5, 0.0, 0.0, 1.0,
//Top
0.5, 0.5, -0.5, 0.0, 1.0, 0.0,
-0.5, 0.5, -0.5, 0.0, 1.0, 0.0,
-0.5, 0.5, 0.5, 0.0, 1.0, 0.0,
0.5, 0.5, 0.5, 0.0, 1.0, 0.0,
//Bottom
0.5, -0.5, -0.5, 0.0, -1.0, 0.0,
0.5, -0.5, 0.5, 0.0, -1.0, 0.0,
-0.5, -0.5, 0.5, 0.0, -1.0, 0.0,
-0.5, -0.5, -0.5, 0.0, -1.0, 0.0,
//Right
0.5, -0.5, 0.5, 1.0, 0.0, 0.0,
0.5, -0.5, -0.5, 1.0, 0.0, 0.0,
0.5, 0.5, -0.5, 1.0, 0.0, 0.0,
0.5, 0.5, 0.5, 1.0, 0.0, 0.0,
//Left
-0.5, -0.5, 0.5, -1.0, 0.0, 0.0,
-0.5, 0.5, 0.5, -1.0, 0.0, 0.0,
-0.5, 0.5, -0.5, -1.0, 0.0, 0.0,
-0.5, -0.5, -0.5, -1.0, 0.0, 0.0
};
};
#endif