I’m currently using an offscreen buffer in a 3D view and also a 2D view to help select objects in a UI when the mouse is clicked.
The method is basically similar to what @Quark has built for shapes3D i.e. assigning a unique colour to every object and then testing mouseX/Y in the PGraphics buffer to see if the mouse is over an assigned colour rather than background and get the instance of the object associated with that colour.
I’ve also used the same approach in a 2D view because it was a very easy solution for when the 2D view had been zoomed out or panned about.
What I’m now trying to figure out, is an effecient method to use a marquee selection / drag rectangle that references this PGraphics offscreen buffer for both 3D and 2D views so that multiple objects can easily be selected in one go.
My attempts to loop thru XY positions and testing pixel colour in the buffer have ended up dragging the application to near standstill.
The buffer is quite large approx. 1780*900. In the 2Dview all objects are of a known similar size, so in theory I shouln’t need to test every pixel…I think, but that doesn’t help with the 3D view.
Would it perhaps be quicker / better to save the buffer as a PImage, loadPixels and iterate thru that rather than the PGraphics ‘buffer’, would it make any difference ?
Has anyone here got a marquee selection working in a P3D context before ?