import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;
import java.util.*;
+import edu.berkeley.qfat.bind.*;
import edu.berkeley.qfat.geom.*;
import edu.berkeley.qfat.geom.Point;
public class MeshViewer extends JPanel implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
+ Main main;
+
+
private float tz = 0;
private float anglex = 0;
private float angley = 0;
private Mesh.Vertex closest = null;
+ private Point closestOriginallyAt = null;
private int mousex;
private int mousey;
private Matrix projection = null;
gl.glEnable(GL.GL_LIGHTING);
gl.glShadeModel(GL.GL_SMOOTH);
- for(Mesh mesh : meshes)
+ for(Mesh mesh : meshes) {
mesh.render(gl, Matrix.ONE);
+ if (main != null && main.whichNeighbor>0 && main.transforms!=null && !mesh.option_wireframe) {
+ mesh.option_wireframe = true;
+ mesh.render(gl, main.transforms[main.whichNeighbor-1]);
+ mesh.option_wireframe = false;
+ }
+ }
// highlight the point closest to the mouse; we do this here to avoid flicker
if (closest != null) {
//Matrix projection = Matrix.getProjectionMatrix(gl);
double dist = Double.MAX_VALUE;
closest = null;
+ closestOriginallyAt = null;
for(Mesh mesh : meshes)
if (mesh.option_selectable)
for(Mesh.Vertex v : mesh.vertices()) {
if ((e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) {
if (closest != null && projection != null) {
synchronized(this) {
- Point clickClosest = closest == null ? null : closest.getPoint();
+ if (closestOriginallyAt==null) closestOriginallyAt = closest.getPoint();
Vec d1 = projection.inverse().times(getMouse()).minus(projection.inverse().times(clickPoint));
- Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
+ Vec delta = d1.plus(closestOriginallyAt).minus(closest.getPoint());
closest.move(delta, false);
}
}