I want to use mouse to pick 3D balls int 3D world.
I got 3D ball centre coordinates(ball_x,ball_y,ball_z),mouse clicking coordinates(mouse_x,mouse_y)
My plane is :
1.use gluUnProject(mouse x,mouse y,mouse z,model,projection,viewport,world x,world y,world z)
mouse_z is 0 and 1.0, to get world_x,world_y,world_z on of the near point and far point on the Cut surface.
2.through eye point(eye x,eye y,eye z),near point,far point,i get a shooting line start from eye point .
i judge the distance from ball centre to the line,if it is longer than ball radius to decide if the line get through the ball.
through the balls,
i choose the shortest distance from ball centre to my eye coordinates.
Is this plane ok?Please give me some advice if there are any problems,THX all.