What is Mesh.ArrayType?

I know that Mesh.ArrayType is an enum, but what is it used for, and can I get/set mesh’s information through some function?

I want to change mesh’s vertex color, not during runtime via shader, but in mesh info in scene file.
Looking through Mesh documentation, I found Mesh.ARRAY_COLOR (Description: PackedColorArray of vertex colors). However, I could not find a method that would accept Mesh.ArrayType as a parameter, not in Mesh class, not in MeshInstance3D class. Are those just constants for users to use if they want to extend functionality?

The add_surface_from_arrays description and the code snippet on the Array Mesh page might help explain things. Mesh.ArrayType is basically just the type of the enum that holds the various array indices.

I think the typical workflow is to vertex paint in an external program and then import the model in Godot. If you want to change them from a script, you’d need to create the mesh with an ArrayMesh.

1 Like

To edit a Mesh you can use the MeshDataTool More info Using the MeshDataTool — Godot Engine (stable) documentation in English

1 Like

These constants are (usually) to determine wether an imported asset does have the relevant data. While you can definitely construct these arrays at runtime or in tool script, it’s much easier to just use blender or whatever 3D modeling software you use to make these arrays, then import them.
These constants correspond to the arrays GPU shaders can understand as builtin, like, GLSL specifies a default input for vertex color as well as vertex coordinates and indices. You can have data in a vertex array (aka attribute) that does not correspond to these constants, but you have to specify it as an input explicitly in the shader code.

Basically, you don’t need to mess with it unless you are building vertex data at runtime or have made some fancy model with extra data arrays. Just use blender.

1 Like

Thanks for everyone in this thread, using MeshDataTool was exactly what I needed.

Reason why I had to do this in-engine and not in “modeling app”, is because I wanted to generate several 3D tiles from 1 mesh, with differ vertex colors according to tile type (corner, corridor, 3-way, | which way its rotated). Basically a plugin that helps me to generate GridMap from one model.

1 Like

Here’s the result (currently prototype) :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.