diff --git a/wfobj.py b/wfobj.py index 0c6d878..65e5cdd 100755 --- a/wfobj.py +++ b/wfobj.py @@ -1,5 +1,6 @@ import types +import os class WFObj(object): def __init__(self, source, fileloader=None): @@ -10,6 +11,7 @@ class WFObj(object): self.faces = {} self.materials = {} if type(source) == types.StringType: + self.source_path = source if self.fileloader is not None: fh = self.fileloader(source) self.load(fh) @@ -18,6 +20,7 @@ class WFObj(object): self.load(fh) fh.close() else: + self.source_path = '' self.load(source) def load(self, fh): @@ -106,6 +109,9 @@ class WFObj(object): self.shininess = 50 def load_material_library(self, name): + dn = os.path.dirname(self.source_path) + if dn != '': + name = dn + os.path.sep + name if self.fileloader is not None: fh = self.fileloader(name) else: