We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am developing a genomic visualization package using Processing and Proscene - I am blown away by the power of both of these pieces of software!!! Kudos to the developers for making it possible for us to implement such sophisticated functionality with so little effort!!!!
I am trying to make it possible to zoom,pan, or rotate a 3-D model of a chromosome using the standard mouse techniques AS WELL AS allow the user to enter (either with sliders or textfields) values that will serve the same function. To do this, I have to report the current state of the camera as he moves/drags the mouse AND react to values that he enters thru the gui. Here is what I have done so far:
To allow panning I allow the user to set the world coordinate he would like to see at the center of the window. I take the value he enters and do: camera.setSceneCenter(value); camera.centerScene(); which works fine. But I cannot figure out how to calculate and report the world coordinate at the center of the window when the user uses the mouse to move the camera. This is of course essential to report to the user by updating the gui fields as he moves around with the mouse.
For zooming, the reverse applies - when the user zooms with the mouse, I can report the value to the user by calling camera.distanceToSceneCenter(). But when the user types in a distance value in the gui, I don't know how to move the camera to the specified distance from the scene center. Is there a function or sequence of steps for that?
For rotation, I report the 3 Euler angles (pitch, yaw, and roll) based on the current orientation of the camera - by calling camera.orientation().eulerAngles. But I don't know how to do the reverse - i.e., given angles that the user has entered thru the gui, how do I rotate the camera to achieve what he wants?
Would appreciate any help on these topics. Thanks!
Comments
Hi,
nice new forum ;) Almost missed this one.
Thanks for your kind words :)
So camera().position() or camera().at() didn't make it? Otherwise, notice that screen to frame transformations are performed by camera().unprojectedCoordinatesOf().
Do you mean to achieve a distance from the world origin keeping the current camera orientation, right? That seems to require two steps: a. Calculate the world point where you want to move your camera to; and, b. Move the camera there keeping the up and viewDirection vectors. See Camera.setPosition(), camera.setUpVector(), and camera.setViewDirection()
As for the angles, you can orient the camera with Quaterion.fromEulerAngles(Vec angles).
Hi Jean-Pierre! Thanks to your help, I have managed to solve all the problems I posed to you before. Now I am seeing some weird behaviour in Proscene zooming. I have a window with 6 separate scenes. When I zoom in on one of them, strange things happen when the distance to the scene center gets less than 1000 pixels. I have a .doc file with 2 screenshots - before and after. How can I send it to you? This strange behaviour happens only on some combinations of Java and OpenGL versions - in the .doc file, I have listed the combinations that work. Please let me know how I can get this file to you - since I don't see how to attach it in this post. Thanks!