I have not done mesh generation from C++ myself, so it is entirely possible that what I wrote below is wrong, but I looked at the source code for Godot Voxel and I think I have a loose idea of how it works.
Looking at the source code for Godot Voxel, it looks like the code there is using the ArrayMesh class and is passing in an array of arrays with the mesh data.
In the voxel_mesher.cpp class in Godot voxel, it looks like the requirements to use the add_surface_from_arrays
function is passing the primitive type and the arrays with the mesh data.
One thing I am not sure on is what needs to be passed in teh array of arrays containing the mesh data. In the voxel_mesher_blocky.cpp file, on line 70 there is code that clears the mesh array. Looking at that code, it seems the positions
, normals
, uv
, colors
, and indicies
of the mesh are all potentially needed to generate the mesh. However, in the mesh_builder.cpp
file in the DMC meshers folder, only the positions
, normals
, and indices
are part of the array, so I am not totally sure.
According to the documentation for the add_surface_from_arrays
function, only the first array needs to be an array of vertices, with the rest of the arrays (and the data within) being optional.
It might not be a bad idea to ask Zylann, or someone else with mesh creation experience in C++, for some pointers. I'm sure there is a common/known way to create meshes in C++.
Hopefully this helps!
(Side note: Welcome to the forums!)