[vtkusers] Shadow in vtkActor
Paulo Henrique Junqueira Amorim
paulojamorim at gmail.com
Thu Mar 31 20:26:58 EDT 2011
Hi,
With the code below, i'm projecting the shadow from cone in the cube. But
does not work, what am I doing wrong?
Regards,
Paulo
The code:
import vtk
ren = vtk.vtkRenderer()
ren.SetBackground(0.1, 0.1, 0.4)
cube = vtk.vtkCubeSource()
cube.SetXLength(100)
cube.SetYLength(100)
cube.SetZLength(100)
cube_mapper = vtk.vtkPolyDataMapper()
cube_mapper.SetInput(cube.GetOutput())
cube_actor = vtk.vtkActor()
cube_actor.SetMapper(cube_mapper)
prop = cube_actor.GetProperty()
prop.ShadingOn()
ren.AddActor(cube_actor)
ren.ResetCamera()
cam = ren.GetActiveCamera()
cam.GetPosition()
cam.GetFocalPoint()
cilynder = vtk.vtkCylinderSource()
cilynder.SetRadius(5)
cilynder.SetCenter(0, 0, 0)
cilynder.SetHeight(600)
cilynder_mapper = vtk.vtkPolyDataMapper()
cilynder_mapper.SetInput(cilynder.GetOutput())
cilynder_actor = vtk.vtkActor()
cilynder_actor.SetMapper(cilynder_mapper)
cilynder_actor.SetPosition(cube_actor.GetPosition()[0],
cube_actor.GetPosition()[1], cube_actor.GetPosition()[2] + 200)
cilynder_actor.GetProperty().SetColor(0, 0, 1)
ren.AddActor(cilynder_actor)
ren_win = vtk.vtkRenderWindow()
ren_win.AddRenderer(ren)
ren_win.SetSize(800, 600)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(ren_win)
interactor.Initialize()
interactor.Render()
light = ren.GetLights().GetItemAsObject(0)
light.SetLightTypeToSceneLight()
light.SetConeAngle(180)
light.SetPosition(cilynder_actor.GetPosition()[0],
cilynder_actor.GetPosition()[1], cilynder_actor.GetPosition()[2] + 200)
ren.AddLight(light)
interactor.Render()
interactor.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110331/33e306ef/attachment.htm>
More information about the vtkusers
mailing list