Get screen coordinates and size of OpenGL 3D Object after transformation -
i have couple of 3d objects in opengl in processing sketch , need find out if mouse hovering on objects. since there constant transformation can't compare original coordinates , size mouse position. found screenx() , screeny() methods return translated screen coordinates after transformation , translation still need displayed size after rotation.
determining object mouse on called picking , there 2 main approaches:
- color picking. draw each object using different color buffer (this done when picking, colored objects never displayed on screen). use glreadpixels read pixel under cursor , check color determine object is. if mouse isn't on object you'll background color. more details here: lighthouse 3d picking tutorial, color coding
- ray casting. cast ray through cursor location scene , check if intersects objects. more details here: mouse picking ray casting
from reading description option 1 simpler , need.
Comments
Post a Comment