ajaxinc wrote:

> KISS = Keeping Implementations Simple & Short

Yes, just what we need, another acronym.

>
> what's the simplest way to implement picking of rectangular region of
> canvas

Have you posted this many times? I seem to have seen it lots.

The simplest away is probably to cycle across the rectangle doing a pick
for every pixel. So if you're rectangle ranged from x1,y1 to x2,y2

    PickCanvas pickCanvas = new PickCanvas(canvas, scene);
    pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
    pickCanvas.setTolerance(1.0f);

    for (int x=x1;x<=x2;x++) {
        for (int y=y1;y<=y2;y++) {
            pickCanvas.setShapeLocation(x,y);
            PickResult[] results = pickCanvas.pickAll();

            // you'd need to do something about concatonating all the
array together here
        }
    }

However, this would be increadibly inefficent (but simple). This would
alsocause you to have to sort the results yourself.

The next step would probably to use sub-division of the rectangle into
square segments, setting the tolerance to half the width of the square
and picking from the center of the square. This would reduce the number
of picks you'd actually have to do in most cases. There are plenty of
web sites for alogirthms on sub-division.

Finally if you wanted to get far more complicated, you could get the
source for PickCanvas, use it as a reference and implement a new
PickCanvas that supported a shape that was alligned in the right way and
of the right size. This should be relativly simple since the source can
already produce square sections. As much as I hate reimplementing / not
reusing stuff, in this case it may be the only really efficent choice.
But then, I suppose this wouldn't be KISS.

Maybe I missed a really obvious tool, or mebbe some utility class at
j3d.org ?

Kev
[Please excuse spelling, I seem to have misplaced my spell checker]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to