Skip to content

problems importing obj from kenney.nl with colors/textures #1

@horstjens

Description

@horstjens

(see also posting in vpython mailing list https://groups.google.com/g/vpython-users/c/qokOrlyj2-c/m/Xtv4JJuUAgAJ )

The demo python script to import the spinning cubes into vpython works fine,
however when I try to import assets from kenney.nl (obj and mtl files) the program complains
( i try to import the "tree_small.obj" and "tree_small.mtl" files from https://www.kenney.nl/assets/city-kit-suburban )

ine 48, in obj_to_triangles
curtexture = str(material.texture._path)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_path'

After I changed the offending code line into:

if material.texture is not None: 
      curtexture = str(material.texture._path)

the import works, but I only get snow-white 3d objects, without any textures or colors.
How can I import obj and mtl files correctly so that i get a colored object in vpython?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions