If you were only using a circle, not a sphere, it's simple trigonometry; sphere is abit more difficult though, do you have to take rotation (of the sphere) into account?
For a circle though; see attached image, and you must know:
- The distance (D) from the viewing platform to the center of the object
- The distance (Y) from the line Y=0 (relative the sphere AND viewing platform) to the point where the click is received from.
- The radius (R) of the object.
This won’t work directly with spheres, it assumes a cylindrical object lateral to the viewing platform, with a zoom factor of 1, and no transformations.
The point you’ll get is X,Y,Z where (X,Y) are the clicked co-ordinate, and Z is the result of:
t = asin(Y/R)
B = cos(t) x R
Z = D – B
If the X and Y values are within a distance (the object’s size as centred around the line X = 0, Y = 0) from the point X = 0, Y = 0; then the point is on the surface of the object, at the point X,Y,Z relative to the viewing platform.
To map that to a texture co-ordinate is different, it depends on your texturing system/method of creating the object; you can find the point relative to the object as opposed to relative to the viewing platform by subtracting the value of Z from the value of D, or taking the initial value of B.
Taking that from a circle function to a sphere function could be simple, but could be difficult depending on the potential for/possibility of rotation, particularly if it's about arbitrary axes.
Hope that helps; but definately try looking for third party packages/extensions that implement point picking; there may be some in Java3D already somewhere, look in the Java3D examples folder, I remember seeing some nice picking demos in there.
Another solution (if texture point picking isn't implemented) is to put objects (which CAN be picked easily using the mouse) at every texture point, store reference to the texture point in that object, catch the pick with a behaviour and mutate or return the reference depending on what kind of app you're making.
Matt