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 types
|
||||||
|
import os
|
||||||
|
|
||||||
class WFObj(object):
|
class WFObj(object):
|
||||||
def __init__(self, source, fileloader=None):
|
def __init__(self, source, fileloader=None):
|
||||||
@ -10,6 +11,7 @@ class WFObj(object):
|
|||||||
self.faces = {}
|
self.faces = {}
|
||||||
self.materials = {}
|
self.materials = {}
|
||||||
if type(source) == types.StringType:
|
if type(source) == types.StringType:
|
||||||
|
self.source_path = source
|
||||||
if self.fileloader is not None:
|
if self.fileloader is not None:
|
||||||
fh = self.fileloader(source)
|
fh = self.fileloader(source)
|
||||||
self.load(fh)
|
self.load(fh)
|
||||||
@ -18,6 +20,7 @@ class WFObj(object):
|
|||||||
self.load(fh)
|
self.load(fh)
|
||||||
fh.close()
|
fh.close()
|
||||||
else:
|
else:
|
||||||
|
self.source_path = ''
|
||||||
self.load(source)
|
self.load(source)
|
||||||
|
|
||||||
def load(self, fh):
|
def load(self, fh):
|
||||||
@ -106,6 +109,9 @@ class WFObj(object):
|
|||||||
self.shininess = 50
|
self.shininess = 50
|
||||||
|
|
||||||
def load_material_library(self, name):
|
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:
|
if self.fileloader is not None:
|
||||||
fh = self.fileloader(name)
|
fh = self.fileloader(name)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user