Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get the vertices, faces and texturecoord from the Wavefront object #129

Open
nhanminhnhat1998 opened this issue Feb 16, 2021 · 1 comment

Comments

@nhanminhnhat1998
Copy link

Hello everyone,

I am trying to use your library to open the .obj with the .mtl as the texture file

here is my attempt. I could not find a way to get the faces out of it :((

import pywavefront
import logging

pywavefront.configure_logging(
    logging.DEBUG,
    formatter=logging.Formatter('%(name)s-%(levelname)s: %(message)s')
)

file_name = '/home/duma/Documents/RTT_stuffs/camera_calibration/3D_model/scene_mesh_textured.obj'
waveFrontObj = pywavefront.Wavefront(file_name, strict=True, encoding="iso-8859-1", parse=False,collect_faces=True)
waveFrontObj.parse()  # Explicit call to parse() needed when parse=False

for name, material in waveFrontObj.materials.items():
    print("#### Name: ",name)
    temp = vars(material)
    for item in temp:
        if item== "vertices" :
            print("vertices : ") 
            continue
        if item=="texture": print("texture.image : ",type(temp[item].path),temp[item].path)
        print(item, ':', temp[item])
        # print(item, ':')
    print("----------------------")

Thank you for your help

@einarf
Copy link
Member

einarf commented Feb 18, 2021

I'll try to remember to include some info in readme about this. Meanwhile see : #87 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants