-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathyafCliRender2.py
120 lines (93 loc) · 3.17 KB
/
yafCliRender2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!BPY
__author__ = ['Rodrigo Placencia (DarkTide) & mods by Mitch Hughes (lobo_nz)']
__version__ = '0.0.1'
__url__ = ['http://www.yafaray.org','http://www.farmerjoe.info']
__bpydoc__ = """\
"""
# This script can be used from a command line like this:
#WINDOWS
#call SET "YAFRENDERDIR=r:\path to output\frames"&SET YAFANIM="true"&"r:\bin\path to blender\Blender.exe" -b "r:\path to blend\yafaray.blend" -s "1" -e "1" -P "r:\path to script\yafCliRender.py"
#*NIX (Including OSX)
#YAFRENDERDIR="r:\path to output\frames" YAFANIM="true" "r:\bin\path to blender\Blender.exe" -b "r:\path to blend\yafaray.blend" -s "1" -e "1" -P "r:\path to script\yafCliRender.py"
#########
# import order IS important for sys.path.append seemingly
import sys
import os
import platform
import Blender
# Enter the abolsute path to the YafaRay directory or the relative path
# (as seen from Blender.exe)
# If you have a directory structure like this:
#
# ,- Blender (containing Blender.exe)
# +- YafaRay
# + ...
#
# then set dllPath = "..\\YafaRay\\"
# dllPath = "..\\YafaRay\\"
dllPath = ""
pythonPath = ""
haveQt = True
_SYS = platform.system()
if _SYS == 'Windows':
if dllPath == "":
import _winreg
regKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\YafRay Team\\YafaRay')
dllPath = _winreg.QueryValueEx(regKey, 'InstallDir')[0] + '\\'
if pythonPath == "":
pythonPath = dllPath + 'python\\'
from ctypes import cdll
dlls = ['zlib1','libpng3','jpeg62','Iex','Half','IlmThread',\
'IlmImf','mingwm10','libfreetype-6','yafraycore', 'yafarayplugin']
qtDlls = ['QtCore4', 'QtGui4', 'yafarayqt']
if os.path.exists(dllPath + 'yafarayqt.dll'):
dlls += qtDlls
else:
haveQt = False
print "WARNING: Qt GUI will NOT be available."
for dll in dlls:
print "Loading DLL: " + dllPath + dll + '.dll'
cdll.LoadLibrary(dllPath + dll + '.dll')
dllPath = str(dllPath + 'plugins\\')
# append a non-empty pythonpath to sys
if pythonPath != "":
pythonPath = os.path.normpath(pythonPath)
sys.path.append(pythonPath)
# assume for all non-windows systems unix-like paths,
# add search paths for the scripts
if _SYS != 'Windows':
if pythonPath == "":
searchPaths = []
searchPaths.append(os.environ['HOME'] + '/.blender/scripts/yafaray/')
searchPaths.append('/usr/local/share/yafaray/blender/')
searchPaths.append('/usr/share/yafaray/blender/')
searchPaths.append(Blender.Get('scriptsdir') + '/yafaray/')
for p in searchPaths:
if os.path.exists(p):
sys.path.append(p)
if haveQt:
try:
import yafqt
except:
haveQt = False
print "WARNING: Importing yafqt failed, Qt GUI will NOT be available."
import string
import math
import yaf_export
from yaf_export import yafrayRender
import yafrayinterface
from Blender import *
# TODO: add ability to overwrite output method settings?
# TODO: check interface needed from output method settings
yinterface = yafrayinterface.yafrayInterface_t()
yinterface.loadPlugins(dllPath)
yaf_export.haveQt = haveQt
# FIXME: check animation option from command line
yafanim = False
yRender = yafrayRender()
yRender.setInterface(yinterface)
print "Starting render process: Animation [" + str(yafanim) + "]"
if not yafanim:
yRender.renderCL()
else:
yRender.renderAnim()