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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
package ru.olamedia.geom;
public class SimpleQuadMesh extends Mesh {
public SimpleQuadMesh(int size) {
super(size * 4);
}
private void addBottomLeftBackVertex() {
setPoint3f(-0.5f, -0.5f, -0.5f);
}
private void addBottomLeftFrontVertex() {
setPoint3f(-0.5f, -0.5f, 0.5f);
}
private void addBottomRightBackVertex() {
setPoint3f(0.5f, -0.5f, -0.5f);
}
private void addBottomRightFrontVertex() {
setPoint3f(0.5f, -0.5f, 0.5f);
}
private void addTopLeftBackVertex() {
setPoint3f(-0.5f, 0.5f, -0.5f);
}
private void addTopLeftFrontVertex() {
setPoint3f(-0.5f, 0.5f, 0.5f);
}
private void addTopRightBackVertex() {
setPoint3f(0.5f, 0.5f, -0.5f);
}
private void addTopRightFrontVertex() {
setPoint3f(0.5f, 0.5f, 0.5f);
}
public void addFrontQuad() {
// triangle strip: И
setUV(0, 1);
addTopLeftFrontVertex(); // top left
setUV(0, 0);
addBottomLeftFrontVertex(); // bottom left
setUV(1, 0);
addBottomRightFrontVertex(); // bottom right
setUV(1, 1);
addTopRightFrontVertex(); // top right
}
public void addBackQuad() {
// triangle strip: И
setUV(0, 1);
addTopRightBackVertex();
setUV(0, 0);
addBottomRightBackVertex();
setUV(1, 0);
addBottomLeftBackVertex();
setUV(1, 1);
addTopLeftBackVertex();
}
public void addLeftQuad() {
// triangle strip: И
setUV(0, 1);
addTopLeftBackVertex();
setUV(0, 0);
addBottomLeftBackVertex();
setUV(1, 0);
addBottomLeftFrontVertex();
setUV(1, 1);
addTopLeftFrontVertex();
}
public void addRightQuad() {
// triangle strip: И
setUV(0, 1);
addTopRightFrontVertex();
setUV(0, 0);
addBottomRightFrontVertex();
setUV(1, 0);
addBottomRightBackVertex();
setUV(1, 1);
addTopRightBackVertex();
}
public void addTopQuad() {
// triangle strip: И
setUV(0, 0);
addTopLeftBackVertex();
setUV(0, 1);
addTopLeftFrontVertex();
setUV(1, 1);
addTopRightFrontVertex();
setUV(1, 0);
addTopRightBackVertex();
}
public void addBottomQuad() {
// triangle strip: И
setUV(0, 0);
addBottomLeftFrontVertex();
setUV(0, 1);
addBottomLeftBackVertex();
setUV(1, 1);
addBottomRightBackVertex();
setUV(1, 0);
addBottomRightFrontVertex();
}
}
|