I am trying to extract the colors for each vertex of the object file that I downloaded from https://www.turbosquid.com/3d-models/3d-s-chef-knife-model-1387505. However, the code below only saves the coordinates of each vertex and their faces in a json file without the color. How using pywavefront can I extract the colors of each vertex ?
import json
import numpy as np
from pywavefront import Wavefront
object_names = ["./objfiles/knife/knife"]
for object_name in object_names:
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
data = {"faces":faces, "vertices":vertices}
with open(object_name+".json", 'w') as fp:
json.dump(data, fp)