@Bentley wrote:
Hi oF people.
I’m currently trying to do some hit detection of billboarded panels sitting above a 3D environment. Basically they are labels that sit atop buildings. I’m using a billboard shader to draw the labels which is very effective.
I want to be able to click on the labels in order to access more information about the 3D point that it is attached to.
To do this I want to get the 3D position of the point in world space, I then want to convert it to screen space by using cam.worldToScreen§;
ofCamera cam; // World coordinate of Point ofVec3f worldP = ofVec3f(x, y,z); ofVec3f screenCoordinateOfP; screenCoordinateOfP = cam.worldToScreen(worldP); if(mouseIsNearToPoint(screenCoordinateOfP)) { // Do stuff }I would have thought this would work but instead when I call
worldToScreen(worldP);I end up getting weird numbers, mostly numbers that are way off-screen. For a given world point which should return sensible values like: (728, 450) (calculated using a screen ruler)I’m getting values like: (2365.24, -645.439) which on a 1920x1080 screen would mean that the point is off-screen.
Any idea why these numbers seem so wrong? Once have the screen coordinate of the point I can easily work out if my mouse is near it!
Thanks,
James Bentley
Posts: 2
Participants: 1