-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (25 loc) · 989 Bytes
/
main.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
#!/usr/bin/env python
from scene import Scene
from engine import Renderer
import argparse
import importlib
import os
from multiprocessing import cpu_count
def main():
parser = argparse.ArgumentParser()
parser.add_argument("scene", help="Path to scene file (no .py)")
parser.add_argument("-p", "--processes", action="store", type=int, dest="processes", default=0, help="Number of threads (all threads is default/0")
args = parser.parse_args()
args = parser.parse_args()
if args.processes == 0:
process_count = cpu_count()
else:
process_count = args.processes
mod = importlib.import_module(args.scene)
scene = Scene(mod.CAMERA, mod.OBJECTS, mod.LIGHTS, mod.WIDTH, mod.HEIGHT)
engine = Renderer()
os.chdir(os.path.dirname(os.path.abspath(mod.__file__)))
with open(mod.RENDERED_IMAGE, "w") as img_file_object:
engine.render_multiprocess(scene, process_count, img_file_object)
if __name__ == '__main__':
main()