- Matrix projection = Matrix.getProjectionMatrix(gl);
- double dist = Double.MAX_VALUE;
- if (getMouseClick() != null) return;
- closest = null;
- for(Mesh mesh : meshes)
- if (mesh.option_selectable)
- for(Mesh.Vertex v : mesh.vertices()) {
- if (!v.visible) continue;
- Point p = projection.times(v.getPoint());
- int x = (int)p.x;
- int y = (int)p.y;
- int mousex = (int)getMouse().x;
- int mousey = (int)getMouse().y;
- if (closest==null || (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey) < dist) {
- dist = (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey);
- closest = v;
- }
+ if (closest.visible) {
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ gl.glColor3f(1,1,0);
+ gl.glBegin(gl.GL_POINTS);
+ closest.getPoint().glVertex(gl);
+ gl.glColor3f(0.5f,0.5f,0);
+ for(Mesh.Vertex v : (Iterable<Mesh.Vertex>)closest.getBoundPeers())
+ if (v!=closest)
+ v.getPoint().glVertex(gl);
+ gl.glEnd();
+
+ if (closest.getBindingConstraint() instanceof Plane) {
+ Plane p = (Plane)closest.getBindingConstraint();
+ Vec v = p.norm();
+ gl.glEnable(gl.GL_BLEND);
+ gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
+ gl.glColor4f(1,1,0,0.3f);
+ gl.glBegin(gl.GL_LINES);
+ closest.getPoint().glVertex(gl);
+ v.plus(closest.getPoint()).glVertex(gl);
+ closest.getPoint().glVertex(gl);
+ v.times(-1).plus(closest.getPoint()).glVertex(gl);
+ gl.glEnd();
+ gl.glDisable(gl.GL_BLEND);