Fixed optional import, readme

This commit is contained in:
Thomas FORGIONE
2016-12-02 21:37:20 +01:00
parent 9860d90e0b
commit 5da117b42a
4 changed files with 24 additions and 11 deletions

View File

@@ -2,7 +2,6 @@ from ..basemodel import ModelParser, Exporter, Vertex, TexCoord, Normal, FaceVer
from ..mesh import Material, MeshPart
from functools import reduce
import os.path
import PIL.Image
import sys
@@ -89,7 +88,11 @@ class MTLParser:
elif first == 'Ks':
self.current_mtl.Ks = Vertex().from_array(split)
elif first == 'map_Kd':
self.current_mtl.map_Kd = PIL.Image.open(os.path.join(os.path.dirname(self.parent.path), split[0]))
try:
import PIL.Image
self.current_mtl.map_Kd = PIL.Image.open(os.path.join(os.path.dirname(self.parent.path), split[0]))
except:
pass
def parse_file(self, path):

View File

@@ -50,13 +50,16 @@ class Material:
gl.glDisable(gl.GL_TEXTURE_2D)
import PIL.Image
Material.DEFAULT_MATERIAL=Material('')
Material.DEFAULT_MATERIAL.Ka = 1.0
Material.DEFAULT_MATERIAL.Kd = 0.0
Material.DEFAULT_MATERIAL.Ks = 0.0
Material.DEFAULT_MATERIAL.map_Kd = PIL.Image.new("RGBA", (1,1), "white")
try:
import PIL.Image
Material.DEFAULT_MATERIAL.map_Kd = PIL.Image.new("RGBA", (1,1), "white")
except:
pass
class MeshPart:
def __init__(self, parent):