def _check_ramp_update(scene): if g.light_index() == -1: return if cpp().colorRampChanged(g.light_index()): cpp().updateLightColor(g.light_index()) image.create_final()
def clear(): for scene in g.scenes(): if scene.name[0:len(_PREFIX)] == _PREFIX: g.scenes().remove(scene, do_unlink = True) g.scene().use_nodes = False image.set_as_env_map(g.scene(), g.image()) image.create_final()
def update_x(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightX(index, l.x) global change_both_coordinates if change_both_coordinates: change_both_coordinates = False else: image.create_final()
def _update_color(l, context): global _skip_update_color _skip_update_color = not(_skip_update_color) if not(_skip_update_color): return index = _index_by_id(l) if index != -1: cpp().changeLightColor(index, _to_float_pointer(l.color)) image.create_final()
def _check_curve_update(scene): if g.light_index() == -1: return if cpp().curveFlatChanged(g.light_index()): cpp().updateLightLuminosity(g.light_index()) image.create_final() if g.light().content_type == 'IMAGE': if cpp().curveImageChanged(g.light_index()): cpp().changeLightImageBrightness(g.light_index()) image.create_final()
def execute(self, context): if g.light_index() < 1: return {'CANCELLED'} upper = g.light_index() - 1 g.lights().move(g.light_index(), upper) g.light_data.insert(upper, g.light_data[g.light_index()]) g.light_data.pop(g.light_index() + 1) cpp().up(g.light_index()) g.data().light_index -= 1 image.create_final() return {'FINISHED'}
def execute(self, context): if g.light_index() > len(g.lights()) - 2: return {'CANCELLED'} lower = g.light_index() + 1 g.lights().move(g.light_index(), lower) g.light_data.insert(g.light_index(), g.light_data[lower]) g.light_data.pop(lower + 1) cpp().down(g.light_index()) g.data().light_index += 1 image.create_final() return {'FINISHED'}
def execute(self, context): if g.no_lights(): return {'CANCELLED'} g.lights().remove(g.light_index()) cpp().removeLight(g.light_index()) data = g.light_data[g.light_index()] g.textures().remove(data.texture()) g.blender_lights().remove(data.light_flat()) g.blender_lights().remove(data.light_image()) g.light_data.remove(data) g.data().light_index -= 1 if g.no_lights(): if len(g.lights()): g.data().light_index = 0 image.create_final() return {'FINISHED'}
def execute(self, context): item = g.lights().add() item.id = g.data().max_id g.data().max_id += 1 item.name = 'light' g.data().light_index = len(g.lights()) - 1 texture = g.textures().new(g.data_name(item), 'BLEND') texture.use_color_ramp = True texture.use_fake_user = True light_flat = g.blender_lights().new( g.data_name(item, 'flat'), 'POINT') light_flat.use_fake_user = True light_image = g.blender_lights().new( g.data_name(item, 'image'), 'POINT') light_image.use_fake_user = True curve = light_image.falloff_curve points = curve.curves[0].points points[0].location.y = 0 points[1].location.y = 1 curve.update() g.light_data.append(light.Data( texture.name, light_flat.name, light_image.name )) light.add(item, g.light_index()) image.create_final() return {'FINISHED'}
def _update_is_ellipse(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightIsEllipse(index, l.is_ellipse) image.create_final()
def execute(self, context): g.set_image(active_image(context)) if not (g.image()): self.report({'ERROR'}, 'No image is selected in uv editor.') return {'CANCELLED'} image_pointer = blender.get_image_pointer(g.image().name) if not (image_pointer): self.report({'ERROR'}, 'No image cache is available. Try opening ' 'image in uv editor.') g.set_image(None) return {'CANCELLED'} im_dna = blender.ImageDna.from_address(image_pointer.value) pool = im_dna.cache.contents.items_pool.contents item = blender.MovieCacheItem.from_address(pool.free - pool.esize) imbuf_pointer = item.ibuf if not (cast(imbuf_pointer, c_void_p).value): g.set_image(None) return {'CANCELLED'} rect_float_pointer = imbuf_pointer.contents.rect_float if not (cast(rect_float_pointer, c_void_p).value): g.set_image(None) self.report({'ERROR'}, 'This is not an hdr image.') return {'CANCELLED'} cpp().initImage(image_pointer) try: g.image().pack() except: cpp().clearImage() g.set_image(None) self.report({'ERROR'}, 'Failed to pack image. Try again with image ' 'without unsaved changes.') return {'CANCELLED'} if not (image.enable_renderer()): cpp().clearImage() g.set_image(None) self.report({'ERROR'}, 'Eevee and Cycles render engines are unavailable.') return {'CANCELLED'} image.set_as_env_map(g.scene(), g.image()) for l in g.lights(): image_name = l.image if not (image_name): continue try: g.images()[image_name] except: cpp().clearImage() g.set_image(None) self.report({'ERROR'}, 'Image \'' + image_name + '\' is ' 'unavailable.') return {'CANCELLED'} for area in g.areas(): if area.type == 'VIEW_3D': for space in area.spaces: if space.type == 'VIEW_3D': space.shading.type = 'RENDERED' break break light.Light.x = IntProperty(default=int(g.image().size[0] / 2), min=0, max=(g.image().size[0] - 1), update=light.update_x) light.Light.y = IntProperty(default=int(g.image().size[1] / 2), min=0, max=(g.image().size[1] - 1), update=light.update_y) for l in g.lights(): g.light_data.append( light.Data(g.data_name(l), g.data_name(l, 'flat'), g.data_name(l, 'image'))) for data in g.light_data: data.light_flat().falloff_curve.initialize() data.light_image().falloff_curve.initialize() for im in g.images(): if im.type == 'IMAGE' and im.has_data: im.update() for i in range(len(g.lights())): light.add(g.lights()[i], i) image.create_final() bpy.ops.hdr_pro_studio.move('INVOKE_DEFAULT') bpy.app.handlers.depsgraph_update_pre.append(_check_curve_update) bpy.app.handlers.depsgraph_update_pre.append(_check_ramp_update) _set_hotkeys(False) _set_started(context, True) return {'FINISHED'}
def _update_sides(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightSides(index, l.sides) image.create_final()
def _update_corner_radius(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightCornerRadius(index, l.corner_radius) image.create_final()
def _update_curve_x(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightCurveX(index, l.curve_x) image.create_final()
def _update_content_type(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightContentType(index, _ct_enum(l.content_type)) image.create_final()
def _update_blend_mode(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightBlendMode(index, _bm_enum(l.blend_mode)) image.create_final()
def update_y(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightY(index, l.y) image.create_final()
def _update_solo(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightSolo(index, l.solo) image.create_final()
def _update_radial_height(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightRadialHeight(index, l.radial_height) image.create_final()
def _update_radial_width(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightRadialWidth(index, l.radial_width) image.create_final()
def _update_gradient_angle(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightGradientAngle(index, l.gradient_angle) image.create_final()
def _update_falloff_type(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightFalloffType(index, _ft_enum(l.falloff_type)) image.create_final()
def _update_brightness_color(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightBrightnessColor(index, l.brightness_color) image.create_final()
def _update_brightness_opacity(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightBrightnessOpacity(index, l.brightness_opacity) image.create_final()
def _update_image(l, context): index = _index_by_id(l) if index != -1: cpp().updateLightImage(index) image.create_final()
def _update_enabled(l, context): index = _index_by_id(l) if index != -1: cpp().changeLightEnabled(index, l.enabled) image.create_final()