Background: We work with scientific measurements of the brain. After all the data processing is done, we have vertices of the brain surface (and surface faces) and for each vertex, there are 1..n measurements. Assume that each measurement is a float value.
I wrote a small add-on; mostly stealing code from the STL import to transform our data into a Blender mesh which works nicely:
Now, I can't solve how I can attach an attribute to each vertex of the mesh that I can then use in the Attribute node of the Material to create, e.g. a heat-map of the measurement.
I'm not even sure if this is possible, but what I'd like to have is that I can access the measurement value for each vertex. In the past, I used a workaround and used the vertex color to encode the measurement, but this is not optimal.
Would someone know a solution? I attach the creation of the script that creates the mesh, where you can assume that measures
is a list of floats with the same length as points
(the vertices).
def create_and_link_mesh(name: str, faces: typing.List[tuple], points: typing.List[tuple], measures: typing.List):
import bpy
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(points, [], faces)
mesh.validate(clean_customdata=False, verbose=True)
mesh.calc_normals()
mesh.use_auto_smooth = True
mesh.update()
obj = bpy.data.objects.new(name, mesh)
bpy.context.collection.objects.link(obj)
bpy.context.view_layer.objects.active = obj
obj.select_set(True)