[vtkusers] Adding two lightsources to a renderer

Bill Lorensen bill.lorensen at gmail.com
Thu Sep 7 12:37:21 EDT 2017


Ken,

Can you send me the code? I'll make a VTKExample...

On Thu, Sep 7, 2017 at 12:27 PM, Ken Martin <ken.martin at kitware.com> wrote:

> I just tested this and it seems to work on master. This is the image I
> get. Maybe this is an issue that has been fixed since 8.0 was cut?
>
>
>
> [image: Inline image 1]
>
> On Wed, Sep 6, 2017 at 2:17 PM, Oliver Natt <onatt at gmx.de> wrote:
>
>> Dear vtkusers,
>>
>> I encountered a weird problem when using more than one positional light
>> source in vtk. I am pretty sure that it worked with vtk 7.1 but it stopped
>> working with vtk 8.0.0 and 8.0.1. An example in python is given below. The
>> scene contains a plane which should be illuminated by two spot lights.
>> However, only one spotlight is rendered. It seems that this is always the
>> first spotlight that is added to the renderer. Is there any workaround for
>> this problem?
>>
>> Many thanks
>> Oliver
>>
>>
>> import vtk
>> # create a rendering window and rendererrenderer = vtk.vtkRenderer()
>> render_window = vtk.vtkRenderWindow()
>> render_window.AddRenderer(renderer)
>> # create a renderwindowinteractoriren = vtk.vtkRenderWindowInteractor()
>> iren.SetRenderWindow(render_window)
>> # create a plane and add it to the rendererrectangle_source = vtk.vtkPlaneSource()
>> rectangle_source.SetOrigin(-5.0, 0.0, 5.0)
>> rectangle_source.SetPoint1(5.0, 0.0, 5.0)
>> rectangle_source.SetPoint2(-5.0, 0.0, -5.0)
>> rectangle_source.SetResolution(100, 100)
>> mapper = vtk.vtkPolyDataMapper()
>> mapper.SetInputConnection(rectangle_source.GetOutputPort())
>> actor = vtk.vtkActor()
>> actor.SetMapper(mapper)
>> renderer.AddActor(actor)
>> # set camera viewrenderer.ResetCamera()
>> camera = renderer.GetActiveCamera()
>> camera.Azimuth(40.0)
>> camera.Elevation(30.0)
>> # create a green lightlight_green = vtk.vtkLight()
>> light_green.SetPositional(1)
>> light_green.SetPosition(-4.0, 4.0, -1.0)
>> light_green.SetColor(0.0, 1.0, 0.0)
>> light_green.SetIntensity(0.5)
>> # create a pink lighlight_pink = vtk.vtkLight()
>> light_pink.SetPositional(1)
>> light_pink.SetPosition(4.0, 5.0, 1.0)
>> light_pink.SetColor(1.0, 0.0, 1.0)
>> light_pink.SetIntensity(0.6)
>> # add lights to the renderer## This is interesting in vtk 8.0.0 and 8.0.1:# Only the pink light spot is visible. If the two statements are swapped,# only the green light is visible. It seems that always only the first# light can be active.renderer.AddLight(light_pink)
>> renderer.AddLight(light_green)
>> # define a background for better visibilityrenderer.SetBackground(0.2, 0.2, 0.5)
>> renderer.SetBackground2(0.4, 0.4, 1.0)
>> renderer.SetGradientBackground(True)
>> # enable interactoriren.Initialize()
>> render_window.Render()
>> iren.Start()
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Ken Martin PhD
> Distinguished Engineer
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170907/aa6a76da/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 18129 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170907/aa6a76da/attachment.png>


More information about the vtkusers mailing list