Converting Screen Coordinates to World Coordinates

Yes you’re more clear this time :slight_smile:

From your code it seems as if the geometry of your quad is not important. You don’t use it in the calculation of the world coordinates.

I don’t know if you realized this, but one point on your screen represents an infinite number of points in 3D-Space.
If the method only returns one point, then it can return any point on that ray, unless you specified something like “I want to have the point on the ray in 5 units distance”. Because I don’t see in your code, where you have such an restriction, I can only guess that you were lucky in the cases, where it worked :wink:

oop’s …you are right ,earliar also i was getting only correct x and y axis but not z value…thanks for pointing it out…dont know how i missed this point.
I’ll try now keeping this point in mind…thanks fr the help.

i am stuck with how to get the intersection point of the ray with the shape3D object i am able to see whether the ray intersect or not but how to get the intersection Point.
i am using…my code for this


			 Point3f center =new Point3f();
			 Vector3f forward =new Vector3f();
                       canvas.createPickRay(x,y,center,forward);
		       BoundingSphere boundingSphere= node.getVworldBounds();	       
		       boolean isIntersection =boundingSphere.intersect(center,forward);

but how to get the intersection point

that’s called picking and there’s loads of code here in these forums about the topic. try a search

now i am able to get the intersection point … :wink: used your code and tweaked according to my requirement…


                                                 Point3f center = new Point3f();
						Vector3f d = new Vector3f();
						canvas.createPickRay(mouseClickPos_X,mouseClickPos_Y, center, d);

						PickResult r = new PickResult((Shape3D) selectedNode, 0);
                                                
						QuadIntersection t = new QuadIntersection();
						Geometry geo = r.getGeom();


						r.transform(center);
						r.transform(d);

						Vector3f pos1 = new Vector3f();
						Vector3f pos2 = new Vector3f();
						Vector3f pos3 = new Vector3f();
						Vector3f pos4 = new Vector3f();
						geo.getVertex(0, pos1);
						geo.getVertex(1, pos2);
						geo.getVertex(2, pos3);
						geo.getVertex(3, pos4);
						t.set(pos1, pos2, pos3, pos4);
						float closestIntersect = Float.POSITIVE_INFINITY;
						float f = t.test(center, d, closestIntersect);


now i am getting correct X,Y,Z values , even on Translation and Rotation about Z axis ,on clinking on vertices i am getting thier correct values…but when i apply rotation about X and Y axis corresponding x and y values are coming wrong…
In my project getting exact co-ordinates is very important …one more thing…if one of the cube face is at an angle to my view direction and on click of that face i need to change my view to be normal to that face…that is that face is facing the view direction …how to go about it…
thanks for the help … :slight_smile:

P.S : i am using PARALLEL_PROJECTION