[vtk-developers] Passive stereo visualization with legacy graphics card

g_luigi at fastwebnet.it g_luigi at fastwebnet.it
Wed Dec 6 11:42:31 EST 2006


Hi, thx for the answer but with your solution i cannot rotate the actors 
keepeng the stereo view. I haven't found a solution to set both cameras 
concordly to the stereo view...

Any idea?


Hi Valeria.
> I need a double-wide render window where in a half there is the left 
> eye view and in the other half there is the right eye view.
I believe you can achieve what you are trying to do by simply using two 
renderers in the same render window, and offsetting the two cameras accordingly 
to where you want the left and the right eye to be in your scene.  Here's a 
simple Python script that does what you
describe:

import vtk

renWin = vtk.vtkRenderWindow()

renL = vtk.vtkRenderer() # Left eye renderer.
renL.SetViewport(0, 0, 0.5, 1)
renL.SetBackground(1, 0, 0)
renL.GetActiveCamera().SetPosition(-1, 0, 5) # Exagerated offset.
renWin.AddRenderer(renL)
renR = vtk.vtkRenderer() # Right eye renderer.
renR.SetViewport(0.5, 0, 1, 1)
renR.SetBackground(0, 0, 1)
renR.GetActiveCamera().SetPosition(1, 0, 5) # Exagerated offset.
renWin.AddRenderer(renR)

cs = vtk.vtkConeSource()
cm = vtk.vtkPolyDataMapper()
cm.SetInputConnection(cs.GetOutputPort())
ca = vtk.vtkActor()
ca.SetMapper(cm)

renL.AddViewProp(ca)
renR.AddViewProp(ca)

renL.ResetCameraClippingRange()
renR.ResetCameraClippingRange()

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
iren.Start()

If you run this, you will see two renderers in one window, each taking up one 
horizontal half of the window.  I changed the background colors to exemplify 
the two renderers.  Each renderer shows the same prop (a cone), but each 
renderer's camera has been moved (one to the left and one to the right), so 
that they show the cone from two different points of view.  I hope this helps.

One note: the two renderers do act independently when it comes to the render 
window interactor.  I don't know if it is possible to set the interactor and/or 
the renderers such that the events on one renderer are replicated onto the 
other.

With kind regards,

Michael




More information about the vtk-developers mailing list