0

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)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Kong
  • 2,202
  • 8
  • 28
  • 56

1 Answers1

0

The object file you mentioned does not contain any vertex colors. The .OBJ format is not capable of containing vertex colors as far as I am concerned(unless you write the code for it of course).