- if (clickPoint==null) closest = null;
- synchronized(this) {
- for(Mesh.T t : safeTriangles)
- t.glTriangle(gl, null);
- for(Mesh.Vertex v : tile.vertices()) {
- Point p = v.getPoint();
- gl.glColor3f(1,1,1);
- gl.glBegin(gl.GL_POINTS);
- p.glVertex(gl);
- gl.glEnd();
- gl.glFlush();
-
- Point projected = projection.times(p);
- int x = (int)projected.x;
- int y = (int)projected.y;
- gl.glReadPixels(x-1, y-1, 3, 3, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, buf);
-
- boolean vis = false;
- for(int j=0; j<9*4; j++) vis |= buf.get(j)!=0;
- v.visible = vis;
- if (vis) {
- gl.glColor3f(0,0,0);
- gl.glBegin(gl.GL_POINTS);
- p.glVertex(gl);
- gl.glEnd();
- y = glcanvas.getHeight()-y;
- if (clickPoint==null) {
- if (closest==null || (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey) < dist) {
- dist = (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey);
- closest = v;
- }
- }
- }
- }
- }
- gl.glShadeModel(GL.GL_SMOOTH);
- gl.glEnable(GL.GL_LIGHTING);
- gl.glDrawBuffer(GL.GL_FRONT);
- }
-
-
- private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris) { draw(gl, triangles, tris, Matrix.ONE); }
- private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris, Matrix m) {
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
- synchronized(this) {
- for(Mesh.T t : tris) {
- if (red < 0.15) red = 1.0f;
- if (green < 0.15) green = 1.0f;
- if (blue < 0.15) blue = 1.0f;
- red -= .09f;
- green -= .12f;
- blue -= .15f;
-
- /*
- if (triangles) switch(t.color) {
- case 0: gl.glColor4f((float)0.25, (float)0.25, (float)0.75, (float)0.3); break;
- case 1: gl.glColor4f((float)0.25, (float)0.75, (float)0.25, (float)0.3); break;
- case 2: gl.glColor4f((float)0.75, (float)0.25, (float)0.25, (float)0.3); break;
- case 3: gl.glColor4f((float)0.50, (float)0.50, (float)0.50, (float)0.3); break;
- case 4: gl.glColor4f((float)0.25, (float)0.75, (float)0.75, (float)0.3); break;
- case 5: gl.glColor4f((float)0.25, (float)0.75, (float)0.75, (float)0.3); break;
- case 6: gl.glColor4f((float)0.75, (float)0.25, (float)0.75, (float)0.3); break;
- }
- */
-
- gl.glColor4f((float)(0.25+(0.05*t.color)),
- (float)(0.25+(0.05*t.color)),
- (float)(0.75+(0.05*t.color)),
- (float)0.3);
- //if (t.v1().visible && t.v2().visible && t.v3().visible) continue;
-
- /*
- if (t.e1().pair.t==null) gl.glColor4f((float)0.25, (float)0.25, (float)0.75, (float)0.3);
- else if (t.e2().pair.t==null) gl.glColor4f((float)0.25, (float)0.25, (float)0.75, (float)0.3);
- else if (t.e3().pair.t==null) gl.glColor4f((float)0.25, (float)0.25, (float)0.75, (float)0.3);
- else gl.glColor4f((float)0.75, (float)0.25, (float)0.25, (float)0.3);
- */
- //gl.glBegin(GL.GL_LINES);
-
- if (triangles) {
- t.glTriangle(gl, m);
- } else {
- gl.glDisable(GL.GL_LIGHTING);
- gl.glBegin(GL.GL_LINES);
- gl.glColor3f(1, 1, 1);
- m.times(t.e1().p1.goodp).glVertex(gl);
- m.times(t.e1().p2.goodp).glVertex(gl);
- m.times(t.e2().p1.goodp).glVertex(gl);
- m.times(t.e2().p2.goodp).glVertex(gl);
- m.times(t.e3().p1.goodp).glVertex(gl);
- m.times(t.e3().p2.goodp).glVertex(gl);
- gl.glEnd();
- gl.glEnable(GL.GL_LIGHTING);