use of com.jogamp.opengl.GL.GL_LINE_STRIP in project narchy by automenta.
the class OsmSpace method compile.
protected Consumer<GL2> compile() {
List<Consumer<GL2>> draw = new FasterList();
Osm osm = id;
for (OsmWay way : osm.ways) {
Map<String, String> tags = way.tags;
String building, building_part, landuse, natural, route, highway;
if (!tags.isEmpty()) {
building = tags.get("building");
building_part = tags.get("building:part");
landuse = tags.get("landuse");
natural = tags.get("natural");
route = tags.get("route");
highway = tags.get("highway");
} else {
building = building_part = landuse = natural = route = highway = null;
}
boolean isPolygon = false;
boolean isClosed = way.isClosed();
float r, g, b, a;
float lw;
short ls;
if (building != null || building_part != null) {
r = 0f;
g = 1f;
b = 1f;
a = 1f;
lw = 1f;
ls = (short) 0xFFFF;
isPolygon = !wireframe && isClosed;
} else if ("forest".equals(landuse) || "grass".equals(landuse) || "wood".equals(natural)) {
r = 0f;
g = 1f;
b = 0f;
a = 1f;
lw = 1f;
ls = (short) 0xFFFF;
isPolygon = !wireframe && isClosed;
} else if ("water".equals(natural)) {
r = 0f;
g = 0f;
b = 1f;
a = 1f;
lw = 1f;
ls = (short) 0xFFFF;
isPolygon = !wireframe && isClosed;
} else if ("pedestrian".equals(highway)) {
r = 0f;
g = 0.5f;
b = 0f;
a = 1f;
lw = 2f;
ls = (short) 0xFFFF;
} else if ("motorway".equals(highway)) {
r = 1f;
g = 0.5f;
b = 0f;
a = 1f;
lw = 5f;
ls = (short) 0xFFFF;
} else if (highway != null) {
r = 1f;
g = 1f;
b = 1f;
a = 1f;
lw = 3f;
ls = (short) 0xFFFF;
} else if ("road".equals(route)) {
r = 1f;
g = 1f;
b = 1f;
a = 1f;
lw = 1f;
ls = (short) 0xFFFF;
} else if ("train".equals(route)) {
r = 1f;
g = 1f;
b = 1f;
a = 1f;
lw = 5f;
ls = (short) 0xF0F0;
} else {
r = 0.5f;
g = 0f;
b = 0.5f;
a = 1f;
lw = 1f;
ls = (short) 0xFFFF;
}
if (isPolygon) {
List<OsmNode> nn = way.getOsmNodes();
double[][] coord = new double[nn.size()][7];
for (int i = 0, nnSize = nn.size(); i < nnSize; i++) {
OsmNode node = nn.get(i);
double[] ci = coord[i];
project(node.geoCoordinate, ci);
ci[3] = r;
ci[4] = g;
ci[5] = b;
ci[6] = a;
}
draw.add((gl) -> {
gl.glColor4f(r * 0.5f, g * .5f, b * 0.5f, a);
gl.glLineWidth(lw);
gl.glLineStipple(1, ls);
GLU.gluTessBeginPolygon(tobj, null);
GLU.gluTessBeginContour(tobj);
for (int i = 0, nnSize = nn.size(); i < nnSize; i++) {
double[] ci = coord[i];
GLU.gluTessVertex(tobj, ci, 0, ci);
}
GLU.gluTessEndContour(tobj);
GLU.gluTessEndPolygon(tobj);
});
} else {
List<OsmNode> ways = way.getOsmNodes();
int ws = ways.size();
double[] c3 = new double[3 * ws];
for (int i = 0, waysSize = ws; i < waysSize; i++) {
project(ways.get(i).geoCoordinate, c3, i * 3);
}
draw.add((gl) -> {
gl.glColor4f(r, g, b, a);
gl.glLineWidth(lw);
gl.glLineStipple(1, ls);
gl.glBegin(GL_LINE_STRIP);
for (int i = 0; i < c3.length / 3; i++) {
gl.glVertex3dv(c3, i * 3);
}
gl.glEnd();
});
}
}
for (OsmNode node : osm.nodes) {
Map<String, String> tags = node.tags;
if (tags.isEmpty())
continue;
String highway = tags.get("highway");
String natural = tags.get("natural");
float pointSize;
float r, g, b, a;
if ("bus_stop".equals(highway)) {
pointSize = 3;
r = g = b = 1f;
a = 0.7f;
} else if ("traffic_signals".equals(highway)) {
pointSize = 3;
r = g = 1f;
b = 0f;
a = 0.7f;
} else if ("tree".equals(natural)) {
pointSize = 3;
g = 1f;
r = b = 0f;
a = 0.7f;
} else {
pointSize = 3;
r = 1f;
g = b = 0f;
a = 0.7f;
}
double[] c3 = new double[3];
project(node.geoCoordinate, c3);
draw.add((gl) -> {
gl.glPointSize(pointSize);
gl.glBegin(GL_POINTS);
gl.glColor4f(r, g, b, a);
gl.glVertex3d(c3[0], c3[1], c3[2]);
gl.glEnd();
});
}
return (v) -> draw.forEach(d -> d.accept(v));
}
Aggregations