Google Summer of Code project: "Smoke Simulator Improvements & Fire".

Documentation & Test blend files:
------------------
http://wiki.blender.org/index.php/User:MiikaH/GSoC-2012-Smoke-Simulator-Improvements

Credits:
------------------
Miika Hamalainen (MiikaH): Student / Main programmer

Daniel Genrich (Genscher): Mentor / Programmer of merged patches from Smoke2 branch
Google: For Google Summer of Code 2012
This commit is contained in:
Daniel Genrich
2012-10-10 13:18:07 +00:00
parent f0a9b66469
commit cb634b9100
50 changed files with 4206 additions and 1836 deletions

View File

@@ -299,7 +299,6 @@ class QuickSmoke(Operator):
style = EnumProperty(
name="Smoke Style",
items=(('STREAM', "Stream", ""),
('PUFF', "Puff", ""),
('FIRE', "Fire", ""),
),
default='STREAM',
@@ -328,20 +327,9 @@ class QuickSmoke(Operator):
bpy.ops.object.modifier_add(fake_context, type='SMOKE')
obj.modifiers[-1].smoke_type = 'FLOW'
psys = obj.particle_systems[-1]
if self.style == 'PUFF':
psys.settings.frame_end = psys.settings.frame_start
psys.settings.emit_from = 'VOLUME'
psys.settings.distribution = 'RAND'
elif self.style == 'FIRE':
psys.settings.effector_weights.gravity = -1
psys.settings.lifetime = 5
psys.settings.count = 100000
if self.style == 'FIRE':
obj.modifiers[-1].flow_settings.smoke_flow_type = 'FIRE'
obj.modifiers[-2].flow_settings.initial_velocity = True
obj.modifiers[-2].flow_settings.temperature = 2
psys.settings.use_render_emitter = self.show_flows
if not self.show_flows:
obj.draw_type = 'WIRE'
@@ -361,8 +349,6 @@ class QuickSmoke(Operator):
bpy.ops.object.modifier_add(type='SMOKE')
obj.modifiers[-1].smoke_type = 'DOMAIN'
if self.style == 'FIRE':
obj.modifiers[-1].domain_settings.use_dissolve_smoke = True
obj.modifiers[-1].domain_settings.dissolve_speed = 20
obj.modifiers[-1].domain_settings.use_high_resolution = True
# create a volume material with a voxel data texture for the domain
@@ -373,6 +359,7 @@ class QuickSmoke(Operator):
mat.type = 'VOLUME'
mat.volume.density = 0
mat.volume.density_scale = 5
mat.volume.step_size = 0.1
tex = bpy.data.textures.new("Smoke Density", 'VOXEL_DATA')
tex.voxel_data.domain_object = obj
@@ -381,29 +368,35 @@ class QuickSmoke(Operator):
tex_slot.texture = tex
tex_slot.use_map_color_emission = False
tex_slot.use_map_density = True
tex_slot.use_map_color_reflection = True
# for fire add a second texture for emission and emission color
if self.style == 'FIRE':
mat.volume.emission = 5
tex = bpy.data.textures.new("Smoke Heat", 'VOXEL_DATA')
tex.voxel_data.domain_object = obj
tex.use_color_ramp = True
# for fire add a second texture for flame emission
mat.volume.emission_color = Vector((0.0, 0.0, 0.0))
tex = bpy.data.textures.new("Flame", 'VOXEL_DATA')
tex.voxel_data.domain_object = obj
tex.voxel_data.smoke_data_type = 'SMOKEFLAME'
tex.use_color_ramp = True
tex_slot = mat.texture_slots.add()
tex_slot.texture = tex
tex_slot = mat.texture_slots.add()
tex_slot.texture = tex
ramp = tex.color_ramp
# add color ramp for flame color
ramp = tex.color_ramp
# dark orange
elem = ramp.elements.new(0.333)
elem.color[0] = 0.2
elem.color[1] = 0.03
elem.color[2] = 0
elem.color[3] = 1
# yellow glow
elem = ramp.elements.new(0.666)
elem.color[0] = elem.color[3] = 1
elem.color[1] = 0.65
elem.color[2] = 0.25
elem = ramp.elements.new(0.333)
elem.color[0] = elem.color[3] = 1
elem.color[1] = elem.color[2] = 0
elem = ramp.elements.new(0.666)
elem.color[0] = elem.color[1] = elem.color[3] = 1
elem.color[2] = 0
mat.texture_slots[1].use_map_emission = True
mat.texture_slots[1].blend_type = 'MULTIPLY'
mat.texture_slots[1].use_map_density = True
mat.texture_slots[1].use_map_emission = True
mat.texture_slots[1].emission_factor = 5
return {'FINISHED'}