Skip to content

Commit 047b989

Browse files
committed
Add method to invert the face-orientations of a TileModel
1 parent 939b893 commit 047b989

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

core/src/main/java/de/bluecolored/bluemap/core/map/hires/ArrayTileModel.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,39 @@ public ArrayTileModel setMaterialIndex(int face, int m) {
186186
return this;
187187
}
188188

189+
public ArrayTileModel invertOrientation(int face) {
190+
int index;
191+
float x, y, z;
192+
193+
// swap first and last positions
194+
index = face * FI_POSITION;
195+
196+
x = position[index ];
197+
y = position[index + 1];
198+
z = position[index + 2];
199+
200+
position[index ] = position[index + 6 ];
201+
position[index + 1] = position[index + 6 + 1];
202+
position[index + 2] = position[index + 6 + 2];
203+
204+
position[index + 6 ] = x;
205+
position[index + 6 + 1] = y;
206+
position[index + 6 + 2] = z;
207+
208+
// swap first and last uvs
209+
index = face * FI_UV;
210+
x = uv[index ];
211+
y = uv[index + 1];
212+
213+
uv[index ] = uv[index + 2 ];
214+
uv[index + 1] = uv[index + 2 + 1];
215+
216+
uv[index + 2 ] = x;
217+
uv[index + 2 + 1] = y;
218+
219+
return this;
220+
}
221+
189222
@Override
190223
public ArrayTileModel rotate(
191224
int start, int count,

core/src/main/java/de/bluecolored/bluemap/core/map/hires/TileModel.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ TileModel setColor(
6363

6464
TileModel setMaterialIndex(int face, int m);
6565

66+
TileModel invertOrientation(int face);
67+
6668
TileModel rotate(
6769
int start, int count,
6870
float angle, float axisX, float axisY, float axisZ
@@ -107,6 +109,14 @@ TileModel transform(
107109
float m30, float m31, float m32, float m33
108110
);
109111

112+
default TileModel invertOrientation(int start, int count) {
113+
int end = start + count;
114+
for (int face = start; face < end; face++) {
115+
invertOrientation(face);
116+
}
117+
return this;
118+
}
119+
110120
TileModel reset(int size);
111121

112122
TileModel clear();

core/src/main/java/de/bluecolored/bluemap/core/map/hires/TileModelView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ public TileModelView transform(
138138
return this;
139139
}
140140

141+
public TileModelView invertOrientation() {
142+
tileModel.invertOrientation(start, size);
143+
return this;
144+
}
145+
141146
public TileModel getTileModel() {
142147
return tileModel;
143148
}

core/src/main/java/de/bluecolored/bluemap/core/map/hires/VoidTileModel.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public TileModel setMaterialIndex(int face, int m) {
9595
return this;
9696
}
9797

98+
@Override
99+
public TileModel invertOrientation(int face) {
100+
return this;
101+
}
102+
98103
@Override
99104
public TileModel rotate(
100105
int start, int count,
@@ -167,6 +172,11 @@ public TileModel transform(
167172
return this;
168173
}
169174

175+
@Override
176+
public TileModel invertOrientation(int start, int count) {
177+
return this;
178+
}
179+
170180
@Override
171181
public TileModel reset(int size) {
172182
return this;

0 commit comments

Comments
 (0)