def run(self, sender, evtid): geometry = None if check_selection([ix.selection[0]], is_kindof=["Geometry", "SceneObjectCombiner"], max_num=1): geometry = ix.selection[0] else: ix.log_warning("Please select an object to scatter on.") return False pc_type = "GeometryPointCloud" if pc_checkbox.get_value( ) else "GeometryPointUvSampler" ix.begin_command_batch("Scatter pointcloud") pc = generate_decimated_pointcloud( geometry, pc_type=pc_type, use_density=use_density_checkbox.get_value(), density=density_field.get_value(), point_count=point_count_field.get_value(), slope_blend=slope_blend_checkbox.get_value(), scope_blend=scope_blend_checkbox.get_value(), height_blend=height_blend_checkbox.get_value(), fractal_blend=fractal_blend_checkbox.get_value(), triplanar_blend=triplanar_blend_checkbox.get_value(), ao_blend=ao_blend_checkbox.get_value(), ix=ix) if pc: ix.application.check_for_events() ix.selection.deselect_all() ix.selection.add(pc) ix.end_command_batch() sender.get_window().hide() else: ix.end_command_batch()
def toggle_tx_stream_gui(): selection_copy = [] for selection in ix.selection: selection_copy.append(selection) new_selection = [] if check_selection(selection_copy, is_kindof=[ "TextureMapFile", "TextureStreamedMapFile", "OfContext" ]): ix.begin_command_batch("Toggle texture stream") for selected in selection_copy: if selected.is_context(): texture_maps = get_items( selected, kind=["TextureMapFile", "TextureStreamedMapFile"], ix=ix) for texture_map in texture_maps: tx = toggle_map_file_stream(tx=texture_map, ix=ix) if tx: new_selection.append(tx) else: tx = toggle_map_file_stream(tx=selected, ix=ix) if tx: new_selection.append(tx) ix.end_command_batch() ix.selection.deselect_all() ix.application.check_for_events() for selection in new_selection: ix.selection.add(selection) else: ix.log_warning( "Please one or more texture of type: TextureMapFile or TextureStreamedMapFile " "or a Context that contains these types.")
def run(self, sender, evtid): if ix.selection.get_count() == 0: ix.log_warning("Please select one or more texture objects.") else: textures = [] for selected in ix.selection: if check_selection([selected], is_kindof=["Texture"]): textures.append(selected) else: ix.log_warning( "One or more selected items are not texture objects." ) ix.begin_command_batch("Blur textures") blurred_textures = [] for texture in textures: blurred_textures.append( blur_tx(texture, radius=radius_field.get_value(), quality=int(quality_field.get_value()), ix=ix)) if blurred_textures: ix.selection.deselect_all() for blurred_tx in blurred_textures: ix.selection.add(blurred_tx) ix.end_command_batch() sender.get_window().hide()
def run(self, sender, evtid): if ix.selection.get_count() > 0 and check_selection( [ix.selection[0]], is_kindof=["MaterialPhysicalStandard", "OfContext"], max_num=1): if ix.selection[0].is_context(): ctx = ix.selection[0] else: ctx = ix.selection[0].get_context() else: ix.log_warning( "Please select either a Physical Standard material or its parent context." ) return False ix.begin_command_batch("Moisten surface") moisten_surface( ctx, ior=ior.get_value(), diffuse_multiplier=diffuse_multiplier.get_value(), specular_multiplier=specular_multiplier.get_value(), roughness_multiplier=roughness_multiplier.get_value(), displacement_blend=displacement_blend_checkbox.get_value(), scope_blend=scope_blend_checkbox.get_value(), height_blend=height_blend_checkbox.get_value(), fractal_blend=fractal_blend_checkbox.get_value(), ao_blend=ao_blend_checkbox.get_value(), ix=ix) ix.end_command_batch() sender.get_window().hide()
def srf1_picker_refresh(self, sender, evtid): if check_selection(ix.selection, is_kindof=[ "MaterialPhysicalStandard", "MaterialPhysicalBlend", "OfContext" ], min_num=1): ctxs = [] for selection in ix.selection: if selection.is_context(): ctx = selection else: ctx = selection.get_context() if not get_mtl_from_context(ctx, ix=ix): return None ctxs.append(str(ctx)) if srf2_txt.get_text(): ctx2 = ix.get_item(srf2_txt.get_text()) name_txt.set_text(ctx2.get_name() + MIX_SUFFIX) srf1_txt.set_text(str(IMPORTER_PATH_DELIMITER.join(ctxs))) else: ix.log_warning("Please select a valid material.\n") srf1_txt.set_text("")
def mix_ctx_picker_refresh(self, sender, evtid): if check_selection(ix.selection, is_kindof=["OfContext"], max_num=1): ctx = ix.selection[0] if not get_items(ctx, kind=['MaterialPhysicalBlend'], return_first_hit=True, ix=ix): ix.log_warning("Please select a valid mix context.\n") return None if not get_items(ctx, kind=['TextureMultiBlend'], return_first_hit=True, max_depth=1, ix=ix): ix.log_warning("Please select a valid mix context.\n") return None srf2_txt.set_text(str(ctx)) ctx2_name = ctx.get_name() name_txt.set_text(ctx2_name + MIX_SUFFIX) ix.selection.deselect_all() ix.selection.add(ctx.get_parent()) else: ix.log_warning("Please select a valid mix context.\n") srf2_txt.set_text("")
def run(self, sender, evtid): textures = [] for selected in ix.selection: if check_selection([selected], is_kindof=["Texture"]): textures.append(selected) else: ix.log_warning("One or more selected items are not texture objects.") ix.begin_command_batch("Textures to Triplanar") triplanar_textures = [] for tx in textures: triplanar_textures.append(tx_to_triplanar(tx, blend=ratio_field.get_value(), object_space=result.get('object_space'), ix=ix)) if triplanar_textures: ix.selection.deselect_all() for tx in triplanar_textures: ix.selection.add(tx) ix.end_command_batch() sender.get_window().hide()
def run(self, sender, evtid): if check_selection([ix.selection[0]], is_kindof=["MaterialPhysicalStandard", "OfContext"], max_num=1): if ix.selection[0].is_context(): ctx = ix.selection[0] else: ctx = ix.selection[0].get_context() else: ix.log_warning("Please select either a Physical Standard material or its parent context.") return False ix.begin_command_batch("Tint Surface") tint_tx = tint_surface(ctx, color=[(r.get_value()) / 255, (g.get_value()) / 255, (b.get_value()) / 255], strength=strength.get_value(), ix=ix) if tint_tx: ix.selection.deselect_all() ix.selection.add(tint_tx) ix.end_command_batch() sender.get_window().hide()
def blend_gui(): selection_copy = [] for selection in ix.selection: selection_copy.append(selection) if check_selection(selection_copy, is_kindof=[ "Texture", "MaterialPhysical", "Displacement", "TextureNormalMap" ], min_num=2): ix.begin_command_batch("Blend items") blend_tx = quick_blend(selection_copy, ix=ix) ix.end_command_batch() if blend_tx: ix.selection.deselect_all() ix.selection.add(blend_tx) ix.application.check_for_events() else: ix.log_warning( "ERROR: Couldn't mix the selected items. \n" "Make sure to select either two or more Texture items, Normal Maps, Displacement Maps or PhysicalMaterials. \n" "Texture items can be of any type. Materials can only be of Physical category." )
def toggle_surface_complexity_gui(): ix.begin_command_batch("Toggle Surface Complexity") selection_copy = [] for selection in ix.selection: selection_copy.append(selection) if check_selection(selection_copy, is_kindof=[ "MaterialPhysicalStandard", "MaterialPhysicalBlend", "OfContext" ]): for selected in selection_copy: if selected.is_context(): ctx = selected else: ctx = selected.get_context() toggle_surface_complexity(ctx, ix=ix) ix.end_command_batch() for selection in selection_copy: ix.selection.add(selection) ix.application.check_for_events() else: ix.log_warning( "Please select either a Physical Standard material or its parent context." )
def srf2_picker_refresh(self, sender, evtid): if check_selection(ix.selection, is_kindof=[ "MaterialPhysicalStandard", "MaterialPhysicalBlend", "OfContext" ], max_num=1): if ix.selection[0].is_context(): ctx = ix.selection[0] else: ctx = ix.selection[0].get_context() if not get_mtl_from_context(ctx, ix=ix): return None srf2_txt.set_text(str(ctx)) ctx2_name = ctx.get_name() name_txt.set_text(ctx2_name + MIX_SUFFIX) ix.selection.deselect_all() ix.selection.add(ctx.get_parent()) else: ix.log_warning("Please select a valid cover material.\n") srf2_txt.set_text("")