]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Added vtkCameraAndSelectorAction.setViewDir(Vector3d) 10/4110/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 8 Apr 2020 20:28:11 +0000 (23:28 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 8 Apr 2020 20:28:41 +0000 (23:28 +0300)
Allows setting the camera view direction without changing the focal
point.

gitlab #118

Change-Id: I33421fb46e05c62892a396203681838131b0b382

org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java

index a5ea614978ee803a6df23c252205ad583f0a1622..e177834ed0ae624ba7a78abc2b100f03b62467a7 100644 (file)
@@ -477,4 +477,17 @@ public class vtkCameraAndSelectorAction extends vtkSwtAction implements ISelecti
                return Math.abs(dx * dir.x) + Math.abs(dy * dir.y) + Math.abs(dz * dir.z);
        }
 
+       public void setViewDir(Vector3d direction) {
+               Vector3d focal = new Vector3d(cam.GetFocalPoint());
+               Vector3d pos = new Vector3d(cam.GetPosition());
+               Vector3d dir = new Vector3d(pos);
+               dir.sub(focal);
+               double distance = dir.length();
+               dir.scaleAdd(distance, direction, focal);
+               cam.SetPosition(dir.x, dir.y, dir.z);
+               focus(focal.x, focal.y, focal.z);
+               //panel.UpdateLight();
+               panel.refresh();
+       }
+
 }