PDA

View Full Version : Tessellation and Selection



Richard145
04-20-2007, 06:33 AM
Hello all. I am using GLUTessellation and the GL_SELECT mode and am getting some strange results. Whenever I process the "hits" I always get 1. I was wondering if the tessellation could be causing the problem?

Below is some snippets of my code:

...
int[] viewport = new int[4];
int hits = 0;
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glSelectBuffer(selectionBuffer.capacity(), selectionBuffer);
gl.glRenderMode(GL.GL_SELECT);
this.mode = GL.GL_SELECT;
gl.glInitNames();
glu.gluPickMatrix((double)this.mouseX, (double)(viewport[3] - this.mouseY), 10.0d, 10.0d, viewport, 0);

// Render the Model
draw(gl);

hits = gl.glRenderMode(GL.GL_RENDER);
this.mode = GL.GL_RENDER;The draw(GL gl) Method is where the actual Model is rendered:

GLU glu = new GLU();
tessellCallBack tessCallback = new tessellCallBack(gl, glu);
GLUtessellator tobj = glu.gluNewTess();
glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);
// A Vector of Polygon Faces (these are what I would like to
// set on the NAME Stack for selection
Vector faces = sd.getFaces();
for (int i = 0; i < faces.size(); i++) {
face = (FaceData)faces.get(i);
// Vector of "holes" in Polygon
holes = face.getHoles();
if (this.mode == GL.GL_SELECT) {
// We are in the SELECTION Mode, so push this identity
// on the current NAME Stack
gl.glPushName(i);
}
glu.gluTessBeginPolygon(tobj, null);
glu.gluTessBeginContour(tobj);
for (int j = 0; j < outPts.length; j++) {
glu.gluTessVertex(tobj, outPts[j], 0, outPts[j]);
}
glu.gluTessEndContour(tobj);
for (int j = 0; j < holes.size(); j++) {
poly = (PolyData)holes.get(j);
double[][] holePts = poly.getPtsArray();
glu.gluTessBeginContour(tobj);
for (int k = 0; k < holePts.length; k++){
glu.gluTessVertex(tobj, holePts[k], 0, holePts[k]);
}
glu.gluTessEndContour(tobj);
}
glu.gluTessEndPolygon(tobj);
if (this.mode == GL.GL_SELECT) {
gl.glPopName();
}
}// End of OUTER FOR-LOOP
glu.gluDeleteTess(tobj);Thanks in advance for ANY help/hints. I am fairly new to OpenGL and needless to say, selection seems pretty difficult at this point.

Richard145
04-21-2007, 04:35 AM
anyone?