Modify vertex attributes at run time.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DQBO

I’m currently trying to modify the vertex attributes of a mesh at run time, more specifically, the color of each vertex. I want it to be done without ImmediateGeomety. How can I do that?

Here is a piece of my code.

var mesh_data =
    var image = color_array.get_data()

    for surface in range(mesh.get_surface_count()):
           mesh_data.create_from_surface(mesh, surface)
           for vertex in range(mesh_data.get_vertex_count()):
                    var UV = mesh_data.get_vertex_uv(vertex)
                    var pixel = UV*image.get_size()
                        image.get_pixel(pixel.x, pixel.y))


The code is supposed to work on a .obj file exported from Magicavoxel, saving the texture color array corresponding pixels in the vertex colors. The colors are not the corresponding ones though and I can’t tell what’s wrong.