-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirt.cpp
96 lines (74 loc) · 2.76 KB
/
dirt.cpp
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
#include "dirt.hpp"
Dirt::Dirt(unsigned char visibility):
Cube(visibility)
{
}
void Dirt::display()
{
if (_visibility & FRONT)
{
//face avant
_renderer->setNormal(_normals);
_renderer->addVertexUV(_points, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 3, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 6, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 6, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 9, DIRT_UMAX, DIRT_VMIN);
}
if (_visibility & RIGHT)
{
//face droite
_renderer->setNormal(_normals + 3);
_renderer->addVertexUV(_points + 9, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 6, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 18, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 9, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 18, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 21, DIRT_UMAX, DIRT_VMIN);
}
if (_visibility & BACK)
{
//face arriere
_renderer->setNormal(_normals + 6);
_renderer->addVertexUV(_points + 21, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 18, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 15, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 21, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 15, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 12, DIRT_UMAX, DIRT_VMIN);
}
if (_visibility & LEFT)
{
//face gauche
_renderer->setNormal(_normals + 9);
_renderer->addVertexUV(_points + 12, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 15, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 3, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 12, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 3, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points, DIRT_UMAX, DIRT_VMIN);
}
if (_visibility & TOP)
{
//face haute
_renderer->setNormal(_normals + 12);
_renderer->addVertexUV(_points, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 9, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 21, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 21, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 12, DIRT_UMAX, DIRT_VMIN);
}
if (_visibility & BOT)
{
//face basse
_renderer->setNormal(_normals + 15);
_renderer->addVertexUV(_points + 3, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 15, DIRT_UMIN, DIRT_VMAX);
_renderer->addVertexUV(_points + 18, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 3, DIRT_UMIN, DIRT_VMIN);
_renderer->addVertexUV(_points + 18, DIRT_UMAX, DIRT_VMAX);
_renderer->addVertexUV(_points + 6, DIRT_UMAX, DIRT_VMIN);
}
}