public void drawTransform()
{
if( DrawMode == true ) { drawTransformModel(); }
else if( DrawMode != true )
{
hits = 0;
x = (double) prevMouseX;
y = (double) prevMouseY;
gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort);
System.out.println("GlSelectBuffer " + buffsize + " " + selectBuffer.length);
gl.glSelectBuffer(buffsize, selectBuffer);
gl.glRenderMode(GL.GL_SELECT);
gl.glInitNames();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluPickMatrix(x, (double) viewPort[3] - y, 1.0d, 1.0d, viewPort);
// setView();
gl.glOrtho( bounds[0][0], bounds[0][1],bounds[1][0], bounds[1][1],bounds[2][0], bounds[2][1]);
gl.glPushMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
//gl.glPopMatrix();
// object translation
//gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
///gl.glLoadIdentity();
///viewResize();
gl.glTranslated( (trans.x) * (bounds[0][1] - bounds[0][0]) / Width,
trans.y * (bounds[1][1] - bounds[1][0]) / Height, 0.0);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
drawTransformModel();
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glFlush();
hits = gl.glRenderMode(GL.GL_RENDER);
processHits(hits, selectBuffer);
pickProcess();
DrawMode = true;
//gldrawable.display();
}
}
public void processHits(int hits, int[] buffer)
{
//System.out.println("---------------------------------");
//System.out.println(" HITS: " + hits);
int offset = 0;
int names;
float z1, z2;
float z1Min[] = new float[hits];
float minZ = 9999999;
float maxZ = -9999999;
int select=-1;
this.nObjectHits = hits;
for (int i=0;i<hits;i++)
{
//System.out.println("- - - - - - - - - - - -");
names = buffer[offset]; offset++;
//System.out.println(" hit: " + (i + 1) + " ... " + names);
z1 = (float) buffer[offset] / 0x7fffffff; offset++;
z2 = (float) buffer[offset] / 0x7fffffff; offset++;
for (int j=0;j<names;j++)
{
if (j==(names-1) && buffer[offset] > 100)
{
selectObjectBuffer = buffer[offset];
System.out.println("RawHits " +i+ " " + selectObjectBuffer + " " + z1);
if(z1 <= minZ)
{
select = buffer[offset];
minZ = z1;
}
}
offset++;
}
}
if(select >=hits)
{
this.nObjectHits=1;
this.selectObjectBuffer = select;
//System.out.println("selectPROC :" + select);
}
else
{
this.nObjectHits=0;
}
//System.out.println(" HITS: " + nObjectHits);
//for (int i=0;i<nObjectHits;i++)
// {
// System.out.println("-----> " + selectObjectBuffer[i]);
//}
//System.out.println("ROTS " + view_rotx + " " + view_roty + " " + view_rotz);
}