I maintain physicalWidth and physicalHeight as the actual width and height of the canvas on the screen for accurate image scale. Any values for physicalWidth and physicalHeight should work, providing the aspect ratio is preserved.

I know this is a long time after, but if anyone is still interested I've done excatly what the inital poser wanted, but in c++. I don't know enough about Xith3D to know if this is even doable here., but here is the code:

shochu you must have done this ..how you solved this problem ?so what is the right way to go about this.....it would be of great help if somebody has a code snippet for this...........thanks in advance

If i have to query the state machine than in xith how to go about it...

I am able to convert the Screen Coordinates to world Coordinates by using glu.gluUnProject in display of CanvasPeerImpl.java , to get the modelview matrix i am using shape.getLocalToVworld() . currently if i translate my objects its giving me correct coordinates ex: if i draw a cube ( vertex 1=0,0,0 vertex 2=1,0,0 vertex 3=1,1,0 vertex 4=0,1,0 ) and clicks on vertex 2 it return co-ordinates (1,0,0), Now if i translate this cube on screen and again clicks on vertex 2 i am getting correct co-ordinates that is (1,0,0). the problem comes if i rotate this cube about X or Y axis and than clicks vertex 2 now the co-ordinates i am getting are something junk. Strangely if i rotate about Z axis this problem is not coming.So only on rotation about X and Y axis i am not able to map my Screen Co-ordinates to World Co-ord.

I am able to convert the Screen Coordinates to world Coordinates by using glu.gluUnProject in display of CanvasPeerImpl.java , to get the modelview matrix i am using shape.getLocalToVworld() . currently if i translate my objects its giving me correct coordinates ex: if i draw a cube ( vertex 1=0,0,0 vertex 2=1,0,0 vertex 3=1,1,0 vertex 4=0,1,0 )

That's not a cube, thats a Square.

Quote

and clicks on vertex 2 it return co-ordinates (1,0,0), Now if i translate this cube on screen and again clicks on vertex 2 i am getting correct co-ordinates that is (1,0,0). the problem comes if i rotate this cube about X or Y axis and than clicks vertex 2 now the co-ordinates i am getting are something junk.

What are those coordinates?How do you translate the cube?

Quote

Strangely if i rotate about Z axis this problem is not coming.So only on rotation about X and Y axis i am not able to map my Screen Co-ordinates to World Co-ord.

I don't know what glu.gluUnProject does. Does it perform a pick - or what?

Hence i get the world co-ordinates of the mouse in worldX,,worldY,worldZ,.

4) I am not using createPickray as my requirement is such that even if i translate or rotate the square ,on Clicking at vertices of square i should get the same values that is for vertex 2 it should always be (1,0,0).This means i have to take into account ModelView matrix of the shape which is been moved or rotated so i have used GluUnproject.

3) Now to translate this square i am translating the TransformGroup which contain this square , or to rotate it a apply rotation to the TransformGroup.

4) Now if i rotate my Square about Z axis say by 30 deg clockwise and now clicks any vertex it gives me coorect values, as while applying rotation its modelview matrix gets updated so on using gluUnproj its able to map to correct values .

5) But when i apply rotation in X and y direction i am getting wrong values.

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

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

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 ...

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org