[vtkusers] 3D monitors

Hal Canary hal at cs.unc.edu
Wed May 16 17:10:26 EDT 2012


On 05/16/2012 02:17 PM, Kishore Mosaliganti wrote:
> Hi all,
>
> Is there a "Hello World" program for stereo rendering available
> somewhere? Do you guys mind sharing this code if you have it.
>
> Thanks,
> Kishore

Here it is in Python:

#!/usr/bin/env python
import vtk

StereoMode = True

camera = vtk.vtkCamera()
camera.SetPosition([5.0, 4.0, 2.0])
camera.SetFocalPoint(0.0, 0.0, 0.0)
camera.SetViewUp(0.0, 1.0, 0.0)
camera.SetViewAngle(30)
renderer = vtk.vtkRenderer()
renderer.SetActiveCamera(camera)
cubeSource = vtk.vtkCubeSource()
dataSetMapper = vtk.vtkDataSetMapper()
dataSetMapper.SetInput(cubeSource.GetOutput())
actor = vtk.vtkActor()
actor.SetMapper(dataSetMapper)
renderer.AddActor(actor)
renderWindow = vtk.vtkRenderWindow()
renderWindow.FullScreenOn()
if StereoMode:
	renderWindow.StereoCapableWindowOn();
	renderWindow.SetStereoTypeToCrystalEyes()
	renderWindow.StereoRenderOn()
renderWindow.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renderWindow)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
renderWindow.Render()
iren.Start()
################################

Caveats:
  * You need the VTK libraries compiled with the vtk Python module.
  * That module needs to be in your PYTHONPATH.
  * You need to figure out the right stereo mode.

-- 
Hal Canary



More information about the vtkusers mailing list