0 votes

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 = MeshDataTool.new()
    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.

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.