Skip to content

MTL reader cannot parse string value property #5

Description

@chongkong

Current implementation assumes every mtl property is either integer, float, or array of float. This prevents the parser from getting texture filename from map_Kd, map_Ks, etc.

elif materials:
if data:
split_data = data.strip().split(' ')
if len(split_data) > 1:
material[prefix] = tuple(float(d) for d in split_data)
else:
try:
material[prefix] = int(data)
except ValueError:
material[prefix] = float(data)

This should be fixed as

 elif materials: 
     if data: 
         split_data = data.strip().split(' ') 
  
         if len(split_data) > 1: 
             material[prefix] = tuple(float(d) for d in split_data) 
         else: 
             try: 
                 material[prefix] = int(data) 
             except ValueError:
                 try:
                     material[prefix] = float(data) 
                 except ValueError:
                     material[prefix] = data  # accept string value

This is also a direct solution to #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions