# Fast 3D point cloud animation

**URL:** https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083
**Category:** Support
**Created:** [November 5, 2021, 2:35pm UTC](https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083 "2021-11-05T14:35:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![brnk](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@brnk](https://discourse.vtk.org/u/brnk)
#### Post date: [November 5, 2021, 2:35pm UTC](https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083/1 "2021-11-05T14:35:30Z")

</div>

I want to visualize a `polyData` object of type `vtkPolyData` as a 3D point cloud and update it in an animation. The size, opacity, and the color of each point should be linked to the magnitude which is set as `polyData->GetPointData()->SetScalars(magnitude)`, where `magnitude` is a `vtkFloatArray`.

I found several examples where the points are converted to a 3D glyph, e.g., a sphere. However, I would prefer something simpler than that, e.g., just a round vertex.

Long story short, I want to adapt the [https://kitware.github.io/vtk-examples/site/Cxx/PolyData/PointSource/](https://PointSource) example such that the vertex is a circle instead of a square, and the size, opacity, and color should be linked to the magnitude.

Is this possible or do I have to use glyphs?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 8, 2021, 2:20pm UTC](https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083/2 "2021-11-08T14:20:15Z")

</div>

Hello,

Try using `vtkOpenGLSphereMapper` ([https://vtk.org/doc/nightly/html/classvtkOpenGLSphereMapper.html](https://vtk.org/doc/nightly/html/classvtkOpenGLSphereMapper.html)) as your mapper instead of the more generic `vtkPolyDataMapper` mapper. It’ll draw your points as fake spheres (not glyphs).

regards,

Paulo

---

<div class="post-metadata">

### Author: ![brnk](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@brnk](https://discourse.vtk.org/u/brnk)
#### Post date: [November 16, 2021, 2:55pm UTC](https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083/3 "2021-11-16T14:55:06Z")

</div>

Thank you, I was looking for something like this. However, I would like to disable the shader on the fake spheres such that each sphere has a single color. Also, is it possible to set the opacity of each individual sphere using an array?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 16, 2021, 7:58pm UTC](https://discourse.vtk.org/t/fast-3d-point-cloud-animation/7083/4 "2021-11-16T19:58:20Z")

</div>

Unfortunately I couldn’t find any examples in the internet. I think you’re better off by reading about the parent class `vtkOpenGLPolyDataMapper` ([https://vtk.org/doc/nightly/html/classvtkOpenGLPolyDataMapper.html](https://vtk.org/doc/nightly/html/classvtkOpenGLPolyDataMapper.html)). I guess you can write a shader for the fake spheres such that opacity (alpha channel) is set from a scalar value present at each point. This example ([GitHub - dmreagan/vtk-shaders: Simple example of using shaders with VTK](https://github.com/dmreagan/vtk-shaders)) introduces you on how to write shaders to use with `vtkOpenGLPolyDataMapper` (parent of `vtkOpenGLSphereMapper`). From there you can experiment by trial and error to achive the effect you want.
