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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
package ru.olamedia.geom;
import javax.vecmath.Point3f;
import ru.olamedia.asset.SpriteRectangle;
public class SimpleQuadMesh extends Mesh {
public boolean restart = true;
public Point3f bottomLeftBack = new Point3f();
public Point3f bottomLeftFront = new Point3f();
public Point3f bottomRightBack = new Point3f();
public Point3f bottomRightFront = new Point3f();
public Point3f topLeftBack = new Point3f();
public Point3f topLeftFront = new Point3f();
public Point3f topRightBack = new Point3f();
public Point3f topRightFront = new Point3f();
public float textureTop = 1;
public float textureBottom = 0;
public float textureLeft = 0;
public float textureRight = 1;
public void restart() {
restart = true;
}
public void start() {
restart = false;
}
public SimpleQuadMesh(int size) {
super(size * 4);
}
public void addBottomLeftBackVertex() {
setPoint3f(bottomLeftBack);
}
public void addBottomLeftFrontVertex() {
setPoint3f(bottomLeftFront);
}
public void addBottomRightBackVertex() {
setPoint3f(bottomRightBack);
}
public void addBottomRightFrontVertex() {
setPoint3f(bottomRightFront);
}
public void addTopLeftBackVertex() {
setPoint3f(topLeftBack);
}
public void addTopLeftFrontVertex() {
setPoint3f(topLeftFront);
}
public void addTopRightBackVertex() {
setPoint3f(topRightBack);
}
public void addTopRightFrontVertex() {
setPoint3f(topRightFront);
}
public void addFrontQuad() {
// triangle strip: И
setUV(textureLeft, textureTop);
addTopLeftFrontVertex(); // top left
setUV(textureLeft, textureBottom);
addBottomLeftFrontVertex(); // bottom left
setUV(textureRight, textureBottom);
addBottomRightFrontVertex(); // bottom right
setUV(textureRight, textureTop);
addTopRightFrontVertex(); // top right
}
public void addBackQuad() {
// triangle strip: И
setUV(textureLeft, textureTop);
addTopRightBackVertex();
setUV(textureLeft, textureBottom);
addBottomRightBackVertex();
setUV(textureRight, textureBottom);
addBottomLeftBackVertex();
setUV(textureRight, textureTop);
addTopLeftBackVertex();
}
public void addLeftQuad() {
// triangle strip: И
setUV(textureLeft, textureTop);
addTopLeftBackVertex();
setUV(textureLeft, textureBottom);
addBottomLeftBackVertex();
setUV(textureRight, textureBottom);
addBottomLeftFrontVertex();
setUV(textureRight, textureTop);
addTopLeftFrontVertex();
}
public void addRightQuad() {
// triangle strip: И
setUV(textureLeft, textureTop);
addTopRightFrontVertex();
setUV(textureLeft, textureBottom);
addBottomRightFrontVertex();
setUV(textureRight, textureBottom);
addBottomRightBackVertex();
setUV(textureRight, textureTop);
addTopRightBackVertex();
}
public void addTopQuad() {
// triangle strip: И
setUV(textureLeft, textureBottom);
addTopLeftBackVertex();
setUV(textureLeft, textureTop);
addTopLeftFrontVertex();
setUV(textureRight, textureTop);
addTopRightFrontVertex();
setUV(textureRight, textureBottom);
addTopRightBackVertex();
}
public void addBottomQuad() {
// triangle strip: И
setUV(textureLeft, textureBottom);
addBottomLeftFrontVertex();
setUV(textureLeft, textureTop);
addBottomLeftBackVertex();
setUV(textureRight, textureTop);
addBottomRightBackVertex();
setUV(textureRight, textureBottom);
addBottomRightFrontVertex();
}
public void setPointOffset(float offset) {
bottomLeftBack.x = -offset;
bottomLeftBack.y = -offset;
bottomLeftBack.z = -offset;
//
bottomLeftFront.x = -offset;
bottomLeftFront.y = -offset;
bottomLeftFront.z = offset;
//
bottomRightBack.x = offset;
bottomRightBack.y = -offset;
bottomRightBack.z = -offset;
//
bottomRightFront.x = offset;
bottomRightFront.y = -offset;
bottomRightFront.z = offset;
//
topLeftBack.x = -offset;
topLeftBack.y = offset;
topLeftBack.z = -offset;
//
topLeftFront.x = -offset;
topLeftFront.y = offset;
topLeftFront.z = offset;
//
topRightBack.x = offset;
topRightBack.y = offset;
topRightBack.z = -offset;
//
topRightFront.x = offset;
topRightFront.y = offset;
topRightFront.z = offset;
}
public void setTextureOffset(SpriteRectangle offset) {
if (null != offset) {
// System.out.print("Offset " + "[" + offset.topLeft.x + "," +
// offset.topLeft.y + "]");
textureTop = offset.topLeft.y;
textureLeft = offset.topLeft.x;
textureRight = offset.bottomRight.x;
textureBottom = offset.bottomRight.y;
}
}
}
|