View Full Version : Box selection instead of picking

05-12-2006, 10:43 PM

I thought I could use the normal picking procedure to select objects with a rubberband box but this only works if the area is completely covered with objects.
If I have a part of the area without objects, I get zero hits.

Is this expected behaviour?
If so, what can I do to create a rubberband selection?

glu.gluPickMatrix((x0+x)*0.5, (double)(viewport[3]-(y0+y)*0.5),Math.abs(x0-x),Math.abs(y0-y),viewport,0);Box diagonal corners (x0,y0) and (x,y)

Thanks for your feedback
/Jonas Forssell, Gothenburg, Sweden

05-13-2006, 12:55 PM
Try something like this instead.

int xsize=Math.abs(x0-x);
int ysize=Math.abs(y0-y);
gluPickMatrix( Math.min(x0,x)+xsize/2.0,
Math.min(y0,y)+ysize/2.0, xsize, ysize);
I have not tried it but something like that should work, the example above assume that your y values are correct OpenGL values and not standard mouse coordinates.

(You need to specify the center of the box and the width and height of the box as arguments)


05-13-2006, 01:02 PM

I also found that the buffer was not set high enough so when the selection included too much element, none was selected!