Controlling the Camera
Vapor provides several functions to control the camera position and direction. Here are a few examples.
import example_utils
from vapor import session, renderer, dataset, camera
ses = session.Session()
data = example_utils.OpenExampleDataset(ses)
ren = data.NewRenderer(renderer.VolumeIsoRenderer)
ren.SetIsoValues([-0.10, 0.2])
# Show 3D orientation arrows.
ses.GetSceneAnnotations().SetAxisArrowEnabled(True)
Warning: sysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" not found (ignoring for now).
Vapor 3.9.3
Python 3.9.19 (/opt/anaconda3/envs/vapor)
OpenGL 4.1 Metal - 83.1
cam = ses.GetCamera()
View All
help(cam.ViewAll)
cam.ViewAll()
ses.Show()
Help on method ViewAll in module vapor.camera:
ViewAll() method of vapor.camera.Camera instance
Places the camera above the dataset looking down so that it is visible in its entirety.
This is the default view when opening a new dataset.
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 2 GLD_TEXTURE_INDEX_3D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
Align View
help(cam.AlignView)
cam.AlignView("-X")
ses.Show()
Help on method AlignView in module vapor.camera:
AlignView(axis: str) method of vapor.camera.Camera instance
Align camera looking down an axis
Axis format: [+-][XYZ]
Zoom
help(cam.Zoom)
cam.Zoom(-0.4)
ses.Show()
Help on method Zoom in module vapor.camera:
Zoom(fractionOfDistanceToTarget: float) method of vapor.camera.Camera instance
Moves the camera a fractionOfDistanceToTarget with positive zooming in and negative zooming out.
Look At
help(cam.LookAt)
cam.LookAt((32, -100, 100), ren.GetTransform().GetOrigin())
ses.Show()
Help on method LookAt in module vapor.camera:
LookAt(camera_position: tuple[float, float, float], target: tuple[float, float, float], up: tuple[float, float, float] = (0, 0, 1)) method of vapor.camera.Camera instance
Moves the camera to camera_position facing target. up can be used to adjust the camera roll.