PyWavefront icon indicating copy to clipboard operation
PyWavefront copied to clipboard

How do I extract the colors of each vertex after loading the .obj file ?

Open HaziqRazali opened this issue 4 years ago • 1 comments

How do I extract the colors of each vertex after loading the .obj file? I am only able to extract the coordinates of each vertex using the code below. How about the colors of each vertex?

    object = Wavefront(object_name+".obj", create_materials=True, collect_faces=True)

    # collect faces
    faces = []
    for mesh in object.mesh_list:
        faces = faces + mesh.faces
    
    # collect vertices
    vertices = object.vertices

HaziqRazali avatar Feb 19 '21 00:02 HaziqRazali

Colors should be in object.vertices and also interlaved in each material. You will have to look at the vertex format in the last case.

See: https://github.com/pywavefront/PyWavefront/issues/87#issuecomment-464348971

einarf avatar Feb 19 '21 00:02 einarf