-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcube.h
48 lines (40 loc) · 1.84 KB
/
cube.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
#include "renderer/mesh.h"
vertex vertices[8] = {
{-1, -1, -1},
{1, -1, -1},
{1, 1, -1},
{-1, 1, -1},
{-1, -1, 1},
{1, -1, 1},
{1, 1, 1},
{-1, 1, 1}};
point textureCoords[4] = {
{0, 0},
{1, 0},
{1, 1},
{0, 1}};
triangle triangles[12] = {
{vertices[0], vertices[1], vertices[2], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[0], vertices[2], vertices[3], textureCoords[0], textureCoords[2], textureCoords[3]},
{vertices[1], vertices[5], vertices[6], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[1], vertices[6], vertices[2], textureCoords[0], textureCoords[2], textureCoords[3]},
{vertices[5], vertices[4], vertices[7], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[5], vertices[7], vertices[6], textureCoords[0], textureCoords[2], textureCoords[3]},
{vertices[4], vertices[0], vertices[3], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[4], vertices[3], vertices[7], textureCoords[0], textureCoords[2], textureCoords[3]},
{vertices[3], vertices[2], vertices[6], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[3], vertices[6], vertices[7], textureCoords[0], textureCoords[2], textureCoords[3]},
{vertices[4], vertices[5], vertices[1], textureCoords[0], textureCoords[1], textureCoords[2]},
{vertices[4], vertices[1], vertices[0], textureCoords[0], textureCoords[2], textureCoords[3]}};
// mesh cube = {triangles, 12, new vertex({0, 0, 0}), new vertex({0, 0, 200}), 100};
// mesh *meshes[] = {&cube};
mesh *genCube(double x, double y, double z)
{
mesh *cube = new mesh;
cube->triangles = triangles;
cube->numTriangles = 12;
cube->rotation = new vertex({0, 0, 0});
cube->translation = new vertex({x * 50, y * 50 + 100, z * 50 + 50});
cube->scale = 25;
return cube;
}