Merge branch 'master' of github.com:tforgione/model-converter

This commit is contained in:
Thomas FORGIONE 2016-12-21 12:17:17 +01:00
commit 43791483d8
No known key found for this signature in database
GPG Key ID: 2A210FFC062E00C3
4 changed files with 24 additions and 11 deletions

View File

@ -24,6 +24,7 @@ dependencies, you'll need :
- pip (to install the other dependencies) `sudo apt-get install python3-pip`
for example
- PIL `sudo pip install pillow`
- numpy `sudo pip install numpy`
- pygame `sudo pip install pygame`
- PyOpenGL `sudo pip install pyopengl`

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
@ -90,7 +89,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):

View File

@ -6,13 +6,13 @@ import argparse
import os
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
try:
import PIL
except:
print('You need to install PIL', file=sys.stderr)
sys.exit(-1)
try:
import pygame as pg
import pygame.locals as pgl
@ -33,6 +33,12 @@ except:
print('You need to install numpy', file=sys.stderr)
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_HEIGHT = 1024