public MeshViewer(JFrame f) { super(f); }
-
public void _display(GLAutoDrawable drawable, GL gl) {
if (transforms==null) return;
gl.glDisable(GL.GL_LIGHTING);
gl.glShadeModel(GL.GL_FLAT);
- }
+ updateVisibility(gl, tile);
+ Matrix projection = Matrix.getProjectionMatrix(gl);
+ double dist = Double.MAX_VALUE;
+ if (clickPoint != null) return;
+ closest = null;
+ for(Mesh.Vertex v : tile.vertices()) {
+ if (!v.visible) continue;
+ Point p = projection.times(v.getPoint());
+ int x = (int)p.x;
+ int y = (int)p.y;
+ y = glcanvas.getHeight()-y;
+ if (closest==null || (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey) < dist) {
+ dist = (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey);
+ closest = v;
+ }
+ }
+ }
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) {