Filling a OpenGLVertexBufferObject with a custom DataArray

Hello!

I am trying to provide a custom C++ object to a PolyData by overriding its DataArray. For example, I would like to give a custom DataArray (made of a struct of double) to the PolyData Points.

I have an issue when the OpenGLVertexBufferObject is filled. I would like to use the vtkAppendVBOWorker for my array so I could use the vtkDataArrayAccessor. However, it does not seem possible since the Dispatcher only looks at vtkAOSDataArrayTemplate.

Is there a way to use custom range iteration to fill the vtkOpenGLVertexBufferObject?

Thanks for your help

IIRC, you are looking for vtkPolyDataMapper::MapDataArrayToVertexAttribute.
You will be able to access this array in the shader.

You’re in uncharted territory at the moment – I don’t think anyone has actually tried to use a custom dataarray type in VTK with the default dispatchers yet. But the good news is that there are some CMake hooks that can help you build a version of VTK that does what you want.

Take a look at the documentation here: https://gitlab.kitware.com/vtk/vtk/blob/master/Common/Core/vtkCreateArrayDispatchArrayList.cmake

Those describe how to configure VTK to build with a custom array type in its default dispatch list. I don’t think this has been widely used, so you may run into some rough edges, but hopefully this will help you get a little farther.