projects
/
anneal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
checkpoint
[anneal.git]
/
src
/
edu
/
berkeley
/
qfat
/
Viewer.java
diff --git
a/src/edu/berkeley/qfat/Viewer.java
b/src/edu/berkeley/qfat/Viewer.java
index
627b457
..
1464020
100644
(file)
--- a/
src/edu/berkeley/qfat/Viewer.java
+++ b/
src/edu/berkeley/qfat/Viewer.java
@@
-18,17
+18,16
@@
public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
public Mesh tile = new Mesh(false);
public Mesh goal = new Mesh(false);
public Mesh tile = new Mesh(false);
public Mesh goal = new Mesh(false);
+ private int mousex;
+ private int mousey;
private Matrix projection = null;
JFrame f;
GLCanvas glcanvas;
private Matrix projection = null;
JFrame f;
GLCanvas glcanvas;
- Point clickPoint = null;
+
+ private Point clickPoint = null;
Point clickClosest = null;
Point clickClosest = null;
- int mousex;
- int mousey;
- float tx = 0;
- float ty = 0;
float tz = 0;
float anglex = 0;
float angley = 0;
float tz = 0;
float anglex = 0;
float angley = 0;
@@
-83,6
+82,13
@@
public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
protected synchronized void updateVisibility(GL gl, Mesh mesh) {
Matrix projection = Matrix.getProjectionMatrix(gl);
IntBuffer buf = ByteBuffer.allocateDirect(9*4*4).order(ByteOrder.nativeOrder()).asIntBuffer();
protected synchronized void updateVisibility(GL gl, Mesh mesh) {
Matrix projection = Matrix.getProjectionMatrix(gl);
IntBuffer buf = ByteBuffer.allocateDirect(9*4*4).order(ByteOrder.nativeOrder()).asIntBuffer();
+ gl.glFlush();
+ gl.glDrawBuffer(GL.GL_BACK);
+ gl.glReadBuffer( GL.GL_BACK );
+ gl.glPixelStorei( GL.GL_PACK_ALIGNMENT, 1);
+ gl.glFlush();
+ gl.glDisable(GL.GL_LIGHTING);
+ gl.glShadeModel(GL.GL_FLAT);
gl.glColor3f(0,0,0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
for(Mesh.T t : mesh) t.glTriangle(gl, null);
gl.glColor3f(0,0,0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
for(Mesh.T t : mesh) t.glTriangle(gl, null);
@@
-112,12
+118,16
@@
public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
gl.glDrawBuffer(GL.GL_FRONT);
}
gl.glDrawBuffer(GL.GL_FRONT);
}
-
/** return the position of the mouse as a point in window-space */
public Point getMouse() {
return new Point(mousex, glcanvas.getHeight()-mousey, 0);
}
/** return the position of the mouse as a point in window-space */
public Point getMouse() {
return new Point(mousex, glcanvas.getHeight()-mousey, 0);
}
+ /** return the position where the mouse button was pressed, or null if it is not currently pressed */
+ public Point getMouseClick() {
+ return clickPoint;
+ }
+
public void mouseWheelMoved(MouseWheelEvent e) {
tz -= e.getWheelRotation();
}
public void mouseWheelMoved(MouseWheelEvent e) {
tz -= e.getWheelRotation();
}
@@
-159,17
+169,11
@@
public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
public void mouseDragged(MouseEvent e) {
if (shift) {
public void mouseDragged(MouseEvent e) {
if (shift) {
- /*
- tx += (mousex - e.getX())/(float)20;
- ty += (mousey - e.getY())/(float)20;
- */
if (closest != null && projection != null && clickClosest != null) {
synchronized(this) {
Vec d1 = projection.inverse().times(getMouse()).minus(projection.inverse().times(clickPoint));
Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
if (closest != null && projection != null && clickClosest != null) {
synchronized(this) {
Vec d1 = projection.inverse().times(getMouse()).minus(projection.inverse().times(clickPoint));
Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
- //System.out.println(delta + " " + closest.getPoint());
- System.out.println(getMouse().minus(clickPoint));
- closest.move(Matrix.translate(delta), false);
+ closest.move(delta, false);
}
}
} else {
}
}
} else {