As you can see in the upcoming code, I’ve implemented a custom way of mouse picking through the AWT interface. While debugging it appeared to me that mouse clicks were indeed transformed into meaningful world coordinates (both X and Y between -0.5 and 0.5). However, when performing mouse picking on a rotated box, finding picks really lacks accuracy and I can get a static box continue rotating even by clicking its surroundings (as depicted in the following image).
I’ve read several topics about triangle picking, but implementing those pieces of code only ends up in null pointer exceptions. What would be a general method for accurately picking any kind of spatial?
Greetings.
SwingTest.java - to start up the application, putting jME in a canvas
You are using BoundingPickResults combined with BoundingBox which is Axis-Aligned. So, based on that fact and your screenshot, I'd guess that it is in fact hitting the bounding for that box.
Turn on bounding display to see a more accurate picture of what is happening.
As you can see on the screenshot, you were right. Thanks for clearing that up.
However, forgive me my ignorance, but I haven’t got a clue on how to increase the accuracy; simply changing BoundingPickResults into TrianglePickResults is rather useless.
Okay, I’ve implemented the triangle picking method from (here), which really improved the accuracy…
well, actually I would say the picking method is too picky now
As indicated in the image below, picking the red spot fails to produce a triangle intersection, which in turn fails to get the model rotating (or stopping from rotating)… whereas, the closer I get to the center (the green spot), the more ‘luck’ I get.
I hope this isn’t any kind of float imprecision thingy.