[vtkusers] Animation Conundrum

Bruno da Silva de Oliveira bruno at esss.com.br
Fri Oct 7 13:36:16 EDT 2005


Hmm, that's the idea. The renderer is not shared in the code below; 
they're in the same thread. The timer event is triggered by a windows 
event, like a mouse event for instance.

Can you send a reproductible use case (in Python)?

Mischa Thesberg wrote:

> Are you suggesting a code that is something like this?:
>
>        def myCallback():
>            for i in range(100,260):
>                #time.sleep(0.03)
>                givable = "C:/Conics/1-32-04/9-28-2005 1-32-04 PM-0%d" 
> % i+".jpg"
>                jpgReader.SetFileName(givable)
>                atext.SetInput(jpgReader.GetOutput())
>                renWin.Render()
>
>        ren.AddActor(triangulation)
>        ren.SetBackground(1, 1, 1)
>        renWin.SetSize(350, 350)
>        iren.AddObserver("TimerEvent", myCallback)
>        iren.Initialize()
>        iren.Start()
>        t = threading.Timer(0.1,myCallback) # call animate after 0.1 
> seconds
>        t.start()
>
> when this code runs I get the following error from the prompt
>
> ERROR: In 
> \OCCIviewerSDK\Vtk42\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 22
> 8
> vtkWin32OpenGLRenderWindow (00B290B0): wglMakeCurrent failed in 
> MakeCurrent(), e
> rror: The requested resource is in use.
>
> which seems to me to be a share renderer problem.  Or is my code using 
> the wrong idea?  Thank you for your help btw
>
>
> Bruno da Silva de Oliveira wrote:
>
>> Hi Mischa,
>>
>> Try to use a timer. Connect an observer in the RenderWindowInteractor 
>> listening for the TimerEvent, and in this handler change the texture.
>>
>> HTH,
>>
>> Mischa Thesberg wrote:
>>
>>>    This is the same problem I was having before however I still 
>>> cannot seem to fine a solution to it.  I am simulating the effect of 
>>> projecting a movie onto a cone by creating a cone object in a render 
>>> window (with an interactor) and changing the texture (mapped using 
>>> textureMapToPlane) of the cone about 10 times a second (in other 
>>> words I loop through a series of sequentially named jpeg's).  The 
>>> problem is that while this animation is occuring (which is always) 
>>> the interactor is frozen with an hourglass (or if I put the 
>>> animation in a rudimentary thread the hourglass is gone but I still 
>>> can't interact).  How do I keep the interactor usable as I 
>>> constantly change the texture of the cone.  I think a problem with 
>>> the way I tried to thread has to do with the shared resources 
>>> between the actor changing textures and the interactor.  If someone 
>>> could give me some advice it would be much appreciated.  If 
>>> threading is in fact necessary it would be helpful to have a code 
>>> snippet or a link to an explicit example.  The pertinent part of my 
>>> code is below (I have kept all of the commented out stuff just to 
>>> illustrate the type of stuff I've tried:
>>>
>>>        #def myCallback():
>>>          #  if renWin.GetEventPending():
>>>            #    renWin.SetAbortRender=1
>>>
>>> # Add the actors to the renderer, set the background and size
>>>        ren.AddActor(triangulation)
>>>        ren.SetBackground(1, 1, 1)
>>>        #ren.AddObserver("StartEvent", myCallback)
>>>        renWin.SetSize(350, 350)
>>>        #renWin.FullScreenOn()
>>>        #iren.UpdateSize(700,700)
>>>        #iren.AddObserver("InteractionEvent", myCallback)
>>>        iren.Initialize()
>>>
>>>        #renWin.Render()
>>>        iren.Start()
>>>
>>>        for i in range(100,260):
>>>            time.sleep(0.03)
>>>            #iren.UnRegister(renWin)
>>>            #iren = None
>>>            #iren = vtk.vtkRenderWindowInteractor()
>>>            givable = "C:/Conics/1-32-04/9-28-2005 1-32-04 PM-0%d" % 
>>> i+".jpg"
>>>            jpgReader.SetFileName(givable)
>>>            atext.SetInput(jpgReader.GetOutput())
>>>            #atext.Render(ren)
>>>            #ren.Render()
>>>            renWin.Render()
>>>            #print iren.GetInitialized()
>>>            #iren.SetRenderWindow(renWin)
>>>            #iren.Enable()
>>>            #iren.Initialize()
>>>            #iren.Start()
>>>
>>>
>>> _______________________________________________
>>> This is the private VTK discussion list. Please keep messages 
>>> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>

-- 
Bruno da Silva de Oliveira
bruno at esss.com.br
ESSS - Engineering Simulation and Scientific Software
http://www.esss.com.br




More information about the vtkusers mailing list