[vtkusers] Setting new Camera Position under Java
Christian Pöcher
Poecher at gmx.net
Thu Jun 28 17:33:11 EDT 2001
Hello,
I am looking for help on setting new camera positions. I am developing under
VTK 3.2 and Sun JDK 1.2.2 on a Win2K machine.
I studied some examlpes in TCL on this fine discussion board and
re-implemented them, which worked as expected. I did:
...get the camera
cam = ren.GetActiveCamera();
...set it to an new position and changed the focal point
cam.SetPosition(3.0,3.0,3.0);
cam.SetFocalPoint(0.0,0.0,0.0);
cam.ComputeViewPlaneNormal();
...set a view-up-vector
cam.OrthogonalizeViewUp();
...got the only light in the scenery
lights = ren.GetLights();
lights.InitTraversal();
light = lights.GetNextItem();
...and set it to camera's position and focal point
light.SetPosition(cam.GetPosition());
light.SetFocalPoint(cam.GetFocalPoint());
...then I reset the clipping range
ren.ResetCameraClippingRange();
The problem is that the visuals don't update, altough the coordinates are
set right (I checked it with a System.out.println(...);). Adding a
ren.Render(); changed nothing. But if I did just a little mouse dragging in
the vtkPanel
it updated correctly. That is why I thought of creating a MouseDragged event
by code. But doing so the new camera position was taken only after two or
three clicks
on the button, which triggered the code stated above. Sometimes I also seem
to be "lost
in space", because every rotation or ren.ResetCamera(); doesn't bring me
back to my
geometry.
It is essential for me to see the change after moving to a new camera
position, but a
"sometimes it works and sometimes not" way is even worse, so if you could
help me
figure out what's wrong, I'd really appriciate.
Chris
More information about the vtkusers
mailing list