Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LIGHT_MAP = ['POINT', 'FRUSTUM', 'NONE']
- if light_settings.enabled:
- globLight = bpy.data.objects.new(name + '_LIGHTS', None)
- globLight.hide_viewport = True
- globLight.parent = rootObj
- bpyhelper.scene_link(globLight)
- for light in data.lights:
- prog += 1
- is_spot = light.fov > 0
- if light.ex[6] >= 2:
- print("[owmap] Light is type NONE!?")
- lamp_data = bpy.data.lights.new(name='%s_%s' % (name, LIGHT_MAP[min([2, light.ex[6]])]), type='SPOT' if is_spot else 'POINT')
- lamp_ob = bpy.data.objects.new(name=name, object_data=lamp_data)
- bpyhelper.scene_link(lamp_ob)
- lamp_ob.location = pos_matrix(light.position)
- if light.ex[6] == 1:
- print("[owmap] warning: importing frustum light at X: %f, Y: %f, Z: %f" % (lamp_ob.location.x, lamp_ob.location.y, lamp_ob.location.z))
- lamp_ob.rotation_euler = Quaternion(wxzy(light.rotation)).to_euler('XYZ')
- lamp_ob.rotation_euler.x -= 1.5708
- light_scale = light.ex[light_settings.sizeIndex % len(light.ex)]
- lamp_ob.scale = (light_scale, light_scale, light_scale)
- lamp_col = Color(light.color)
- lamp_col.v *= light_settings.adjuistValues['VALUE']
- lamp_data.cycles.use_multiple_importance_sampling = light_settings.multipleImportance
- lamp_str = light_settings.adjuistValues['STRENGTH']
- if is_spot:
- lamp_data.spot_size = math.radians(light.fov)
- lamp_data.spot_blend = light.ex[light_settings.spotIndex % len(light.ex)]
- if light_settings.useStrength:
- lamp_str = light_settings.adjuistValues['STRENGTH'] * light.ex[light_settings.index % len(light.ex)]
- lamp_data.use_nodes = True
- lamp_data.shadow_soft_size = light_settings.bias
- enode = lamp_data.node_tree.nodes.get('Emission')
- enode.inputs.get('Color').default_value = (lamp_col.r, lamp_col.g, lamp_col.b, 1.0)
- enode.inputs.get('Strength').default_value = lamp_str
- lamp_ob.parent = globLight
- progress_update(total, prog, "Lamp")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement