|
@@ -278,7 +278,7 @@ def generate_texture_bindings(material_property, material_params):
|
|
"DiffuseFactor": "diffuseFactor",
|
|
"DiffuseFactor": "diffuseFactor",
|
|
"EmissiveColor": "emissiveMap",
|
|
"EmissiveColor": "emissiveMap",
|
|
"EmissiveFactor": "emissiveFactor",
|
|
"EmissiveFactor": "emissiveFactor",
|
|
- "AmbientColor": "ambientMap",
|
|
|
|
|
|
+ "AmbientColor": "lightMap", # "ambientMap",
|
|
"AmbientFactor": "ambientFactor",
|
|
"AmbientFactor": "ambientFactor",
|
|
"SpecularColor": "specularMap",
|
|
"SpecularColor": "specularMap",
|
|
"SpecularFactor": "specularFactor",
|
|
"SpecularFactor": "specularFactor",
|
|
@@ -340,7 +340,8 @@ def generate_material_object(material):
|
|
transparent = False
|
|
transparent = False
|
|
reflectivity = 1
|
|
reflectivity = 1
|
|
|
|
|
|
- material_type = 'MeshLambertMaterial'
|
|
|
|
|
|
+ material_type = 'MeshBasicMaterial'
|
|
|
|
+# material_type = 'MeshLambertMaterial'
|
|
material_params = {
|
|
material_params = {
|
|
|
|
|
|
'color' : diffuse,
|
|
'color' : diffuse,
|
|
@@ -510,11 +511,18 @@ def generate_texture_object(texture):
|
|
else:
|
|
else:
|
|
url = getTextureName( texture )
|
|
url = getTextureName( texture )
|
|
|
|
|
|
- url = replace_inFolder2OutFolder( url )
|
|
|
|
|
|
+ #url = replace_inFolder2OutFolder( url )
|
|
|
|
+ #print( url )
|
|
|
|
+
|
|
|
|
+ index = url.rfind( '/' )
|
|
|
|
+ if index == -1:
|
|
|
|
+ index = url.rfind( '\\' )
|
|
|
|
+ filename = url[ index+1 : len(url) ]
|
|
|
|
|
|
output = {
|
|
output = {
|
|
|
|
|
|
- 'url': url,
|
|
|
|
|
|
+ 'url': filename,
|
|
|
|
+ 'fullpath': url,
|
|
'repeat': serializeVector2( (1,1) ),
|
|
'repeat': serializeVector2( (1,1) ),
|
|
'offset': serializeVector2( texture.GetUVTranslation() ),
|
|
'offset': serializeVector2( texture.GetUVTranslation() ),
|
|
'magFilter': 'LinearFilter',
|
|
'magFilter': 'LinearFilter',
|
|
@@ -2008,8 +2016,8 @@ def write_file(filepath, content):
|
|
index = filepath.rfind('/')
|
|
index = filepath.rfind('/')
|
|
dir = filepath[0:index]
|
|
dir = filepath[0:index]
|
|
|
|
|
|
- if not os.path.exists(dir):
|
|
|
|
- os.makedirs(dir)
|
|
|
|
|
|
+ #if not os.path.exists(dir):
|
|
|
|
+ #os.makedirs(dir)
|
|
|
|
|
|
out = open(filepath, "w")
|
|
out = open(filepath, "w")
|
|
out.write(content.encode('utf8', 'replace'))
|
|
out.write(content.encode('utf8', 'replace'))
|
|
@@ -2025,25 +2033,35 @@ def copy_textures(textures):
|
|
texture_dict = {}
|
|
texture_dict = {}
|
|
|
|
|
|
for key in textures:
|
|
for key in textures:
|
|
- url = textures[key]['url']
|
|
|
|
- src = replace_OutFolder2inFolder(url)
|
|
|
|
-
|
|
|
|
|
|
+ url = textures[key]['fullpath']
|
|
|
|
+ #src = replace_OutFolder2inFolder(url)
|
|
|
|
+
|
|
|
|
+ #print( src )
|
|
|
|
+ #print( url )
|
|
|
|
+
|
|
if url in texture_dict: # texture has been copied
|
|
if url in texture_dict: # texture has been copied
|
|
continue
|
|
continue
|
|
|
|
|
|
- if not os.path.exists(src):
|
|
|
|
- print("copy_texture error: we can't find this texture at " + src)
|
|
|
|
|
|
+ if not os.path.exists(url):
|
|
|
|
+ print("copy_texture error: we can't find this texture at " + url)
|
|
continue
|
|
continue
|
|
|
|
|
|
try:
|
|
try:
|
|
index = url.rfind('/')
|
|
index = url.rfind('/')
|
|
- folder = url[0:index]
|
|
|
|
- if len(folder) and not os.path.exists(folder):
|
|
|
|
- os.makedirs(folder)
|
|
|
|
- shutil.copyfile(src, url)
|
|
|
|
|
|
+ if index == -1:
|
|
|
|
+ index = url.rfind( '\\' )
|
|
|
|
+ filename = url[index+1:len(url)]
|
|
|
|
+ saveFolder = "maps"
|
|
|
|
+ saveFilename = saveFolder + "/" + filename
|
|
|
|
+ #print( src )
|
|
|
|
+ #print( url )
|
|
|
|
+ #print( saveFilename )
|
|
|
|
+ if not os.path.exists(saveFolder):
|
|
|
|
+ os.makedirs(saveFolder)
|
|
|
|
+ shutil.copyfile(url, saveFilename)
|
|
texture_dict[url] = True
|
|
texture_dict[url] = True
|
|
except IOError as e:
|
|
except IOError as e:
|
|
- print "I/O error({0}): {1} {2}".format(e.errno, e.strerror, src)
|
|
|
|
|
|
+ print "I/O error({0}): {1} {2}".format(e.errno, e.strerror, url)
|
|
|
|
|
|
def findFilesWithExt(directory, ext, include_path = True):
|
|
def findFilesWithExt(directory, ext, include_path = True):
|
|
ext = ext.lower()
|
|
ext = ext.lower()
|
|
@@ -2157,4 +2175,4 @@ if __name__ == "__main__":
|
|
|
|
|
|
# Destroy all objects created by the FBX SDK.
|
|
# Destroy all objects created by the FBX SDK.
|
|
sdk_manager.Destroy()
|
|
sdk_manager.Destroy()
|
|
- sys.exit(0)
|
|
|
|
|
|
+ sys.exit(0)
|