From 63695755b0c5eed6fd72ebf8e3370dacbf37bdcf Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 15 Jul 2012 18:45:26 -0400 Subject: [PATCH] load material library file relative to object file location --- wfobj.py | 6 ++++++ 1 file changed, 6 insertions(+) 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: