Advertisement
Guest User

OWM Cycles Lights

a guest
Jul 13th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | None | 0 0
  1.     LIGHT_MAP = ['POINT', 'FRUSTUM', 'NONE']
  2.  
  3.     if light_settings.enabled:
  4.         globLight = bpy.data.objects.new(name + '_LIGHTS', None)
  5.         globLight.hide_viewport = True
  6.         globLight.parent = rootObj
  7.         bpyhelper.scene_link(globLight)
  8.         for light in data.lights:
  9.             prog += 1
  10.             is_spot = light.fov > 0
  11.             if light.ex[6] >= 2:
  12.                 print("[owmap] Light is type NONE!?")
  13.             lamp_data = bpy.data.lights.new(name='%s_%s' % (name, LIGHT_MAP[min([2, light.ex[6]])]), type='SPOT' if is_spot else 'POINT')
  14.             lamp_ob = bpy.data.objects.new(name=name, object_data=lamp_data)
  15.             bpyhelper.scene_link(lamp_ob)
  16.             lamp_ob.location = pos_matrix(light.position)
  17.             if light.ex[6] == 1:
  18.                 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))
  19.             lamp_ob.rotation_euler = Quaternion(wxzy(light.rotation)).to_euler('XYZ')
  20.             lamp_ob.rotation_euler.x -= 1.5708
  21.             light_scale = light.ex[light_settings.sizeIndex % len(light.ex)]
  22.             lamp_ob.scale = (light_scale, light_scale, light_scale)
  23.             lamp_col = Color(light.color)
  24.             lamp_col.v *= light_settings.adjuistValues['VALUE']
  25.             lamp_data.cycles.use_multiple_importance_sampling = light_settings.multipleImportance
  26.             lamp_str = light_settings.adjuistValues['STRENGTH']
  27.             if is_spot:
  28.                 lamp_data.spot_size = math.radians(light.fov)
  29.                 lamp_data.spot_blend = light.ex[light_settings.spotIndex % len(light.ex)]
  30.             if light_settings.useStrength:
  31.                 lamp_str = light_settings.adjuistValues['STRENGTH'] * light.ex[light_settings.index % len(light.ex)]
  32.             lamp_data.use_nodes = True
  33.             lamp_data.shadow_soft_size = light_settings.bias
  34.             enode = lamp_data.node_tree.nodes.get('Emission')
  35.             enode.inputs.get('Color').default_value = (lamp_col.r, lamp_col.g, lamp_col.b, 1.0)
  36.             enode.inputs.get('Strength').default_value = lamp_str
  37.             lamp_ob.parent = globLight
  38.             progress_update(total, prog, "Lamp")
  39.            
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement