1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
private void displayNode(GL gl, int i) {
GLNode n = this.nodes.get(i);
//Picking mode
if (this.mouse_state == this.PICKED) {
if (this.selected == i && this.point != null) {
neighbors = this.cg.getNeighbors(selected);
GLU glu = new GLU();
int viewport[] = new int[4];
double mvmatrix[] = new double[16];
double projmatrix[] = new double[16];
double wcoord[] = new double[4];// wx, wy, wz;// returned xyz coords
int realy = 0;// GL y coord pos
this.gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
this.gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, mvmatrix, 0);
this.gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, projmatrix, 0);
realy = viewport[3] - (int) this.point.y - 1;
glu.gluUnProject((double) this.point.x, (double) realy, 0.0, //
mvmatrix, 0,//
projmatrix, 0, //
viewport, 0, //
wcoord, 0);
n.setPosition((float) wcoord[0], (float) wcoord[1]);
n.setColor(Color.GREEN);
}
else if(i != this.selected && this.point != null){
n.setPosition(n.x, n.y);
if(this.neighbors!=null && Util.contains(neighbors, i))
n.setColor(Color.PINK);
else
n.setColor(Color.RED);
}
}
//No picking mode
else{
this.neighbors=null;
n.setPosition(n.x, n.y);
n.setColor(Color.RED);
}
n.draw(gl, new GLU());
} |
Partager