1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# -*- coding: utf-8 -*-
# vispy: testskip
# -----------------------------------------------------------------------------
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
"""
Example demonstrating stereo vision in a scene has an anisotropic aspect
ratio. This example can be used to test that the cameras behave
correctly with nested translated/rotated cameras.
NOTE: This example is currently broken!
"""
import numpy as np
from vispy import app, scene, io
# Read volume
vol1 = np.load(io.load_data_file('volume/stent.npz'))['arr_0']
# Prepare canvas
canvas = scene.SceneCanvas(keys='interactive')
canvas.size = 800, 600
canvas.show()
canvas.measure_fps()
# Set up a viewbox to display the image with interactive pan/zoom
# Create two ViewBoxes, place side-by-side
vb1 = scene.widgets.ViewBox(border_color='yellow', parent=canvas.scene)
vb2 = scene.widgets.ViewBox(border_color='blue', parent=canvas.scene)
# This is temporarily needed because fragment clipping method is not yet
# compatible with multiple parenting.
vb1.clip_method = 'viewport'
vb2.clip_method = 'viewport'
scenes = vb1.scene, vb2.scene
#
grid = canvas.central_widget.add_grid()
grid.padding = 6
grid.add_widget(vb1, 0, 0)
grid.add_widget(vb2, 0, 1)
# Create the volume visuals, only one is visible
volume1 = scene.visuals.Volume(vol1, parent=scenes, threshold=0.5)
# Create cameras. The second is a child of the first, thus inheriting
# its transform.
cam1 = scene.cameras.TurntableCamera(parent=scenes, fov=60)
cam2 = scene.cameras.PerspectiveCamera(parent=cam1, fov=60)
#
cam2.transform.translate((+10, 0, 0))
vb1.camera = cam1
vb2.camera = cam2
if __name__ == '__main__':
app.run()
|