Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D sprite to bounding box hit test
#1
Is there a way to get elements inside a 2D rectangle?
I mean, probably I can draw an overly sprite for the rectangle following user's pointer, but after having screen U,V coordinates I'll need a hit test on elements that I don't know how to solve. Maybe getting a camera direction ray and move it along the edges, but that would not retrieve elements inside the rectangle.
Maybe a bounding box created from perpendicular plane to camera and long enough could do the job, but I am totally lost

Any tip about this?
#2
I have just added a new sample that shows how to render scene to ID bitmap where each object is rendered with its own color that represents the  ID of the object (https://github.com/ab4d/Ab4d.SharpEngine...pSample.cs).

This sample shows how to get the hit object by checking the colors at the specified mouse coordinates.

Get the latest version of the samples to get the new "Hit-testing with ID bitmap".

This sample can be easily extended to get objects in a rectangle by checking the colors in the rectangular area instead of checking the color of a single pixel.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)