Repository navigation
Expand file tree
/
Copy pathpreview.py
More file actions
24 lines (24 loc) · 1.38 KB
/
Copy pathpreview.py
File metadata and controls
24 lines (24 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""모델 확인용 렌더. blender -b -P preview.py -- <Resources> <out.png>"""
import bpy, sys, math, os
args = sys.argv[sys.argv.index("--") + 1:]
res, png = args[0], args[1]
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.wm.usd_import(filepath=os.path.join(res, "FlowerHead.usdz"))
head = [o for o in bpy.context.scene.objects if o.type == "MESH"][-1]
head.location = (0.05, 0.075, 0); head.rotation_euler = (0, 0, math.radians(-150))
bpy.ops.wm.usd_import(filepath=os.path.join(res, "FrostedBase.usdz"))
base = [o for o in bpy.context.scene.objects if o.type == "MESH" and o != head][-1]
base.location = (-0.05, 0, 0)
sc = bpy.context.scene
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")); sc.collection.objects.link(cam)
cam.location = (0, 0.05, 0.28); cam.rotation_euler = (0, 0, 0)
sc.camera = cam
w = bpy.data.worlds.new("w"); sc.world = w; w.use_nodes = True
w.node_tree.nodes["Background"].inputs[0].default_value = (0.45, 0.62, 0.64, 1)
w.node_tree.nodes["Background"].inputs[1].default_value = 1.2
l = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")); sc.collection.objects.link(l)
l.rotation_euler = (math.radians(40), math.radians(20), 0); l.data.energy = 3
sc.render.engine = "CYCLES"; sc.cycles.samples = 48; sc.cycles.device = "CPU"
sc.render.resolution_x = 700; sc.render.resolution_y = 500
sc.render.filepath = png
bpy.ops.render.render(write_still=True)