Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18261
Modified Files:
View3D.java
Log Message:
moved selection code to abstractview
Index: View3D.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** View3D.java 17 Aug 2005 08:57:52 -0000 1.5
--- View3D.java 17 Aug 2005 11:03:22 -0000 1.6
***************
*** 11,26 ****
import net.java.games.jogl.GL;
import net.java.games.jogl.GLDrawable;
- //import net.java.games.jogl.GLU;
- import net.java.games.jogl.util.BufferUtils;
-
-
- import net.sourceforge.bprocessor.model.Edge;
- import net.sourceforge.bprocessor.model.EdgeFacade;
- import net.sourceforge.bprocessor.model.Vertex;
-
- import java.util.Iterator;
- import java.util.Set;
-
- import java.nio.IntBuffer;
import org.apache.log4j.Logger;
--- 11,14 ----
***************
*** 42,54 ****
private static double rotationY = 130;
- /** The picking state */
- private int picking = 0;
-
- /** x coordinate */
- private double x;
-
- /** y coordinate */
- private double y;
-
/**
* The constructor
--- 30,33 ----
***************
*** 77,82 ****
//Set the PickMatrix if we are trying to pick something
if (picking > 0) {
! glu.gluPickMatrix(x, viewport[3] - y, 7, 7, viewport);
! picking--;
}
double aspect = width / height;
--- 56,60 ----
//Set the PickMatrix if we are trying to pick something
if (picking > 0) {
! glu.gluPickMatrix(x, viewport[3] - y, 5, 5, viewport);
}
double aspect = width / height;
***************
*** 183,273 ****
}
}
-
- /**
- *Names objects in the scene for selection
- */
- protected void nameObjects() {
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glPushMatrix();
-
- gl.glInitNames();
-
- Set edges = EdgeFacade.getInstance().findAll();
- Iterator it = edges.iterator();
- gl.glColor3dv(STD_LINE_COLOR);
- gl.glLineWidth(1.0f);
- gl.glColor3dv(STD_LINE_COLOR);
- while (it.hasNext()) {
- Edge e = (Edge)it.next();
- Vertex to = e.getTo();
- Vertex from = e.getFrom();
- int name = e.getId().intValue();
- if (to != null && from != null) {
- gl.glPushName(name);
- gl.glBegin(GL.GL_LINES);
- gl.glVertex3d(to.getX(), to.getY(), to.getZ());
- gl.glVertex3d(from.getX(), from.getY(), from.getZ());
- gl.glEnd();
- gl.glPopName();
- }
- }
- gl.glPopMatrix();
- }
-
- /**
- * Gives an id of the object under the point of a mouseclick
- * @param x the x coordinate of the point
- * @param y the y coordinate of the point
- * @return a Long id of the object under the point, null if no object is there
- */
- public Long getObjectAtPoint(double x, double y) {
- this.x = x;
- this.y = y;
- int hits;
- IntBuffer selectBuffer = BufferUtils.newIntBuffer(1024);
- Long id = null;
- int[] mode = new int[1];
- int[] viewport = new int[] {0, 0, (int)width, (int)height};
- gl.glViewport(0, 0, (int)width, (int)height);
- gl.glSelectBuffer(1024, selectBuffer);
- gl.glRenderMode(GL.GL_SELECT);
-
- //drawing scene in selection mode
- picking = 60; //indicating that I am trying to pick(used in camera)
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
-
- camera(drawable);
- grid();
- coords();
- gl.glColor3dv(STD_LINE_COLOR);
- gl.glLineWidth(1.0f);
- drawAll(drawable);
-
- //picking = 0;
- //end drawing scene
-
- //gl.glMatrixMode(GL.GL_PROJECTION);
- //gl.glPopMatrix();
- gl.glFlush();
-
- //Geting hits and going back to RENDER mode
- hits = gl.glRenderMode(GL.GL_RENDER);
-
- log.info("x,y = " + x + "," + y + " hits = " + hits + ";SB = " + selectBuffer.get(0));
-
- //Processing hits
- if (hits >= 1) {
- Integer intId = new Integer(selectBuffer.get(3));
- id = new Long(intId.longValue());
- }
-
- gl.glMatrixMode(GL.GL_MODELVIEW);
-
- if (id != null) {
- return id;
- } else {
- return null;
- }
- }
}
--- 161,163 ----
|