From 6325452591b2a854f82ac913fe4f61e3df2f922d Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Wed, 8 Apr 2020 23:28:11 +0300 Subject: [PATCH] Added vtkCameraAndSelectorAction.setViewDir(Vector3d) Allows setting the camera view direction without changing the focal point. gitlab #118 Change-Id: I33421fb46e05c62892a396203681838131b0b382 --- .../g3d/vtk/swt/vtkCameraAndSelectorAction.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java index a5ea6149..e177834e 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java @@ -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(); + } + } -- 2.47.1