Advertisement
salahzar

massage materials

Mar 13th, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. extends Node
  2.  
  3. func _ready():
  4.    
  5.     var files = []
  6.     list_files("res://",".material",files)
  7.    
  8.     for f in files:
  9.         var m:SpatialMaterial = load(f)
  10.         print("Handling"+ f + " Metallic: "+str(m.metallic) + " Specular: "+str(m.metallic_specular) + " Roughness: "+str(m.roughness))
  11.         if(m.metallic != 0 && m.metallic_specular != 0 && m.roughness != 1):
  12.             print(".... massaging material")
  13.             m.metallic = 0
  14.             m.metallic_specular = 0
  15.             m.roughness = 1
  16.        
  17.             ResourceSaver.save(f, m)
  18.        
  19.    
  20.     pass # Replace with function body.
  21.  
  22. func list_files(path: String, suffix: String, files: Array):
  23.    
  24.     var dir: Directory = Directory.new()
  25.     dir.open(path)
  26.     dir.list_dir_begin()
  27.  
  28.     while true:
  29.         var file: String = dir.get_next()
  30.         if file == "":
  31.             break
  32.         if file.begins_with("."):
  33.             continue
  34.         if dir.current_is_dir():
  35.             list_files(path+"/"+file,suffix,files)
  36.         else:
  37.             if file.ends_with(suffix):
  38.                 files.append(path+"/"+file)
  39.  
  40.     dir.list_dir_end()
  41.  
  42.     return files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement