   3d paint program
  I'm making a 3d paint program.  Basically, it puts a sphere in a 3d scene when the user clicks the mouse.  All of the sphere radii will go into the same plane.  Anyone know exactly how to convert a 2d mouse click into a 3d point in the scene that corresponds exactly?
Quote:Original post by ms75214I'm making a 3d paint program.  Basically, it puts a sphere in a 3d scene when the user clicks the mouse.  All of the sphere radii will go into the same plane.  Anyone know exactly how to convert a 2d mouse click into a 3d point in the scene that corresponds exactly?A 2D mouse pointer does not convert to a 3D point.A single pixel represents a box or pyramid projected out to infinity.A few options:* Project your 2D coordinate back onto your plane* Use a selection buffer to identify the selected object.* Use Google to find some of the many other solutions out there.   ;Quote:Original post by frob* Project your 2D coordinate back onto your planeThe best option....  Generate a ray from the points on the near/far viewing plane, determine ray intersection with the plane, and then render sphere at specified location. Quote:Original post by frob* Use a selection buffer to identify the selected object.Ack, my eyes! They burn! More seriously, avoid the selection buffer like the plague, mainly because it's extremely in-efficient (certainly not quick enough for a 3D paint app - it's computed entirely in software!). The biggest problem is it's deprecated status, which already causes problems with some vendors hardware and OpenGL3+. A good case in point, try selecting an object that's been generated via a geometry or tessellation shader! You will find there are some difficulties with that (i.e. a crash!). The final nail in the coffin is that you can determine that the plane has been hit, but you won't be able to determine a selection point.   