Given .obj, .mat, .jpg → create voxel
https://github.com/IvanNik17/python-3d-analysis-libraries
extracting a mesh’s texture color information and giving it as colors to the voxels representation.
extract the texture information and map it as color information to each vertex of the mesh
name_of_the_imported_mesh.visual.to_color().vertex_colors
create a voxel grid from the mesh
name_of_the_imported_mesh.voxelized().hollow()
calculate the distance between each vertex of the mesh and the already created voxel representation points.
trimesh.proximity.ProximityQuery(name_of_the_mesh).vertex(voxel_grid_name.points)
go through each point, extract the color of the closest mesh vertex, and map it into a color array of size (X, Y, Z, 4), where X, Y, and Z are the sizes of the generated voxel grid and 3 is the R, G, B, and A components of the color.
makes the voxel grid into a Trimesh mesh object with voxel/box colors equal to the initial mesh ones
voxel_grid_name.as_boxes(colors = mapped_color_array)