trimesh
trimesh copied to clipboard
load a obj file with vertex color
I have a question about how to read and write an obj file with vertex colors? using trimesh.load('result.obj') can only return the vertex without color. How can I read the color as well and after I apply some transformation, how can I save the obj with color too?
Hello @Holmes-Alan,
Trimesh loads the visual information (vertex colors, material properties, textures) in a Visuals
object accessible via your_mesh.visual
, see https://trimsh.org/trimesh.visual.html.
If your obj has vertex colors (but no textures), your_mesh.visual
should be of type ColorVisuals
and your_mesh.visual.vertex_colors
should be an array (n, 4) uint8 representing the color of each vertex.
Hi @Kiord , I'm trying to load colors from a COFF file and an example row in it is: 0.0487114 -0.456213 0.216446 89 71 57 255
. The first three are xyz and I believe the last four elements are the color for the vertex. I also used open3d and it returns true
with the has_vertex_colors
method. But when I load the color with trimesh.visual.vertex_colors
, it always give me an array with [102 102 102 255] in all rows. I'm wondering how can I get it's vertex colors using Trimesh?
Thank you!
https://trimsh.org/trimesh.visual.html
Hi! Could you please explain how do you load a mesh (i.e., an .obj file) into Visuals object using trimesh?