Blenderで炎(その2)

bl-fire2-title
炎の続きです。

炎がよく見えるように背景を黒にします。

bpy.data.worlds['World'].horizon_color=(0,0,0)

薪の色です。

bpy.data.materials['Material'].diffuse_color=(0.9, 0.4, 0.18)

Cubeを長細くして薪にします。

bpy.ops.transform.resize(value=(0.08, 0.03, 0.4))
bpy.data.objects['Cube'].rotation_mode='XYZ'
bpy.data.objects['Cube'].rotation_euler=(-math.pi/3, 0, 0)
bpy.data.objects['Cube'].location=(0, -0.3, -0.2)
bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)

薪をコピーして増やします。

bpy.ops.object.duplicate()
bpy.data.objects['Cube.001'].rotation_euler=(0,0,1)

火の種になる球体です。

bpy.ops.mesh.primitive_uv_sphere_add()
bpy.ops.transform.resize(value=(0.01,0.01,0.01))

煙のシミュレーションです。

bpy.ops.object.quick_smoke()

炎と煙の細かい設定をします。

bpy.data.objects['Sphere'].modifiers['Smoke'].flow_settings.smoke_flow_type='FIRE'
bpy.data.objects['Sphere'].modifiers['Smoke'].flow_settings.surface_distance=2.7
bpy.data.objects['Smoke Domain'].modifiers['Smoke'].domain_settings.flame_smoke=0.2

全部合わせたスクリプトです。

~$ cat fire2.sh
#!/bin/bash
cat <<EOL>/tmp/tmp.py

import bpy,math

bpy.data.worlds['World'].horizon_color=(0,0,0)

bpy.data.materials['Material'].diffuse_color=(0.9, 0.4, 0.18)

bpy.ops.transform.resize(value=(0.08, 0.03, 0.4))
bpy.data.objects['Cube'].rotation_mode='XYZ'
bpy.data.objects['Cube'].rotation_euler=(-math.pi/3, 0, 0)
bpy.data.objects['Cube'].location=(0, -0.3, -0.2)
bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)
bpy.ops.object.duplicate()
bpy.data.objects['Cube.001'].rotation_euler=(0,0,1)
bpy.ops.object.duplicate()
bpy.data.objects['Cube.002'].rotation_euler=(0,0,2)
bpy.ops.object.duplicate()
bpy.data.objects['Cube.003'].rotation_euler=(0,0,3)
bpy.ops.object.duplicate()
bpy.data.objects['Cube.004'].rotation_euler=(0,0,4)
bpy.ops.object.duplicate()
bpy.data.objects['Cube.005'].rotation_euler=(0,0,5)

bpy.ops.mesh.primitive_uv_sphere_add()
bpy.ops.transform.resize(value=(0.01,0.01,0.01))
bpy.ops.object.quick_smoke()
bpy.data.objects['Sphere'].modifiers['Smoke'].flow_settings.smoke_flow_type='FIRE'
bpy.data.objects['Sphere'].modifiers['Smoke'].flow_settings.surface_distance=2.7
bpy.data.objects['Smoke Domain'].modifiers['Smoke'].domain_settings.flame_smoke=0.2

EOL
blender -b -P /tmp/tmp.py -o //test -a -F PNG -x 1 -f 30 | grep ^Save
convert -layers optimize -loop 0 -delay 1 test????.png test.gif

bl-fire2

One response to “Blenderで炎(その2)

  1. I’m quite pleased with the infmioatron in this one. TY!

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA