OSPRay colouring materials by scalar

Hi Dave,

This is how I create the dataset (particle positions at many times)

# n_p * n_t, 3
pcoords = npvtk.numpy_to_vtk(xyz[:,:,:].reshape(-1,3), deep=True, array_type=vtk.VTK_FLOAT)

self.points = vtk.vtkPoints()
self.points.SetData(pcoords)

# n_p * n_t
q = npvtk.numpy_to_vtk(np.asarray(self.particles.q[0:n_p,:]).ravel(), deep=True, array_type=vtk.VTK_FLOAT)
q.SetName('q')

vtk_points.poly = vtk.vtkPolyData()
vtk_points.poly.SetPoints(self.points)
vtk_points.poly.GetPointData().AddArray(q)
vtk_points.poly.GetPointData().SetActiveScalars('q')

# Set connectivity data per particle
lines = vtk.vtkCellArray()
# See https://vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/PolyLine
for i in range(n_p):
  lines.InsertNextCell(n_t, range(n_t*i, n_t*i+n_t))
vtk_points.poly.SetLines(lines)

vtk_points.lut = vtk_lut.W_lut() #as in first post on discourse

tube = vtk.vtkTubeFilter()
tube.SetInputData(vtk_points.poly)
tube.SetNumberOfSides(6)
tube.SetVaryRadiusToVaryRadiusOff()
tube.SetRadius(0.015)

vtk_points.mapper = vtk.vtkPolyDataMapper()
vtk_points.mapper.SetInputConnection(tube.GetOutputPort())
vtk_points.mapper.ScalarVisibilityOn()
vtk_points.mapper.SetScalarRange(vtk_points.poly.GetPointData().GetArray('q').GetRange())
vtk_points.mapper.SetLookupTable(vtk_points.lut)


vtk_points.actor = vtk.vtkActor() 
vtk_points.actor.SetMapper(vtk_points.mapper)
#vtk_points.actor.GetProperty().SetMaterialName("Value Indexed")
vtk_points.actor.GetProperty().SetMaterialName("OBJMaterial")

vtk_points.colorbar = vtk_color_bar()
vtk_points.colorbar.SetLookupTable(vtk_points.lut)
vtk_points.colorbar.SetTitle('q')
vtk_points.colorbar.SetPosition(0.05, 0.1)

return vtk_points