bake.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. import subprocess
  3. import os
  4. import glob
  5. import sys
  6. root = os.path.dirname(sys.argv[0])
  7. platform = sys.platform
  8. SHADERS = 'shaders'
  9. TEXTURES = 'textures'
  10. RES = 4096
  11. os.environ['DL_SHADERS_PATH'] = os.path.join(root, SHADERS)
  12. os.environ['DL_TEXTURES_PATH'] = os.path.join(root, TEXTURES)
  13. if platform == 'linux2':
  14. print 'running linux'
  15. DELIGHT = '/usr/local/3delight-12.0.19/Linux-x86_64'
  16. os.environ['DELIGHT'] = DELIGHT
  17. sys.path.append(os.path.join(DELIGHT, 'bin'))
  18. elif platform == 'darwin':
  19. os.environ['DELIGHT'] = '/Applications/3Delight'
  20. def cleanup():
  21. for bakefile in glob.glob(os.path.join(root,'*.bake')):
  22. os.remove(bakefile)
  23. for tdl in glob.glob(os.path.join(root,'*.tdl')):
  24. os.remove(tdl)
  25. def gen_includes():
  26. includes = []
  27. for file in glob.glob('caster/*'):
  28. includes.append(file)
  29. for file in glob.glob('receiver/*'):
  30. includes.append(file)
  31. return includes
  32. def bake_post_render(root, res=RES):
  33. for bakefile in glob.glob(os.path.join(root, '*.bake')):
  34. bake_target = os.path.splitext(bakefile)[0]
  35. cmd = ['tdlmake', '-bakeres', str(res) + 'x' + str(res), bakefile, bake_target + '.tdl']
  36. subprocess.call(cmd)
  37. cmd = ['tdlmake', bake_target + '.tdl', bake_target + '.tif',]
  38. subprocess.call(cmd)
  39. print gen_includes()
  40. cleanup()
  41. #subprocess.call(['renderdl', '-res', str(RES), str(RES), '-id', '-progress', 'options.rib'])
  42. subprocess.call(['renderdl', '-res', str(RES), str(RES), '-id','-progress', 'options.rib'])
  43. bake_post_render(root)