PickRay and Camera questions...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PickRay and Camera questions...

ThomasR
Hi,

Camera.getPickRay() doesn't return results consistent with a new com.ardor3d.framework.Canvas after resizing the window, unless I manually resize the Camera on each componentResized event. Is this correct, or is there a better way. You can see this issue resizing the window in the ShapesExample.


How can I adjust the Camera so that aspect ratio of the scene is not altered when the user resizes the window. Unless a translations is applied to the model, the center of the window should remain aligned the the center of the world coordinate system. I tried playing with camera.resize() but I don't get the results I expect and pickRay problem above manifests itself. Does the viewport or frustum have to be adjusted?


To translate the model against mouse motion, I scale screen pixel changes to world coordinate changes at the world coordinate origin. But to do this using Camera facilities I need the normalized depth at the w.c. origin so I can use
Camera.getWorldCoordinates. My solution is to build a function zDepth -> w.c. Z at the center of the window and
interpolate. This works well, but would have to be updated anytime the camera is changed. Can you suggest a better way
using what Jogamp Ardor3D already has? Any suggestion greatly appreciated. I know I could work the model to view
tranfpormation process backward, but there must be a better way.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: PickRay and Camera questions...

gouessej
Administrator
Hey

I think that there is some source code commented somewhere doing what you seem to expect. In theory, you can use several cameras with a single canvas and you can use the same camera with several canvases, that's why a camera isn't strictly bound to a canvas and it's up to you to update the camera used with a particular canvas.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: PickRay and Camera questions...

ThomasR
Thanks for your help!

gouessej wrote
I think that there is some source code commented somewhere doing what you seem to expect.
I'll dig around, but definitely the examples dealing with PickRay do not handle window resizing properly.
 
gouessej wrote
In theory, you can use several cameras with a single canvas and you can use the same camera with several canvases, that's why a camera isn't strictly bound to a canvas and it's up to you to update the camera used with a particular canvas.
Okay, that makes sense but more flexibility demands more intimate knowledge of internal mechanisms and w/o documentation I'm forced to examine the code and post questions to a list of experts who hopefully have already tackled the problem. I really appreciate the insight you've provide thus far, how would you approach this? Could you point me to source code from one of your projects?

Tom
Reply | Threaded
Open this post in threaded view
|

Re: PickRay and Camera questions...

ThomasR
Hi,

To anyone interested:

I found Camera.setFrustumPerspective() to handle to update the Camera. I hope it's okay to call from the EDT via
componentResized() - I have no idea.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: PickRay and Camera questions...

gouessej
Administrator
Yes it's okay. There are several methods to update the camera from the projection and inversely.
Julien Gouesse | Personal blog | Website