load material library file relative to object file location
This commit is contained in:
parent
d00b6a0d4e
commit
63695755b0
6
wfobj.py
6
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user