Picking Problem - Either hits always or not any

Hello,



I have copied the picking tutorial sample code and applied it to my code. My code is very easy. Only a single sphere (geometry, mesh, material) at localTranslation x,y,z attached to the rootNode. I can see the sphere. If I use the code from the tutorial, I can click the mouse button or hit the space bar and get my collision results printed on the output screen. However, it makes no difference where to click, I always get 63 !!! collision results, even if I click the “black nirvana” around the sphere. My question is…



what about the mouse pointer canvas x-y position? How is it implemented? Does it have to be implemented? What is the ray? Is the ray the direct connection between the center of my cam to the mouse pointer in 3D at infinity?



Thanks,

Equi

Hello,



ahhh. Now I got it. It is a 3D Shooter style. The ray is always created from the center of the camera into the camera direction. Now, of course, my question would be how to transform the mouse coordinates to a ray. It must be something like this…



[java]



rootNode.updateGeometricState();

// 1. Reset results list.

CollisionResults results = new CollisionResults();

// 2. Aim the ray from cam loc to cam direction.

Vector3f pos=cam.getWorldCoordinates(PraxitelesApplication.mousePosition,0f);

Vector3f dir=cam.getWorldCoordinates(PraxitelesApplication.mousePosition,1f);

dir.subtract(pos).normalizeLocal();

Ray ray = new Ray(pos, dir);



[/java]



Thanks,

Equi

Vector3f pos=cam.getWorldCoordinates(PraxitelesApplication.mousePosition,0f);

==

Vector3f pos=cam.getLocation();

See TestMousePick test class

Hello Momoko Fan,



Thanks a lot, that helped very much.



Regards,

Equi