Picking library failing on many spheres

another picking:

Everything we draw on screen we also draw on a PGraphics that we don’t display. We use PGraphics only to check it against the mouse. The items / boxes we draw on the PGraphics we draw with an unique color.
Then we can use pg.get(mouseX,mouseY) to check against the pixel.
We need some kind of list to know which item / box has thi color we found under the mouse.

It is a picking mechanism: The color underneath the mouse is checked against a unique color that every box has. This unique color is invisible on a PGraphics that gets not displayed. In this PGraphics the check of the mouse is performed.

This is useful because we don’t have to do any calculations with mouse position and box position but can just use the colors. We have to use the PGraphics because in the visible graphic, the colors are distorted because we use lights(). The PGraphics has the same size as the visible window and also uses the same camera data of course. But noLights() command

see Looking for more resources about ArrayLists - #45 by Chrisir

1 Like