Fast 3D point cloud animation

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/ 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?

Hello,

Try using vtkOpenGLSphereMapper (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

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?

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). 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) 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.