# 3DView Model Animation (Fade-in, Fade-out)

**URL:** <https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367>\
**Category:** Support\
**Created:** [June 28, 2021, 7:07am UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367 "2021-06-28T07:07:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)\
**Post date:** [June 28, 2021, 7:07am UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/1 "2021-06-28T07:07:37Z")

</div>

I have 2 models that are aligned. I would like to visually show them using an animation that fades-in the source model, while simultaneously fading out the target-model, say within a 1-second timeframe, then do vice-versa. This way, the difference between the 2 models can be readily visualized.

How can I achieve this programatically?

I know that I can alter the opacity using the following piece of code:  
model1.GetDisplayNode().SetOpacity(0)  
model2.GetDisplayNode().SetOpacity(1)

but I would like to animate the fade-in and fade-out process within a specified timeframe for a specified duration.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 28, 2021, 12:16pm UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/2 "2021-06-28T12:16:55Z")

</div>

You can set up a little animation loop using QTimer, something like [this](https://github.com/Slicer/LandmarkRegistration/blob/master/RegistrationLib/Visualization.py#L146-L161).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 28, 2021, 1:08pm UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/3 "2021-06-28T13:08:06Z")

</div>

It would be great if you could post here a video of the result that you get.

Usually we compare models in slice views (showing slice intersections with different colors) and/or by coloring the surfaces by distance (computed by ModelToModelDistance extension).

---

<div class="post-metadata">

**Author:** ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)\
**Post date:** [June 28, 2021, 1:10pm UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/4 "2021-06-28T13:10:54Z")

</div>

Yes, will do Prof Andras. I think the colour map is great - however because it is a 2D representation it may be limited in its visual representation. I thought the fade-in and fade-out would be good to show the visualization in 3D. I will post the video in a moment.

---

<div class="post-metadata">

**Author:** ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)\
**Post date:** [June 28, 2021, 1:14pm UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/5 "2021-06-28T13:14:10Z")

</div>

Video here (wireframe representation). Let me know what you guys think.

> **[screen\_recording.mov (video)](https://drive.google.com/file/d/1Yvmh4EAfU23K5nSycF7xJM7Kvp14TuF3/view?usp=sharing)**
>
> Google Drive file.

Any way I can slow down the fade-in and fade-out? I’m happy with everything else.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 28, 2021, 1:56pm UTC](https://discourse.slicer.org/t/3dview-model-animation-fade-in-fade-out/18367/6 "2021-06-28T13:56:44Z")

</div>

You can change the timer interval and/or the opacity change step size to make the fading slower/faster.
