[vtkusers] animation while renderer responsive

David Gobbi david.gobbi at gmail.com
Wed May 9 10:55:13 EDT 2018


Hi Sam,

There is a simple solution to this if the animation is looped (for example,
if you have 20 polydata and you want to cycle through them).  If this is
the case, then add all of your polydata to the renderer at the same time,
each with its own actor, and use the SetVisibility() method to hide all but
the one that you want to show.

The advantage to doing things this way is that all of the polydata is
loaded onto the GPU up front. During the animation, switching the
visibility on and off is instantaneous.  The visibility switching can be
done in a callback to a TimerEvent (for obvious reasons, it can't be done
in a for() loop, and for less obvious reasons, trying to use multithreading
for this is just asking for trouble).

I've used this method myself for displaying animated cardiac models with
interaction, but I no longer have the code (it was a long time ago).  One
thing that I remember is that in order to ensure that all the polydata were
loaded onto the GPU before the animation started, I did one render at the
beginning with all of the actors visible, but with SwapBuffersOff() so that
this initial rendering was restricted to the back buffer.

 - David



On Wed, May 9, 2018 at 8:09 AM, Sam Raby <rabysam28 at gmail.com> wrote:

> Hello, I have a vtkPolyData that I can display fine. Every half a second
> another vrkplydata comes in, so I need to display the new vtkpolydata
> instead of the old one, and so forth. It is essentially like an animation
> but the incoming vtkploydata are different in size and content, so I cannot
> use the same vtkpolydata object every time.
>
> Is there an example so I see how to approach this? One requirement is that
> as this animation is displayed I need to be able to still interact with the
> scene such as zoom in and out. So it needs to be an unblocking call.
>
> Thanks
> -s
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180509/4c98c99d/attachment.html>


More information about the vtkusers mailing list