Fixed optional import, readme
This commit is contained in:
parent
9860d90e0b
commit
5da117b42a
|
@ -24,6 +24,7 @@ dependencies, you'll need :
|
||||||
|
|
||||||
- pip (to install the other dependencies) `sudo apt-get install python3-pip`
|
- pip (to install the other dependencies) `sudo apt-get install python3-pip`
|
||||||
for example
|
for example
|
||||||
|
- PIL `sudo pip install pillow`
|
||||||
- numpy `sudo pip install numpy`
|
- numpy `sudo pip install numpy`
|
||||||
- pygame `sudo pip install pygame`
|
- pygame `sudo pip install pygame`
|
||||||
- PyOpenGL `sudo pip install pyopengl`
|
- PyOpenGL `sudo pip install pyopengl`
|
||||||
|
|
|
@ -2,7 +2,6 @@ from ..basemodel import ModelParser, Exporter, Vertex, TexCoord, Normal, FaceVer
|
||||||
from ..mesh import Material, MeshPart
|
from ..mesh import Material, MeshPart
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import os.path
|
import os.path
|
||||||
import PIL.Image
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +88,11 @@ class MTLParser:
|
||||||
elif first == 'Ks':
|
elif first == 'Ks':
|
||||||
self.current_mtl.Ks = Vertex().from_array(split)
|
self.current_mtl.Ks = Vertex().from_array(split)
|
||||||
elif first == 'map_Kd':
|
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):
|
def parse_file(self, path):
|
||||||
|
|
|
@ -50,13 +50,16 @@ class Material:
|
||||||
|
|
||||||
gl.glDisable(gl.GL_TEXTURE_2D)
|
gl.glDisable(gl.GL_TEXTURE_2D)
|
||||||
|
|
||||||
import PIL.Image
|
|
||||||
|
|
||||||
Material.DEFAULT_MATERIAL=Material('')
|
Material.DEFAULT_MATERIAL=Material('')
|
||||||
Material.DEFAULT_MATERIAL.Ka = 1.0
|
Material.DEFAULT_MATERIAL.Ka = 1.0
|
||||||
Material.DEFAULT_MATERIAL.Kd = 0.0
|
Material.DEFAULT_MATERIAL.Kd = 0.0
|
||||||
Material.DEFAULT_MATERIAL.Ks = 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:
|
class MeshPart:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
|
18
viewer.py
18
viewer.py
|
@ -6,13 +6,13 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from d3.model.tools import load_model
|
|
||||||
from d3.geometry import Vector
|
|
||||||
from d3.controls import TrackBallControls, OrbitControls
|
|
||||||
from d3.camera import Camera
|
|
||||||
from d3.shader import DefaultShader
|
|
||||||
|
|
||||||
# Test dependencies
|
# Test dependencies
|
||||||
|
try:
|
||||||
|
import PIL
|
||||||
|
except:
|
||||||
|
print('You need to install PIL', file=sys.stderr)
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pygame as pg
|
import pygame as pg
|
||||||
import pygame.locals as pgl
|
import pygame.locals as pgl
|
||||||
|
@ -33,6 +33,12 @@ except:
|
||||||
print('You need to install numpy', file=sys.stderr)
|
print('You need to install numpy', file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
from d3.model.tools import load_model
|
||||||
|
from d3.geometry import Vector
|
||||||
|
from d3.controls import TrackBallControls, OrbitControls
|
||||||
|
from d3.camera import Camera
|
||||||
|
from d3.shader import DefaultShader
|
||||||
|
|
||||||
WINDOW_WIDTH = 1024
|
WINDOW_WIDTH = 1024
|
||||||
WINDOW_HEIGHT = 1024
|
WINDOW_HEIGHT = 1024
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue