Hey there,
I’m searching for an idea to label the polygons of my mesh with different multiple labels.
So far I’m using vertex groups, putting all the vertices belonging to polygons that share a label into one vertex group.
But storing that information in vertices is not bidirectional, because as you can see in this Image, all 3 vertices got the information they belong to the yellow and the blue label and in the end the mid polygon is blue and yellow instead of only blue.
Can this be achieved with materials? Afaik there is only one material_index per polygon.
Is it possible to store more than one material to a polygon? (I don’t care which one is displayed as long as I can read it via python)
for material i don’t think it is possible
one material is assign per face but you can have more then one texture
color might be control with texture on the face!
but there is the vertex color
let say for one face each vertex on the face can be assign a vert color
unless you use UV map and change the UV map for each face!
I’ll have a try saving the label information in an uv layer.
It seems to be a float array with 2 items, so each item should hold 64bit => I can store 128bit in each loop.
Maybe polygon_layers. Haven’t used these myself, the following produces a string layer with a value for every poly in the mesh. The layers are saved with the file. I’m “assuming” that the indexes match those of the polygons in the mesh.
An int ( as boolean) layer for each material would be one way to utilise polygon layers to store multiple material indexes per poly.
Yep, the polygon_layer is working nice, since my labels are strings I just write them all in the string layer.
Sadly there’s no vertex_layers, would love to see that added.
Thanks a lot.
Its just a list with the same length as the polygon count in the mesh.
Every list item is associated with a polygon.
So you can store strings, ints or floats to every polygon.
Thats how I’m using it, reduced to an example.
def create_triangle_layer(context):
#save triangle index in the polygon_layers_int
me = context.selected_objects[0]
me.data.polygon_layers_int.new("triangle")
for idx,poly in enumerate(me.data.polygons):
me.data.polygon_layers_int["triangle"].data[idx].value = idx