<div dir="ltr">Jens,<div><br></div><div>The resetCamera() call is likely causing your problems. It resets the camera so that all visible objects in the renderer are displayed, so it will overwrite the position that you set.</div><div><br></div><div>It's a bit of a mystery to me why the callback that creates a new camera doesn't behave the same as the one that uses the active camera. Perhaps the active camera returned by getActiveCamera() is not the same as the renderer's active camera.</div><div><br></div><div>HTH,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 12:55 PM, Jens Schmidt <span dir="ltr"><<a href="mailto:jens.g.w.schmidt@gmx.de" target="_blank">jens.g.w.schmidt@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Dear Cory,<br>
<br>
thank you for your reply! It took some time to identify the problem
further.<br>
Please find at the very bottom of this mail a test implementation
(java) showing the problem. The code creates a simple view showing
some spheres and two buttons. The first button uses the camera
present, the second one creates a new camera.<br>
They should behave the same, but don't. I think it is the
resetCamera() method. Maybe i use it wrong? The relevant code is in
the selectionListeners for the buttons.<br>
<br>
Best regards<br>
Jens<div><div class="h5"><br>
<br>
<br>
<div>Am 29.07.2015 um 03:48 schrieb Cory
Quammen:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Jens,
<div><br>
</div>
<div>Please remember to "reply-all" so that others on the list
may benefit from or contribute to the conversation.</div>
<div><br>
</div>
<div>Do you have a small code sample that reproduces the issue?
This kind of camera manipulation followed by rendering is done
all the time (see [1], for example), so I'm not sure what is
going on.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Cory</div>
<div><br>
</div>
<div>[1] <a href="http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Tutorial/Step3/Java/Cone3.java;h=91e003825bca66e275c22658019b6c52ef1afb75;hb=HEAD" target="_blank">http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Tutorial/Step3/Java/Cone3.java;h=91e003825bca66e275c22658019b6c52ef1afb75;hb=HEAD</a></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Jul 28, 2015 at 7:42 AM, Jens
Schmidt <span dir="ltr"><<a href="mailto:jens.g.w.schmidt@gmx.de" target="_blank">jens.g.w.schmidt@gmx.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote">Cory,<br>
<br>
thx for your reply! Yep called render each time i changed
the camera. But the only time the camera did what i wanted
was with the new camera object and setActiveCamera.<br>
<br>
Best regards<span><br>
Jens</span>
<div>
<div><br>
<br>
<br>
Am 27.07.2015 um 20:31 schrieb Cory Quammen:<br>
<blockquote class="gmail_quote">
Jens,<br>
<br>
Did you try calling your render window's Render()
member function after<br>
changing the camera properties? Rendering updates are
not performed<br>
automatically when you change just camera properties.
This is actually good<br>
because it prevents too many renderings when you
update more than one<br>
camera property.<br>
<br>
HTH,<br>
Cory<br>
<br>
On Mon, Jul 27, 2015 at 1:46 PM, Jens Schmidt <<a href="mailto:jens.g.w.schmidt@gmx.de" target="_blank">jens.g.w.schmidt@gmx.de</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote">
Hi Everyone!<br>
<br>
VTK rocks, but we knew that allready. ^^ What rocks
less is that the<br>
camera ist not automatically updated when
SetPosition or SetFocalPoint are<br>
called.<br>
Btw i am using the java wrapping with SWT.
VtkAbstractComponent has a<br>
reference to the active camera.<br>
Using that had no effect, as was using the renderers
GetActiveCamera<br>
method.<br>
In fact i have to create a new vtkCamera, modify
that an then pass it to<br>
the renderer as new active camera -> tada change
on the screen.<br>
Did i do something wrong or is that how it is
supposed to work?<br>
<br>
Thank you<br>
Jens<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ
at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div>
</div>
</blockquote>
</div>
<br>
<br>
<div><br>
</div>
-- <br>
<div>Cory Quammen<br>
R&D Engineer<br>
Kitware, Inc.</div>
</div>
</blockquote>
<br>
<br></div></div>
Code below here:<br>
==============<br>
<br>
package CamTest;<br>
<br>
import org.eclipse.swt.SWT;<br>
import org.eclipse.swt.events.SelectionAdapter;<br>
import org.eclipse.swt.events.SelectionEvent;<br>
import org.eclipse.swt.layout.GridData;<br>
import org.eclipse.swt.layout.GridLayout;<br>
import org.eclipse.swt.widgets.Button;<br>
import org.eclipse.swt.widgets.Composite;<br>
import org.eclipse.swt.widgets.Display;<br>
import org.eclipse.swt.widgets.Shell;<br>
import org.vtk.VTKLoader;<br>
<br>
import vtk.vtkActor;<br>
import vtk.vtkCamera;<br>
import vtk.vtkPolyDataMapper;<br>
import vtk.vtkSphereSource;<br>
import vtk.rendering.swt.vtkSwtComponent;<br>
<br>
public class CamTest {<br>
<br>
class vtkView extends vtkSwtComponent {<br>
<br>
public vtkView(Composite parentComposite) {<br>
super(parentComposite);<br>
renderer.SetBackground(0.1, 0.2, 0.4);<br>
renderer.SetBackground2(1, 1, 1);<br>
renderer.SetGradientBackground(true);<br>
vtkSwtComponent.attachOrientationAxes(this);<br>
update();<br>
}<br>
<br>
void setCamera(vtkCamera camera) {<br>
this.camera = camera;<br>
renderer.SetActiveCamera(camera);<br>
}<br>
<br>
void addSpheres(int precision, int numberInX, int numberInY,
int numberInZ) {<br>
vtkSphereSource source = new vtkSphereSource();<br>
source.SetRadius(1.);<br>
source.SetPhiResolution(precision);<br>
source.SetThetaResolution(precision);<br>
<br>
vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>
mapper.SetInputConnection(source.GetOutputPort());<br>
mapper.Update();<br>
<br>
for (int i = 0; i < numberInX; i++) {<br>
for (int j = 0; j < numberInY; j++) {<br>
for (int k = 0; k < numberInZ; k++) {<br>
vtkActor actor = new vtkActor();<br>
actor.SetPosition(4 * i, 4 * j, 4 * k);<br>
actor.SetMapper(mapper);<br>
actor.GetProperty().BackfaceCullingOn();<br>
renderer.AddActor(actor);<br>
}<br>
}<br>
}<br>
update();<br>
resetCamera();<br>
}<br>
}<br>
<br>
private vtkView vtkView;<br>
<br>
private CamTest() {<br>
VTKLoader loader = new VTKLoader();<br>
loader.loadAll();<br>
<br>
Display display = new Display();<br>
Shell shell = new Shell(display);<br>
shell.setText("CamTest");<br>
GridLayout layout = new GridLayout(2, false);<br>
shell.setLayout(layout);<br>
<br>
vtkView = new vtkView(shell);<br>
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true,
2, 1);<br>
data.widthHint = 300;<br>
data.heightHint = 300;<br>
vtkView.getComponent().setLayoutData(data);<br>
<br>
vtkView.addSpheres(10, 10, 10, 10);<br>
<br>
Button isoButton = new Button(shell, SWT.PUSH);<br>
isoButton.setText("ISO VIEW");<br>
isoButton.addSelectionListener(new SelectionAdapter() {<br>
@Override<br>
public void widgetSelected(SelectionEvent e) {<br>
System.out.println("ISO");<br>
vtkCamera camera = vtkView.getActiveCamera();<br>
camera.SetPosition(new double[] { 1., 1., 1. });<br>
camera.SetViewUp(new double[] { 0., 0., 1. });<br>
vtkView.resetCamera();// <-- bad line<br>
vtkView.update();<br>
}<br>
});<br>
<br>
Button resetButton = new Button(shell, SWT.PUSH);<br>
resetButton.setText("RESET VIEW");<br>
resetButton.addSelectionListener(new SelectionAdapter() {<br>
@Override<br>
public void widgetSelected(SelectionEvent e) {<br>
System.out.println("RESET");<br>
vtkCamera newCamera = new vtkCamera();<br>
newCamera.SetPosition(new double[] { 1., 1., 1. });<br>
newCamera.SetViewUp(new double[] { 0., 0., 1. });<br>
vtkView.setCamera(newCamera);<br>
vtkView.resetCamera();<br>
vtkView.update();<br>
}<br>
});<br>
<br>
shell.pack();<br>
shell.open();<br>
<br>
while (!shell.isDisposed()) {<br>
if (!display.readAndDispatch()) {<br>
display.sleep();<br>
}<br>
}<br>
display.dispose();<br>
}<br>
<br>
public static void main(String[] args) {<br>
CamTest camTest = new CamTest();<br>
}<br>
<br>
}<br>
<br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>