def register(): for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.automirror = PointerProperty(type=AutoMirrorProps) update_panel(None, bpy.context)
def register(): bpy.utils.register_module(__name__) bpy.types.Scene.csv_to_custom_props = PointerProperty( type=addPropsSettings)
def init(): bpy.types.Lamp.luxcore = PointerProperty(type=LuxCoreLightProps)
class ARStreamingProperties(bpy.types.PropertyGroup): ip_address: StringProperty(name="IP Address") target_object: PointerProperty(name="Target", type=bpy.types.Object) rotate_z: FloatProperty(name="Rotate Z", default=0.0, subtype='ANGLE', unit='ROTATION') scale: FloatProperty(name="Scale", default=1.0)
def plug_in(cls): register_class(SizeProperties), bpy.types.WindowManager.size_props = PointerProperty( name="Size Properties", type=SizeProperties) register_class(cls)
def register(): for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)
class FlipFluidDomainProperties(bpy.types.PropertyGroup): conv = vcu.convert_attribute_to_28 render = PointerProperty( name="Domain Render Properties", description="", type=domain_render_properties.DomainRenderProperties, ) exec(conv("render")) bake = PointerProperty( name="Domain Bake Properties", description="", type=domain_bake_properties.DomainBakeProperties, ) exec(conv("bake")) simulation = PointerProperty( name="Domain Simulation Properties", description="", type=domain_simulation_properties.DomainSimulationProperties, ) exec(conv("simulation")) cache = PointerProperty( name="Domain Cache Properties", description="", type=domain_cache_properties.DomainCacheProperties, ) exec(conv("cache")) surface = PointerProperty( name="Domain Surface Properties", description="", type=domain_surface_properties.DomainSurfaceProperties, ) exec(conv("surface")) whitewater = PointerProperty( name="Domain Whitewater Properties", description="", type=domain_whitewater_properties.DomainWhitewaterProperties, ) exec(conv("whitewater")) world = PointerProperty( name="Domain World Properties", description="", type=domain_world_properties.DomainWorldProperties, ) exec(conv("world")) presets = PointerProperty( name="Domain Presets Properties", description="", type=domain_presets_properties.DomainPresetsProperties, ) exec(conv("presets")) materials = PointerProperty( name="Domain Materials Properties", description="", type=domain_materials_properties.DomainMaterialsProperties, ) exec(conv("materials")) advanced = PointerProperty( name="Domain Advanced Properties", description="", type=domain_advanced_properties.DomainAdvancedProperties, ) exec(conv("advanced")) debug = PointerProperty( name="Domain Debug Properties", description="", type=domain_debug_properties.DomainDebugProperties, ) exec(conv("debug")) stats = PointerProperty( name="Domain Stats Properties", description="", type=domain_stats_properties.DomainStatsProperties, ) exec(conv("stats")) mesh_cache = PointerProperty( name="Domain Mesh Cache", description="", type=flip_fluid_cache.FlipFluidCache, ) exec(conv("mesh_cache")) property_registry = PointerProperty( name="Domain Property Registry", description="", type=preset_properties.PresetRegistry, ) exec(conv("property_registry")) def initialize(self): self.simulation.initialize() self.cache.initialize() self.advanced.initialize() self.materials.initialize() self._initialize_cache() self._initialize_property_registry() self.presets.initialize() def dummy_initialize(self): self.simulation.initialize() self.materials.initialize() self._initialize_property_registry() def destroy(self): self._delete_cache() def get_property_from_path(self, path): elements = path.split(".") if elements[0] == "domain": elements.pop(0) prop = self for e in elements: if not hasattr(prop, e): return None prop = getattr(prop, e) if (isinstance(prop, Vector) or isinstance(prop, Color) or (hasattr(prop, "__iter__") and not isinstance(prop, str))): new_prop = [] for x in prop: new_prop.append(x) prop = new_prop elif hasattr(prop, "is_min_max_property"): prop = [prop.value_min, prop.value_max] return prop def set_property_from_path(self, path, value): elements = path.split(".") if elements[0] == "domain": elements.pop(0) identifier = elements.pop() prop_group = self for e in elements: if not hasattr(prop_group, e): return False prop_group = getattr(prop_group, e) if not hasattr(prop_group, identifier): return False try: prop = getattr(prop_group, identifier) if hasattr(prop, "is_min_max_property"): prop.value_min = value[0] prop.value_max = value[1] else: setattr(prop_group, identifier, value) except: return False return True def _initialize_cache(self): self.mesh_cache.initialize_cache_objects() def _delete_cache(self): domain_object = bpy.context.scene.flip_fluid.get_domain_object() if domain_object is None: return self.mesh_cache.delete_cache_objects() def _initialize_property_registry(self): self.property_registry.clear() self.render.register_preset_properties(self.property_registry, "domain.render") self.bake.register_preset_properties(self.property_registry, "domain.bake") self.simulation.register_preset_properties(self.property_registry, "domain.simulation") self.cache.register_preset_properties(self.property_registry, "domain.cache") self.surface.register_preset_properties(self.property_registry, "domain.surface") self.whitewater.register_preset_properties(self.property_registry, "domain.whitewater") self.world.register_preset_properties(self.property_registry, "domain.world") self.presets.register_preset_properties(self.property_registry, "domain.presets") self.materials.register_preset_properties(self.property_registry, "domain.materials") self.advanced.register_preset_properties(self.property_registry, "domain.advanced") self.debug.register_preset_properties(self.property_registry, "domain.debug") self.stats.register_preset_properties(self.property_registry, "domain.stats") self._validate_property_registry() def _validate_property_registry(self): for p in self.property_registry.properties: path = p.path base, group, identifier = path.split('.', 2) if not hasattr(self, group): print("Property Registry Error: Unknown Property Group <" + group + ", " + path + ">") continue prop_group = getattr(self, group) if not hasattr(prop_group, identifier): print("Property Registry Error: Unknown Identifier <" + identifier + ", " + path + ">") continue def scene_update_post(self, scene): self.render.scene_update_post(scene) self.simulation.scene_update_post(scene) self.surface.scene_update_post(scene) self.world.scene_update_post(scene) self.debug.scene_update_post(scene) self.stats.scene_update_post(scene) self.materials.scene_update_post(scene) def frame_change_post(self, scene, depsgraph=None): self.world.frame_change_post(scene) self.stats.frame_change_post(scene, depsgraph) def load_pre(self): self.cache.load_pre() def load_post(self): self.simulation.load_post() self.bake.load_post() self.cache.load_post() self.stats.load_post() self.debug.load_post() #self.presets.load_post() self.advanced.load_post() self.materials.load_post() self.mesh_cache.load_post() self._initialize_property_registry() def save_pre(self): self.debug.save_pre() def save_post(self): self.cache.save_post()
class LuxCoreMaterialProps(bpy.types.PropertyGroup): node_tree = PointerProperty(name="Node Tree", type=bpy.types.NodeTree)
def register(cls): bpy.types.Material.cycles = PointerProperty(type=cls, name="Cycles Material Settings", description="Cycles material settings") cls.sample_as_light = BoolProperty(name="Sample as Lamp", description="Use direct light sampling for this material, disabling may reduce overall noise for large objects that emit little light compared to other light sources", default=True) cls.homogeneous_volume = BoolProperty(name="Homogeneous Volume", description="When using volume rendering, assume volume has the same density everywhere, for faster rendering", default=False)
class HistoryUnmirroredCollection(bpy.types.PropertyGroup): name: StringProperty() obj: PointerProperty(name="取消镜像历史", type=bpy.types.Object)
def init(): bpy.types.Material.luxcore = PointerProperty(type=LuxCoreMaterialProps)
class HistoryObjectsCollection(bpy.types.PropertyGroup): name: StringProperty() obj: PointerProperty(name="对象历史", type=bpy.types.Object)
def register(cls): bpy.types.Scene.starter_library = PointerProperty( name="Starter Library Props", description="Starter Library Props", type=cls, )
class JewelCraftPreferences(AddonPreferences): bl_idname = __package__ active_section: EnumProperty(items=( ("ASSET_MANAGER", "Asset Manager", ""), ("WEIGHTING", "Weighting", ""), ("PRODUCT_REPORT", "Product Report", ""), ("THEMES", "Themes", ""), ("UPDATER", "Update", ""), ), ) update_auto_check: BoolProperty( name="Automatically check for updates", description="Automatically check for updates with specified interval", default=True, ) update_interval: EnumProperty( name="Interval", description="Interval", items=( ("1", "Once a day", ""), ("7", "Once a week", ""), ("30", "Once a month", ""), ), default="7", ) asset_name_from_obj: BoolProperty( name="Asset name from active object", description="Use active object name when creating new asset", ) use_custom_asset_dir: BoolProperty( name="Use custom library folder", description= "Set custom asset library folder, if disabled the default library folder will be used", update=update_asset_refresh, ) custom_asset_dir: StringProperty( name="Library Folder Path", description="Custom library folder path", subtype="DIR_PATH", update=update_asset_refresh, ) display_asset_name: BoolProperty( name="Display asset name", description="Display asset name in Tool Shelf", ) weighting_hide_default_sets: BoolProperty( name="Hide default sets", description="Hide default JewelCraft sets from weighting sets menu", update=dynamic_lists.weighting_set_refresh, ) weighting_set_use_custom_dir: BoolProperty( name="Use custom library folder", description= "Set custom asset library folder, if disabled the default library folder will be used", update=dynamic_lists.weighting_set_refresh, ) weighting_set_custom_dir: StringProperty( name="Library Folder Path", description="Custom library folder path", subtype="DIR_PATH", update=dynamic_lists.weighting_set_refresh, ) weighting_materials: PointerProperty(type=JewelCraftMaterialsList) weighting_list_show_composition: BoolProperty( name="Show composition", description="Display material composition in the list", ) weighting_list_show_density: BoolProperty( name="Show density", description="Display material density in the list", ) product_report_lang: EnumProperty( name="Report Language", description="Product report language", items=( ("AUTO", "Auto (Auto)", "Use user preferences language setting"), ("en_US", "English (English)", ""), ("ru_RU", "Russian (Русский)", ""), ), ) product_report_display: BoolProperty( name="Display in a new window", description="Display product report in new window", default=True, ) product_report_save: BoolProperty( name="Save to file", description="Save product report to file in project folder", default=True, ) product_report_use_hidden_gems: BoolProperty( name="Hidden gems", description="Show warning if there are hidden gem objects in the scene", default=True, ) widget_selection_only: BoolProperty( name="Selection only", description="Draw widgets only for selected objects", ) widget_use_overrides: BoolProperty( name="Use overrides", description="Use object defined widget overrides", default=True, ) widget_overrides_only: BoolProperty( name="Overrides only", description="Display only object defined widget overrides", ) widget_show_in_front: BoolProperty( name="In Front", description="Draw widgets in front of objects", ) widget_color: FloatVectorProperty( name="Color", default=(0.9, 0.9, 0.9, 1.0), size=4, min=0.0, soft_max=1.0, subtype="COLOR", ) widget_linewidth: IntProperty( name="Line Width", default=2, min=1, soft_max=5, subtype="PIXEL", ) widget_distance: FloatProperty( name="Distance", default=0.2, min=0.0, step=1, precision=2, unit="LENGTH", ) color_prongs: FloatVectorProperty( name="Prongs", default=(0.8, 0.8, 0.8, 1.0), size=4, min=0.0, soft_max=1.0, subtype="COLOR", ) color_cutter: FloatVectorProperty( name="Cutter", default=(0.8, 0.8, 0.8, 1.0), size=4, min=0.0, soft_max=1.0, subtype="COLOR", ) theme_icon: EnumProperty( name="Icons", items=( ("LIGHT", "Light", ""), ("DARK", "Dark", ""), ), ) def draw(self, context): layout = self.layout layout.use_property_split = True layout.use_property_decorate = False split = layout.split(factor=0.25) col = split.column() col.use_property_split = False col.scale_y = 1.3 col.prop(self, "active_section", expand=True) box = split.box() if self.active_section == "ASSET_MANAGER": col = box.column() col.prop(self, "asset_name_from_obj") col.prop(self, "display_asset_name") col.prop(self, "use_custom_asset_dir") sub = col.row() sub.active = self.use_custom_asset_dir sub.prop(self, "custom_asset_dir") elif self.active_section == "WEIGHTING": col = box.column() col.prop(self, "weighting_hide_default_sets") col.prop(self, "weighting_set_use_custom_dir") sub = col.row() sub.active = self.weighting_set_use_custom_dir sub.prop(self, "weighting_set_custom_dir") box.label(text="Materials list") row = box.row() row.template_list( "VIEW3D_UL_jewelcraft_weighting_set", "", self.weighting_materials, "coll", self.weighting_materials, "index", ) col = row.column(align=True) col.operator("wm.jewelcraft_ul_item_add", text="", icon="ADD") col.operator("wm.jewelcraft_ul_item_del", text="", icon="REMOVE") col.separator() col.operator("wm.jewelcraft_ul_item_move", text="", icon="TRIA_UP").move_up = True col.operator("wm.jewelcraft_ul_item_move", text="", icon="TRIA_DOWN") col = box.column() col.prop(self, "weighting_list_show_composition") col.prop(self, "weighting_list_show_density") elif self.active_section == "PRODUCT_REPORT": col = box.column() col.prop(self, "product_report_display") col.prop(self, "product_report_save") col.prop(self, "product_report_lang") box.label(text="Warnings") box.prop(self, "product_report_use_hidden_gems") elif self.active_section == "THEMES": box.label(text="Interface") col = box.column() col.prop(self, "theme_icon") box.label(text="Widgets") col = box.column() col.prop(self, "widget_selection_only") col.prop(self, "widget_use_overrides") sub = col.column() sub.active = self.widget_use_overrides sub.prop(self, "widget_overrides_only") col.prop(self, "widget_show_in_front") col.prop(self, "widget_color") col.prop(self, "widget_linewidth") col.prop(self, "widget_distance") box.label(text="Materials") col = box.column() col.prop(self, "color_prongs") col.prop(self, "color_cutter") elif self.active_section == "UPDATER": box.use_property_split = False addon_updater_ops.update_settings_ui(self, context, element=box)
def register(cls): bpy.types.Scene.cycles = PointerProperty( name="Cycles Render Settings", description="Cycles render settings", type=cls, ) cls.device = EnumProperty( name="Device", description="Device to use for rendering", items=enum_devices, default='CPU', ) cls.feature_set = EnumProperty( name="Feature Set", description="Feature set to use for rendering", items=enum_feature_set, default='SUPPORTED', ) cls.shading_system = BoolProperty( name="Open Shading Language", description="Use Open Shading Language (CPU rendering only)", ) cls.progressive = EnumProperty( name="Integrator", description="Method to sample lights and materials", items=enum_integrator, default='PATH', ) cls.use_square_samples = BoolProperty( name="Square Samples", description="Square sampling values for easier artist control", default=False, ) cls.samples = IntProperty( name="Samples", description="Number of samples to render for each pixel", min=1, max=2147483647, default=128, ) cls.preview_samples = IntProperty( name="Preview Samples", description="Number of samples to render in the viewport, unlimited if 0", min=0, max=2147483647, default=32, ) cls.preview_pause = BoolProperty( name="Pause Preview", description="Pause all viewport preview renders", default=False, ) cls.preview_active_layer = BoolProperty( name="Preview Active Layer", description="Preview active render layer in viewport", default=False, ) cls.aa_samples = IntProperty( name="AA Samples", description="Number of antialiasing samples to render for each pixel", min=1, max=10000, default=4, ) cls.preview_aa_samples = IntProperty( name="AA Samples", description="Number of antialiasing samples to render in the viewport, unlimited if 0", min=0, max=10000, default=4, ) cls.diffuse_samples = IntProperty( name="Diffuse Samples", description="Number of diffuse bounce samples to render for each AA sample", min=1, max=10000, default=1, ) cls.glossy_samples = IntProperty( name="Glossy Samples", description="Number of glossy bounce samples to render for each AA sample", min=1, max=10000, default=1, ) cls.transmission_samples = IntProperty( name="Transmission Samples", description="Number of transmission bounce samples to render for each AA sample", min=1, max=10000, default=1, ) cls.ao_samples = IntProperty( name="Ambient Occlusion Samples", description="Number of ambient occlusion samples to render for each AA sample", min=1, max=10000, default=1, ) cls.mesh_light_samples = IntProperty( name="Mesh Light Samples", description="Number of mesh emission light samples to render for each AA sample", min=1, max=10000, default=1, ) cls.subsurface_samples = IntProperty( name="Subsurface Samples", description="Number of subsurface scattering samples to render for each AA sample", min=1, max=10000, default=1, ) cls.volume_samples = IntProperty( name="Volume Samples", description="Number of volume scattering samples to render for each AA sample", min=1, max=10000, default=1, ) cls.sampling_pattern = EnumProperty( name="Sampling Pattern", description="Random sampling pattern used by the integrator", items=enum_sampling_pattern, default='SOBOL', ) cls.use_layer_samples = EnumProperty( name="Layer Samples", description="How to use per render layer sample settings", items=enum_use_layer_samples, default='USE', ) cls.sample_all_lights_direct = BoolProperty( name="Sample All Direct Lights", description="Sample all lights (for direct samples), rather than randomly picking one", default=True, ) cls.sample_all_lights_indirect = BoolProperty( name="Sample All Indirect Lights", description="Sample all lights (for indirect samples), rather than randomly picking one", default=True, ) cls.caustics_reflective = BoolProperty( name="Reflective Caustics", description="Use reflective caustics, resulting in a brighter image (more noise but added realism)", default=True, ) cls.caustics_refractive = BoolProperty( name="Refractive Caustics", description="Use refractive caustics, resulting in a brighter image (more noise but added realism)", default=True, ) cls.blur_glossy = FloatProperty( name="Filter Glossy", description="Adaptively blur glossy shaders after blurry bounces, " "to reduce noise at the cost of accuracy", min=0.0, max=10.0, default=0.0, ) cls.min_bounces = IntProperty( name="Min Bounces", description="Minimum number of bounces, setting this lower " "than the maximum enables probabilistic path " "termination (faster but noisier)", min=0, max=1024, default=3, ) cls.max_bounces = IntProperty( name="Max Bounces", description="Total maximum number of bounces", min=0, max=1024, default=12, ) cls.diffuse_bounces = IntProperty( name="Diffuse Bounces", description="Maximum number of diffuse reflection bounces, bounded by total maximum", min=0, max=1024, default=4, ) cls.glossy_bounces = IntProperty( name="Glossy Bounces", description="Maximum number of glossy reflection bounces, bounded by total maximum", min=0, max=1024, default=4, ) cls.transmission_bounces = IntProperty( name="Transmission Bounces", description="Maximum number of transmission bounces, bounded by total maximum", min=0, max=1024, default=12, ) cls.volume_bounces = IntProperty( name="Volume Bounces", description="Maximum number of volumetric scattering events", min=0, max=1024, default=0, ) cls.transparent_min_bounces = IntProperty( name="Transparent Min Bounces", description="Minimum number of transparent bounces, setting " "this lower than the maximum enables " "probabilistic path termination (faster but " "noisier)", min=0, max=1024, default=8, ) cls.transparent_max_bounces = IntProperty( name="Transparent Max Bounces", description="Maximum number of transparent bounces", min=0, max=1024, default=8, ) cls.use_transparent_shadows = BoolProperty( name="Transparent Shadows", description="Use transparency of surfaces for rendering shadows", default=True, ) cls.volume_step_size = FloatProperty( name="Step Size", description="Distance between volume shader samples when rendering the volume " "(lower values give more accurate and detailed results, but also increased render time)", default=0.1, min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0 ) cls.volume_max_steps = IntProperty( name="Max Steps", description="Maximum number of steps through the volume before giving up, " "to avoid extremely long render times with big objects or small step sizes", default=1024, min=2, max=65536 ) cls.dicing_rate = FloatProperty( name="Dicing Rate", description="Size of a micropolygon in pixels", min=0.1, max=1000.0, default=1.0, ) cls.preview_dicing_rate = FloatProperty( name="Preview Dicing Rate", description="Size of a micropolygon in pixels during preview render", min=0.1, max=1000.0, default=8.0, ) cls.max_subdivisions = IntProperty( name="Max Subdivisions", description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation", min=0, max=16, default=12, ) cls.film_exposure = FloatProperty( name="Exposure", description="Image brightness scale", min=0.0, max=10.0, default=1.0, ) cls.film_transparent = BoolProperty( name="Transparent", description="World background is transparent with premultiplied alpha", default=False, ) # Really annoyingly, we have to keep it around for a few releases, # otherwise forward compatibility breaks in really bad manner: CRASH! # # TODO(sergey): Remove this during 2.8x series of Blender. cls.filter_type = EnumProperty( name="Filter Type", description="Pixel filter type", items=enum_filter_types, default='BLACKMAN_HARRIS', ) cls.pixel_filter_type = EnumProperty( name="Filter Type", description="Pixel filter type", items=enum_filter_types, default='BLACKMAN_HARRIS', ) cls.filter_width = FloatProperty( name="Filter Width", description="Pixel filter width", min=0.01, max=10.0, default=1.5, ) cls.seed = IntProperty( name="Seed", description="Seed value for integrator to get different noise patterns", min=0, max=2147483647, default=0, ) cls.use_animated_seed = BoolProperty( name="Use Animated Seed", description="Use different seed values (and hence noise patterns) at different frames", default=False, ) cls.sample_clamp_direct = FloatProperty( name="Clamp Direct", description="If non-zero, the maximum value for a direct sample, " "higher values will be scaled down to avoid too " "much noise and slow convergence at the cost of accuracy", min=0.0, max=1e8, default=0.0, ) cls.sample_clamp_indirect = FloatProperty( name="Clamp Indirect", description="If non-zero, the maximum value for an indirect sample, " "higher values will be scaled down to avoid too " "much noise and slow convergence at the cost of accuracy", min=0.0, max=1e8, default=0.0, ) cls.debug_tile_size = IntProperty( name="Tile Size", description="", min=1, max=4096, default=1024, ) cls.preview_start_resolution = IntProperty( name="Start Resolution", description="Resolution to start rendering preview at, " "progressively increasing it to the full viewport size", min=8, max=16384, default=64, ) cls.debug_reset_timeout = FloatProperty( name="Reset timeout", description="", min=0.01, max=10.0, default=0.1, ) cls.debug_cancel_timeout = FloatProperty( name="Cancel timeout", description="", min=0.01, max=10.0, default=0.1, ) cls.debug_text_timeout = FloatProperty( name="Text timeout", description="", min=0.01, max=10.0, default=1.0, ) cls.debug_bvh_type = EnumProperty( name="Viewport BVH Type", description="Choose between faster updates, or faster render", items=enum_bvh_types, default='DYNAMIC_BVH', ) cls.debug_use_spatial_splits = BoolProperty( name="Use Spatial Splits", description="Use BVH spatial splits: longer builder time, faster render", default=False, ) cls.tile_order = EnumProperty( name="Tile Order", description="Tile order for rendering", items=enum_tile_order, default='HILBERT_SPIRAL', options=set(), # Not animatable! ) cls.use_progressive_refine = BoolProperty( name="Progressive Refine", description="Instead of rendering each tile until it is finished, " "refine the whole image progressively " "(this renders somewhat slower, " "but time can be saved by manually stopping the render when the noise is low enough)", default=False, ) cls.bake_type = EnumProperty( name="Bake Type", default='COMBINED', description="Type of pass to bake", items=( ('COMBINED', "Combined", ""), ('AO', "Ambient Occlusion", ""), ('SHADOW', "Shadow", ""), ('NORMAL', "Normal", ""), ('UV', "UV", ""), ('EMIT', "Emit", ""), ('ENVIRONMENT', "Environment", ""), ('DIFFUSE', "Diffuse", ""), ('GLOSSY', "Glossy", ""), ('TRANSMISSION', "Transmission", ""), ('SUBSURFACE', "Subsurface", ""), ), ) cls.use_camera_cull = BoolProperty( name="Use Camera Cull", description="Allow objects to be culled based on the camera frustum", default=False, ) cls.camera_cull_margin = FloatProperty( name="Camera Cull Margin", description="Margin for the camera space culling", default=0.1, min=0.0, max=5.0 ) cls.motion_blur_position = EnumProperty( name="Motion Blur Position", default='CENTER', description="Offset for the shutter's time interval, allows to change the motion blur trails", items=( ('START', "Start on Frame", "The shutter opens at the current frame"), ('CENTER', "Center on Frame", "The shutter is open during the current frame"), ('END', "End on Frame", "The shutter closes at the current frame"), ), ) cls.rolling_shutter_type = EnumProperty( name="Shutter Type", default='NONE', description="Type of rolling shutter effect matching CMOS-based cameras", items=( ('NONE', "None", "No rolling shutter effect used"), ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom") # TODO(seergey): Are there real cameras with different scanning direction? ), ) cls.rolling_shutter_duration = FloatProperty( name="Rolling Shutter Duration", description="Scanline \"exposure\" time for the rolling shutter effect", default=0.1, min=0.0, max=1.0, ) # Various fine-tuning debug flags def devices_update_callback(self, context): import _cycles scene = context.scene.as_pointer() return _cycles.debug_flags_update(scene) cls.debug_use_cpu_avx2 = BoolProperty(name="AVX2", default=True) cls.debug_use_cpu_avx = BoolProperty(name="AVX", default=True) cls.debug_use_cpu_sse41 = BoolProperty(name="SSE41", default=True) cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True) cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True) cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True) cls.debug_opencl_kernel_type = EnumProperty( name="OpenCL Kernel Type", default='DEFAULT', items=( ('DEFAULT', "Default", ""), ('MEGA', "Mega", ""), ('SPLIT', "Split", ""), ), update=devices_update_callback ) cls.debug_opencl_device_type = EnumProperty( name="OpenCL Device Type", default='ALL', items=( ('NONE', "None", ""), ('ALL', "All", ""), ('DEFAULT', "Default", ""), ('CPU', "CPU", ""), ('GPU', "GPU", ""), ('ACCELERATOR', "Accelerator", ""), ), update=devices_update_callback ) cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
def register(cls): bpy.types.Lamp.cycles = PointerProperty(type=cls, name="Cycles Lamp Settings", description="Cycles lamp settings") cls.cast_shadow = BoolProperty(name="Cast Shadow", description="Lamp casts shadows", default=True)
def register(cls): import math bpy.types.Camera.cycles = PointerProperty( name="Cycles Camera Settings", description="Cycles camera settings", type=cls, ) cls.aperture_type = EnumProperty( name="Aperture Type", description="Use f-stop number or aperture radius", items=enum_aperture_types, default='RADIUS', ) cls.aperture_fstop = FloatProperty( name="Aperture f-stop", description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", min=0.0, soft_min=0.1, soft_max=64.0, default=5.6, step=10, precision=1, ) cls.aperture_size = FloatProperty( name="Aperture Size", description="Radius of the aperture for depth of field (higher values give more defocus)", min=0.0, soft_max=10.0, default=0.0, step=1, precision=4, subtype='DISTANCE', ) cls.aperture_blades = IntProperty( name="Aperture Blades", description="Number of blades in aperture for polygonal bokeh (at least 3)", min=0, max=100, default=0, ) cls.aperture_rotation = FloatProperty( name="Aperture Rotation", description="Rotation of blades in aperture", soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE', default=0, ) cls.aperture_ratio = FloatProperty( name="Aperture Ratio", description="Distortion to simulate anamorphic lens bokeh", min=0.01, soft_min=1.0, soft_max=2.0, default=1.0, precision=4, ) cls.panorama_type = EnumProperty( name="Panorama Type", description="Distortion to use for the calculation", items=enum_panorama_types, default='FISHEYE_EQUISOLID', ) cls.fisheye_fov = FloatProperty( name="Field of View", description="Field of view for the fisheye lens", min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi, subtype='ANGLE', default=math.pi, ) cls.fisheye_lens = FloatProperty( name="Fisheye Lens", description="Lens focal length (mm)", min=0.01, soft_max=15.0, max=100.0, default=10.5, ) cls.latitude_min = FloatProperty( name="Min Latitude", description="Minimum latitude (vertical angle) for the equirectangular lens", min=-0.5 * math.pi, max=0.5 * math.pi, subtype='ANGLE', default=-0.5 * math.pi, ) cls.latitude_max = FloatProperty( name="Max Latitude", description="Maximum latitude (vertical angle) for the equirectangular lens", min=-0.5 * math.pi, max=0.5 * math.pi, subtype='ANGLE', default=0.5 * math.pi, ) cls.longitude_min = FloatProperty( name="Min Longitude", description="Minimum longitude (horizontal angle) for the equirectangular lens", min=-math.pi, max=math.pi, subtype='ANGLE', default=-math.pi, ) cls.longitude_max = FloatProperty( name="Max Longitude", description="Maximum longitude (horizontal angle) for the equirectangular lens", min=-math.pi, max=math.pi, subtype='ANGLE', default=math.pi, )
def register(cls): bpy.types.World.cycles = PointerProperty(type=cls, name="Cycles World Settings", description="Cycles world settings")
class RailProperty(bpy.types.PropertyGroup): fill_types = [ ("POSTS", "Posts", "", 0), ("RAILS", "Rails", "", 1), ("WALL", "Wall", "", 2), ] fill: EnumProperty( name="Fill Type", items=fill_types, default="POSTS", description="Type of railing", ) corner_post_width: FloatProperty( name="Width", min=get_scaled_unit(0.01), max=get_scaled_unit(100.0), default=get_scaled_unit(0.1), unit="LENGTH", description="Width of each corner post", ) corner_post_height: FloatProperty( name="Height", min=get_scaled_unit(0.01), max=get_scaled_unit(100.0), default=get_scaled_unit(0.7), unit="LENGTH", description="Height of each corner post", ) has_corner_post: BoolProperty( name="Corner Posts", default=True, description="Whether the railing has corner posts", ) offset: FloatProperty( name="Offset", default=get_scaled_unit(0.05), unit="LENGTH", description="Railings offset", ) post_fill: PointerProperty(type=PostFillProperty) rail_fill: PointerProperty(type=RailFillProperty) wall_fill: PointerProperty(type=WallFillProperty) show_extra_props: BoolProperty() bottom_rail: BoolProperty( name="Add Bottom Rail", default=True, ) bottom_rail_offset: FloatProperty( name="Rail Offset", min=get_scaled_unit(-1.0), max=get_scaled_unit(1.0), default=get_scaled_unit(0.0), unit="LENGTH", description="Offset of the bottom rail", ) def draw(self, context, layout): row = layout.row() row.prop(self, "offset", text="Railing Offset") row = layout.row() row.prop_menu_enum(self, "fill", text=self.fill.title()) { "POSTS": self.post_fill, "RAILS": self.rail_fill, "WALL": self.wall_fill }.get(self.fill).draw(context, layout) if self.fill in ["POSTS", "WALL"] and self.show_extra_props: row = layout.row(align=True) row.prop(self, "bottom_rail", toggle=True) row.prop(self, "bottom_rail_offset") layout.label(text="Corner Posts") row = layout.row(align=True) row.prop(self, "corner_post_width") row.prop(self, "corner_post_height")
def register(cls): bpy.types.Scene.cycles = PointerProperty(type=cls, name="Cycles Render Settings", description="Cycles render settings") cls.device = EnumProperty(name="Device", description="Device to use for rendering", items=enums.devices, default="CPU") cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU", items=enums.gpu_type, default="CUDA") cls.feature_set = EnumProperty(name="Feature Set", description="Feature set to use for rendering", items=enums.feature_set, default="SUPPORTED") cls.shading_system = EnumProperty(name="Shading System", description="Shading system to use for rendering", items=enums.shading_systems, default="GPU_COMPATIBLE") cls.samples = IntProperty(name="Samples", description="Number of samples to render for each pixel", default=10, min=1, max=2147483647) cls.preview_samples = IntProperty(name="Preview Samples", description="Number of samples to render in the viewport, unlimited if 0", default=10, min=0, max=2147483647) cls.preview_pause = BoolProperty(name="Pause Preview", description="Pause all viewport preview renders", default=False) cls.no_caustics = BoolProperty(name="No Caustics", description="Leave out caustics, resulting in a darker image with less noise", default=False) cls.blur_caustics = FloatProperty(name="Blur Caustics", description="Blur caustics to reduce noise", default=0.0, min=0.0, max=1.0) cls.min_bounces = IntProperty(name="Min Bounces", description="Minimum number of bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)", default=3, min=0, max=1024) cls.max_bounces = IntProperty(name="Max Bounces", description="Total maximum number of bounces", default=8, min=0, max=1024) cls.diffuse_bounces = IntProperty(name="Diffuse Bounces", description="Maximum number of diffuse reflection bounces, bounded by total maximum", default=128, min=0, max=1024) cls.glossy_bounces = IntProperty(name="Glossy Bounces", description="Maximum number of glossy reflection bounces, bounded by total maximum", default=128, min=0, max=1024) cls.transmission_bounces = IntProperty(name="Transmission Bounces", description="Maximum number of transmission bounces, bounded by total maximum", default=128, min=0, max=1024) cls.transparent_min_bounces = IntProperty(name="Transparent Min Bounces", description="Minimum number of transparent bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)", default=8, min=0, max=1024) cls.transparent_max_bounces = IntProperty(name="Transparent Max Bounces", description="Maximum number of transparent bounces", default=8, min=0, max=1024) cls.use_transparent_shadows = BoolProperty(name="Transparent Shadows", description="Use transparency of surfaces for rendering shadows", default=True) cls.film_exposure = FloatProperty(name="Exposure", description="Image brightness scale", default=1.0, min=0.0, max=10.0) cls.film_transparent = BoolProperty(name="Transparent", description="World background is transparent", default=False) cls.filter_type = EnumProperty(name="Filter Type", description="Pixel filter type", items=enums.filter_types, default="GAUSSIAN") cls.filter_width = FloatProperty(name="Filter Width", description="Pixel filter width", default=1.5, min=0.01, max=10.0) cls.seed = IntProperty(name="Seed", description="Seed value for integrator to get different noise patterns", default=0, min=0, max=2147483647) cls.debug_tile_size = IntProperty(name="Tile Size", description="", default=1024, min=1, max=4096) cls.debug_min_size = IntProperty(name="Min Size", description="", default=64, min=1, max=4096) cls.debug_reset_timeout = FloatProperty(name="Reset timeout", description="", default=0.1, min=0.01, max=10.0) cls.debug_cancel_timeout = FloatProperty(name="Cancel timeout", description="", default=0.1, min=0.01, max=10.0) cls.debug_text_timeout = FloatProperty(name="Text timeout", description="", default=1.0, min=0.01, max=10.0) cls.debug_bvh_type = EnumProperty(name="Viewport BVH Type", description="Choose between faster updates, or faster render", items=enums.bvh_types, default="DYNAMIC_BVH") cls.debug_use_spatial_splits = BoolProperty(name="Use Spatial Splits", description="Use BVH spatial splits: longer builder time, faster render", default=False)
def register(): for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.print_3d = PointerProperty(type=SceneProperties)
class RailProperty(bpy.types.PropertyGroup): fill_types = [ ("POSTS", "Posts", "", 0), ("RAILS", "Rails", "", 1), ("WALL", "Wall", "", 2), ] fill: EnumProperty( name="Fill Type", items=fill_types, default="POSTS", description="Type of railing", ) corner_post_width: FloatProperty( name="Width", min=0.01, max=100.0, default=0.1, unit="LENGTH", description="Width of each corner post", ) corner_post_height: FloatProperty( name="Height", min=0.01, max=100.0, default=0.7, unit="LENGTH", description="Height of each corner post", ) has_corner_post: BoolProperty( name="Corner Posts", default=True, description="Whether the railing has corner posts", ) offset: FloatProperty( name="Offset", default=0.05, unit="LENGTH", description="Railings offset", ) post_fill: PointerProperty(type=PostFillProperty) rail_fill: PointerProperty(type=RailFillProperty) wall_fill: PointerProperty(type=WallFillProperty) def init(self, stair_step_width=None, step_count=None): if stair_step_width and self.fill == "POSTS": if step_count > 1: initial_density = (self.post_fill.size * (step_count - 1)) / (stair_step_width * step_count) else: initial_density = (self.post_fill.size - 0.001) / ( 2 * stair_step_width ) # just enough to have 0 post on stairs self.post_fill.init(initial_density=initial_density) def draw(self, context, layout): row = layout.row() row.prop(self, "offset", text="Railing Offset") row = layout.row() row.prop_menu_enum(self, "fill", text=self.fill.title()) { "POSTS": self.post_fill, "RAILS": self.rail_fill, "WALL": self.wall_fill }.get(self.fill).draw(context, layout) layout.label(text="Corner Posts") row = layout.row(align=True) row.prop(self, "corner_post_width") row.prop(self, "corner_post_height")
class SvTypeViewerNodeV28(bpy.types.Node, SverchCustomTreeNode, SvObjHelper): bl_idname = 'SvTypeViewerNodeV28' bl_label = 'Typography Viewer' bl_icon = 'OUTLINER_OB_FONT' sv_icon = 'SV_TYPOGRAPHY_VIEWER' def captured_updateNode(self, context): if not self.updating_name_from_pointer: font_datablock = self.get_bpy_data_from_name( self.fontname, bpy.data.fonts) if font_datablock: self.font_pointer = font_datablock updateNode(self, context) def pointer_update(self, context): self.updating_name_from_pointer = True try: self.fontname = self.font_pointer.name if self.font_pointer else "" except Exception as err: self.info(err) self.updating_name_from_pointer = False updateNode(self, context) grouping: BoolProperty(default=False, update=SvObjHelper.group_state_update_handler) data_kind: StringProperty(name='data kind', default='FONT') show_options: BoolProperty(default=0) updating_name_from_pointer: BoolProperty(name="updating name") fontname: StringProperty(default='', update=captured_updateNode) font_pointer: PointerProperty(type=bpy.types.VectorFont, poll=lambda s, o: True, update=pointer_update, options={'SKIP_SAVE'}) fsize: FloatProperty(default=1.0, update=updateNode) # space space_character: FloatProperty(default=1.0, update=updateNode) space_word: FloatProperty(default=1.0, update=updateNode) space_line: FloatProperty(default=1.0, update=updateNode) yoffset: FloatProperty(default=0.0, update=updateNode) xoffset: FloatProperty(default=0.0, update=updateNode) # modifications offset: FloatProperty(default=0.0, update=updateNode) extrude: FloatProperty(default=0.0, update=updateNode) # bevel bevel_depth: FloatProperty(default=0.0, update=updateNode) bevel_resolution: IntProperty(default=0, update=updateNode) # orientation x | y align_x: bpy.props.EnumProperty(items=mode_options_x, description="Horizontal Alignment", default="LEFT", update=updateNode) align_y: bpy.props.EnumProperty(items=mode_options_y, description="Vertical Alignment", default="TOP_BASELINE", update=updateNode) def sv_init(self, context): self.sv_init_helper_basedata_name() self.inputs.new('SvStringsSocket', 'text') self.inputs.new('SvMatrixSocket', 'matrix') def draw_buttons(self, context, layout): self.draw_live_and_outliner(context, layout) self.draw_object_buttons(context, layout) col = layout.column(align=True) if col: row = col.row(align=True) row.prop(self, "grouping", text="Group", toggle=True) col = layout.column(align=True) col.prop(self, 'fsize') col.prop(self, 'show_options', toggle=True) if self.show_options: col.label(text='position') row = col.row(align=True) if row: row.prop(self, 'xoffset', text='XOFF') row.prop(self, 'yoffset', text='YOFF') split = col.split() col1 = split.column() col1.prop(self, 'space_character', text='CH') col1.prop(self, 'space_word', text='W') col1.prop(self, 'space_line', text='L') col.label(text='modifications') col.prop(self, 'offset') col.prop(self, 'extrude') col.label(text='bevel') col.prop(self, 'bevel_depth') col.prop(self, 'bevel_resolution') col.label(text="alignment") row = col.row(align=True) row.prop(self, 'align_x', text="") row.prop(self, 'align_y', text="") col.separator() def draw_buttons_ext(self, context, layout): shf = 'node.sv_fontfile_importer_mk1' self.draw_buttons(context, layout) self.draw_ext_object_buttons(context, layout) col = layout.column(align=True) row = col.row(align=True) row.prop_search(self, 'font_pointer', bpy.data, 'fonts', text='', icon='FONT_DATA') row.operator(shf, text='', icon='ZOOM_IN') row = layout.row() row.prop(self, 'parent_to_empty', text='parented') if self.parent_to_empty: row.label(text=self.parent_name) def process(self): if (not self.activate) or (not self.inputs['text'].is_linked): return # no autorepeat yet. text = self.inputs['text'].sv_get(default=[['sv_text']])[0] matrices = self.inputs['matrix'].sv_get(default=[Matrix()]) with self.sv_throttle_tree_update(): if self.parent_to_empty: mtname = 'Empty_' + self.basedata_name self.parent_name = mtname scene = bpy.context.scene collection = scene.collection if not mtname in bpy.data.objects: empty = bpy.data.objects.new(mtname, None) collection.objects.link(empty) bpy.context.view_layer.update() last_index = 0 for obj_index, txt_content in enumerate(text): matrix = matrices[obj_index % len(matrices)] if isinstance(txt_content, list) and (len(txt_content) == 1): txt_content = txt_content[0] else: txt_content = str(txt_content) make_text_object(self, obj_index, bpy.context, (txt_content, matrix)) last_index = obj_index self.remove_non_updated_objects(last_index) objs = self.get_children() if self.grouping: self.to_collection(objs) self.set_corresponding_materials() for obj in objs: if self.parent_to_empty: obj.parent = bpy.data.objects[mtname] elif obj.parent: obj.parent = None def draw_label(self): return f"TV {self.basedata_name}"
class SvProfileNodeMK3(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ''' Triggers: svg-like 2d profiles Tooltip: Generate multiple parameteric 2d profiles using SVG like syntax SvProfileNode generates one or more profiles / elevation segments using; assignments, variables, and a string descriptor similar to SVG. This node expects simple input, or vectorized input. - sockets with no input are automatically 0, not None - The longest input array will be used to extend the shorter ones, using last value repeat. ''' bl_idname = 'SvProfileNodeMK3' bl_label = 'Profile Parametric Mk3' bl_icon = 'SYNTAX_ON' axis_options = [("X", "X", "", 0), ("Y", "Y", "", 1), ("Z", "Z", "", 2)] selected_axis: EnumProperty( items=axis_options, update=updateNode, name="Type of axis", description="offers basic axis output vectors X|Y|Z", default="Z") def pointer_update(self, context): if self.file_pointer: self.filename = self.file_pointer.name else: self.filename = "" self.adjust_sockets() updateNode(self, context) filename: StringProperty(default="") file_pointer: PointerProperty(type=bpy.types.Text, poll=lambda s, o: True, update=pointer_update) x: BoolProperty(default=True) y: BoolProperty(default=True) precision: IntProperty( name="Precision", min=0, max=10, default=8, update=updateNode, description= "decimal precision of coordinates when generating profile from selection" ) addnodes: BoolProperty( name="AddNodes", default=False, description="Lets add support nodes at pressing from selection button") curve_points_count: IntProperty( name="Curve points count", min=1, max=100, default=20, update=updateNode, description="Default number of points on curve segment") close_threshold: FloatProperty( name="X command threshold", min=0, max=1, default=0.0005, precision=6, update=updateNode, description= "If distance between first and last point is less than this, X command will remove the last point" ) nurbs_out: BoolProperty(name="NURBS output", description="Output NURBS curves", default=False, update=updateNode) concat_curves: BoolProperty(name="Concatenate", description="Concatenate curves", default=False, update=updateNode) concat_tolerance: FloatProperty(name="Concat tolerance", min=0.0, default=0.0001, precision=6, update=updateNode) def draw_buttons(self, context, layout): self.draw_animatable_buttons(layout, icon_only=True) layout.prop(self, 'selected_axis', expand=True) row = layout.row(align=True) row.prop_search(self, 'file_pointer', bpy.data, 'texts', text='', icon='TEXT') col = layout.column(align=True) row = col.row() do_text = row.operator('node.sverchok_profilizer_mk3', text='from selection') do_text.nodename = self.name do_text.treename = self.id_data.name do_text.x = self.x do_text.y = self.y def draw_buttons_ext(self, context, layout): self.draw_buttons(context, layout) layout.prop(self, "close_threshold") layout.label(text='Curves output settings') layout.prop(self, 'nurbs_out', toggle=True) layout.prop(self, 'concat_curves', toggle=True) if self.concat_curves: layout.prop(self, 'concat_tolerance') layout.label(text="Profile Generator settings") layout.prop(self, "precision") layout.prop(self, "curve_points_count") row = layout.row(align=True) row.prop(self, "x", text='x-affect', expand=True) row.prop(self, "y", text='y-affect', expand=True) layout.label(text="Import Examples") layout.menu(SvProfileImportMenu.bl_idname) layout.prop(self, "addnodes", text='Auto add nodes') layout.label(text=f"||{self.filename}||") def sv_init(self, context): self.inputs.new('SvStringsSocket', "a") self.outputs.new('SvVerticesSocket', "Vertices") self.outputs.new('SvStringsSocket', "Edges") self.outputs.new('SvVerticesSocket', "Knots") self.outputs.new('SvStringsSocket', "KnotNames") self.outputs.new('SvCurveSocket', "Curve") def load_profile(self): if not self.filename: return None # we do not store stripped self.filename, else prop_search will shows it as read internal_file = bpy.data.texts[self.filename.strip()] f = internal_file.as_string() profile = parse_profile(f) return profile def get_variables(self): variables = set() profile = self.load_profile() if not profile: return variables for statement in profile: vs = statement.get_variables() variables.update(vs) for statement in profile: vs = statement.get_hidden_inputs() variables.difference_update(vs) return list(sorted(list(variables))) def get_optional_inputs(self, profile): result = set() if not profile: return result for statement in profile: vs = statement.get_optional_inputs() result.update(vs) return result def adjust_sockets(self): variables = self.get_variables() #self.debug("adjust_sockets:" + str(variables)) #self.debug("inputs:" + str(self.inputs.keys())) for key in self.inputs.keys(): if key not in variables: self.debug("Input {} not in variables {}, remove it".format( key, str(variables))) self.inputs.remove(self.inputs[key]) for v in variables: if v not in self.inputs: self.debug("Variable {} not in inputs {}, add it".format( v, str(self.inputs.keys()))) self.inputs.new('SvStringsSocket', v) def sv_update(self): ''' update analyzes the state of the node and returns if the criteria to start processing are not met. ''' # keeping the file internal for now. if not (self.filename.strip() in bpy.data.texts): return self.adjust_sockets() def get_input(self): variables = self.get_variables() result = {} for var in variables: if var in self.inputs and self.inputs[var].is_linked: result[var] = self.inputs[var].sv_get()[0] return result def extend_out_verts(self, verts): if self.selected_axis == 'X': extend = lambda v: (0, v[0], v[1]) elif self.selected_axis == 'Y': extend = lambda v: (v[0], 0, v[1]) else: extend = lambda v: (v[0], v[1], 0) return list(map(extend, verts)) def group_curves(self, curves): result = [[curves[0]]] tolerance = self.concat_tolerance for curve1, curve2 in zip(curves, curves[1:]): _, t_max_1 = curve1.get_u_bounds() t_min_2, _ = curve2.get_u_bounds() end1 = curve1.evaluate(t_max_1) begin2 = curve2.evaluate(t_min_2) distance = np.linalg.norm(begin2 - end1) if distance > tolerance: result.append([curve2]) else: result[-1].append(curve2) return result def process(self): if not any(o.is_linked for o in self.outputs): return sync_pointer_and_stored_name(self, "file_pointer", "filename") profile = self.load_profile() optional_inputs = self.get_optional_inputs(profile) var_names = self.get_variables() self.debug("Var_names: %s; optional: %s", var_names, optional_inputs) inputs = self.get_input() result_vertices = [] result_edges = [] result_knots = [] result_names = [] result_curves = [] if var_names: input_values = [] for name in var_names: try: input_values.append(inputs[name]) except KeyError as e: name = e.args[0] if name not in optional_inputs: if name in self.inputs: raise SvNoDataError(self.inputs[name]) else: self.adjust_sockets() raise SvNoDataError(self.inputs[name]) else: input_values.append([None]) parameters = match_long_repeat(input_values) else: parameters = [[[]]] input_names = [ socket.name for socket in self.inputs if socket.is_linked ] for values in zip(*parameters): variables = dict(zip(var_names, values)) curves_form = Interpreter.NURBS if self.nurbs_out else None interpreter = Interpreter(self, input_names, curves_form=curves_form, z_axis=self.selected_axis) interpreter.interpret(profile, variables) verts = self.extend_out_verts(interpreter.vertices) result_vertices.append(verts) result_edges.append(interpreter.edges) knots = self.extend_out_verts(interpreter.knots) result_knots.append(knots) result_names.append([[name] for name in interpreter.knotnames]) all_curves = interpreter.curves if self.concat_curves: new_curves = [] for curves in self.group_curves(all_curves): if self.nurbs_out: curves = unify_curves_degree(curves) curve = concatenate_curves(curves) new_curves.append(curve) result_curves.append(new_curves) else: result_curves.append(all_curves) self.outputs['Vertices'].sv_set(result_vertices) self.outputs['Edges'].sv_set(result_edges) self.outputs['Knots'].sv_set(result_knots) self.outputs['KnotNames'].sv_set(result_names) if 'Curve' in self.outputs: self.outputs['Curve'].sv_set(result_curves) def load_from_json(self, node_data: dict, import_version: float): if 'profile' not in node_data: return # looks like a node was empty when it was exported profile = node_data['profile'] filename = node_data['params']['filename'] bpy.data.texts.new(filename) bpy.data.texts[filename].clear() bpy.data.texts[filename].write(profile) def save_to_json(self, node_data: dict): if self.filename and self.filename.strip() in bpy.data.texts: text = bpy.data.texts[self.filename.strip()].as_string() node_data['profile'] = text else: self.warning("Unknown filename: {}".format(self.filename)) def set_filename_to_match_file_pointer(self): self.file_pointer = self.file_pointer def set_pointer_from_filename(self): """ this function upgrades older versions of ProfileMK3 to the version that has self.file_pointer """ if hasattr(self, "file_pointer") and not self.file_pointer: text = self.get_bpy_data_from_name(self.filename, bpy.data.texts) if text: self.file_pointer = text
} # ------------------------------------------------- # Initial # ------------------------------------------------- # Imports import bpy, os from bpy.props import (StringProperty, PointerProperty, CollectionProperty, EnumProperty) from bpy.utils import (register_class, unregister_class) # Pick object bpy.types.Scene.picked_object = PointerProperty(type=bpy.types.Object, name='Pick object') # Global variables picked_object_global = None message = '' # Define input fields bpy.types.Scene.in_dir_path = StringProperty( name='Input directory', default='', description='Define the input path of the batch', subtype='DIR_PATH') bpy.types.Scene.out_dir_path = StringProperty( name='Output directory', default='',
def register(): for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.jewelcraft = PointerProperty(type=Properties)
from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, BoolVectorProperty, PointerProperty, CollectionProperty, EnumProperty) ENUM_OBJECT_TYPES = [ ('NONE', "None", "None"), ('CAGE', "CAGE", "Cage used to represent the bounding area of an assembly"), ('XDIM', "Visible Prompt X Dimension", "Visible prompt control in the 3D viewport"), ('YDIM', "Visible Prompt Y Dimension", "Visible prompt control in the 3D viewport"), ('ZDIM', "Visible Prompt Z Dimension", "Visible prompt control in the 3D viewport"), ('BP', "Base Point", "Parent object of an assembly"), ('BPWALL', "Wall Base Point", "Parent object of a wall"), ('BPDIM', "Visual Dimension A", "Base Point for OpenGL Dimension") ] class handy_object(bpy.types.PropertyGroup): type = EnumProperty(name="type", items=ENUM_OBJECT_TYPES, description="Handy Object Type", default='NONE') bpy.utils.register_class(handy_object) bpy.types.Object.handy = PointerProperty(type=handy_object)
class AnnotationProperties(BaseWithText, PropertyGroup): customProperties: CollectionProperty(type=CustomProperties) customShape: PointerProperty(name='Custom Annotation Shape', type=Collection, poll=custom_shape_poll) custom_local_transforms: BoolProperty( name='Use Local Transforms', description='Uses the Local transforms of custom annotation objects', default=True) custom_fit_text: BoolProperty( name='Fit Text', description='Scale Custom Shap to Text Length', default=True) custom_scale: FloatProperty( name='Custom Shape Scale', description='Scale Custom Shape', default=1.0, ) custom_shape_location: EnumProperty( items=(('A', "Anchor", "Anchor"), ('T', "Text", "Text")), name="Custom Shape Location", description="Define Where a custom shape is anchored") draw_leader: BoolProperty( name='Use Leader', description='Draw A Leader Line from the annotation to the anchor', default=True) shape_to_text: BoolProperty( name='Shape to text', description= 'Align the custom annotation shape with the annotation text, rather than the anchor point', default=False) annotationRotation: FloatVectorProperty( name='annotationOffset', description='Rotation for Annotation', default=(0.0, 0.0, 0.0), subtype='EULER') annotationOffset: FloatVectorProperty(name='annotationOffset', description='Offset for Annotation', default=(1.0, 1.0, 1.0), subtype='TRANSLATION') annotationTextSource: StringProperty(name='annotationTextSource', description="Text Source", update=annotation_update_flag) annotationAnchorObject: PointerProperty(type=Object) annotationAnchor: IntProperty( name="annotationAnchor", description="Index of Vertex that the annotation is Anchored to") endcapSize: IntProperty(name="dimEndcapSize", description="End Cap size", default=15, min=1, max=500) endcapA: EnumProperty(items=(('99', "--", "No Cap"), ('D', "Dot", "Dot"), ('T', "Triangle", "Triangle")), name="A end", description="Add arrows to point A")
class LuxCoreLightProps(bpy.types.PropertyGroup): def update_image(self, context): if context.lamp: # For spot lamp (toggle projection mode) if context.lamp.type == "AREA": context.lamp.use_square = self.image is not None def update_is_laser(self, context): if context.lamp: # For area lamp (laser can't be rectangular) if self.is_laser: context.lamp.shape = "SQUARE" ############################################## # BlendLuxCore specific properties needed to translate LuxCore light concepts to Blender sun_types = [ ("sun", "Sun", "Sun", 0), ("distant", "Distant", "Distant star without atmosphere simulation (emits parallel light)", 1), ] sun_type = EnumProperty(name="Sun Type", items=sun_types, default="sun") is_laser = BoolProperty( name="Laser", default=False, update=update_is_laser, description="Laser light emitting parallel light rays") ############################################## # Generic properties shared by all light types gain = FloatProperty(name="Gain", default=1, min=0, description="Brightness multiplier") rgb_gain = FloatVectorProperty(name="Tint", default=(1, 1, 1), min=0, max=1, subtype="COLOR") samples = IntProperty(name="Samples", default=-1, min=-1, description=SAMPLES_DESCRIPTION) importance = FloatProperty(name="Importance", default=1, min=0, description=IMPORTANCE_DESCRIPTION) # TODO: id ############################################## # Light type specific properties (some are shared by multiple lights, noted in comments) # TODO: check min/max, add descriptions # sun, sky2 turbidity = FloatProperty(name="Turbidity", default=2.2, min=0, max=30) # sun relsize = FloatProperty(name="Relative Size", default=1, min=0.05) # sky2 (is in world propertys, not sure if it's necessary to have a sky2 light) # groundalbedo = FloatVectorProperty(name="Ground Albedo", default=(0.5, 0.5, 0.5), min=0, max=1, subtype="COLOR") # ground_enable = BoolProperty(name="Use Ground Color", default=False) # ground_color = FloatVectorProperty(name="Ground Color", default=(0.5, 0.5, 0.5), min=0, max=1, subtype="COLOR") # The image property has different names on different lights: # infinite: file # mappoint: mapfile # projection: mapfile image = PointerProperty(name="Image", type=bpy.types.Image, update=update_image) gamma = FloatProperty(name="Gamma", default=1, min=0, description=GAMMA_DESCRIPTION) # infinite sampleupperhemisphereonly = BoolProperty( name="Sample Upper Hemisphere Only", default=False, description=SAMPLEUPPERHEMISPHEREONLY_DESCRIPTION) # point, mappoint, spot, laser power = FloatProperty(name="Power (W)", default=0, min=0, description=POWER_DESCRIPTION) efficacy = FloatProperty(name="Efficacy (lm/W)", default=0, min=0, description=EFFICACY_DESCRIPTION) # mappoint use_ies = BoolProperty(name="Use IES File", default=False, description=USE_IES_DESCRIPTION) iesfile_type = EnumProperty(name="IES File Type", items=iesfile_type_items, default="TEXT") iesfile_path = StringProperty(name="IES File", subtype="FILE_PATH", description=IES_FILE_DESCRIPTION) iesfile_text = PointerProperty(name="IES Text", type=bpy.types.Text, description=IES_TEXT_DESCRIPTION) flipz = BoolProperty(name="Flip IES Z Axis", default=False) # not exposed: emission.map.width, emission.map.height - do we need them? # spot # Note: coneangle and conedeltaangle are set with default Blender properties # (spot_size and spot_blend) # projection # Note: fov is set with default Blender properties # distant theta = FloatProperty(name="Size", default=10, min=0, soft_min=0.05) # laser # Note: radius is set with default Blender properties (area light size) # sky2, sun, infinite, constantinfinite visibility_indirect_diffuse = BoolProperty(name="Diffuse", default=True) visibility_indirect_glossy = BoolProperty(name="Glossy", default=True) visibility_indirect_specular = BoolProperty(name="Specular", default=True) # sky2, infinite, constantinfinite visibilitymap_enable = BoolProperty(name="Build Visibility Map", default=True, description=VISIBILITYMAP_ENABLE_DESC) # area # We use unit="ROTATION" because angles are radians, so conversion is necessary for the UI spread_angle = FloatProperty(name="Spread Angle", default=math.pi / 2, min=0, soft_min=math.radians(5), max=math.pi / 2, subtype="ANGLE", unit="ROTATION", description=SPREAD_ANGLE_DESCRIPTION)
class LuxCoreNodeVolHeterogeneous(bpy.types.Node, LuxCoreNodeVolume): bl_label = "Heterogeneous Volume" bl_width_default = 190 # TODO: get name, default, description etc. from super class or something priority: IntProperty(update=utils_node.force_viewport_update, name="Priority", default=0, min=0, description=VOLUME_PRIORITY_DESC) color_depth: FloatProperty(update=utils_node.force_viewport_update, name="Absorption Depth", default=1.0, min=0.000001, subtype="DISTANCE", unit="LENGTH", description=COLORDEPTH_DESC) lightgroup: StringProperty(update=utils_node.force_viewport_update, name="Light Group", description=LIGHTGROUP_DESC) step_size: FloatProperty(update=utils_node.force_viewport_update, name="Step Size", default=0.1, min=0.0001, soft_min=0.01, soft_max=1, subtype="DISTANCE", unit="LENGTH", description=STEP_SIZE_DESCRIPTION) maxcount: IntProperty( update=utils_node.force_viewport_update, name="Max. Steps", default=1024, min=0, description="Maximum Step Count for Volume Integration") auto_step_settings: BoolProperty( update=utils_node.force_viewport_update, name="Auto Step Settings", default=False, description="Enable when using a smoke domain. " "Automatically calculates the correct step size and maximum steps") def poll_domain(self, obj): # Only allow objects with a smoke modifier in domain mode to be picked return utils.find_smoke_domain_modifier(obj) domain: PointerProperty( update=utils_node.force_viewport_update, name="Domain", type=bpy.types.Object, poll=poll_domain, description= "Domain object for calculating the step size and maximum steps settings" ) multiscattering: BoolProperty(update=utils_node.force_viewport_update, name="Multiscattering", default=False, description=MULTISCATTERING_DESC) def init(self, context): self.add_common_inputs() self.add_input("LuxCoreSocketColor", "Scattering", (1, 1, 1)) self.add_input("LuxCoreSocketFloatPositive", "Scattering Scale", 1.0) self.add_input("LuxCoreSocketVolumeAsymmetry", "Asymmetry", (0, 0, 0)) self.outputs.new("LuxCoreSocketVolume", "Volume") def draw_buttons(self, context, layout): layout.prop(self, "multiscattering") layout.prop(self, "auto_step_settings") if self.auto_step_settings: layout.prop(self, "domain") if self.domain and not utils.find_smoke_domain_modifier( self.domain): layout.label(text="Not a smoke domain!", icon=icons.WARNING) elif self.domain is None: layout.label(text="Select the smoke domain object", icon=icons.WARNING) else: layout.prop(self, "step_size") layout.prop(self, "maxcount") self.draw_common_buttons(context, layout) def sub_export(self, exporter, depsgraph, props, luxcore_name=None, output_socket=None): definitions = { "type": "heterogeneous", "asymmetry": self.inputs["Asymmetry"].export(exporter, depsgraph, props), "multiscattering": self.multiscattering, } if self.auto_step_settings and self.domain: # Search smoke domain target for smoke modifiers domain_eval = self.domain.evaluated_get(depsgraph) smoke_domain_mod = utils.find_smoke_domain_modifier(domain_eval) if smoke_domain_mod is None: msg = 'Object "%s" is not a smoke domain' % domain_eval.name raise Exception(msg) settings = smoke_domain_mod.domain_settings # A list with 3 elements (resolution in x, y, z directions) resolutions = list(settings.domain_resolution) if bpy.app.version[:2] < (2, 82): if settings.use_high_resolution: resolutions = [ res * (settings.amplify + 1) for res in resolutions ] else: if settings.use_noise: resolutions = [ res * settings.noise_scale for res in resolutions ] dimensions = [dim for dim in domain_eval.dimensions] # The optimal step size on each axis step_sizes = [ dim / res for dim, res in zip(dimensions, resolutions) ] # Use the smallest step size in LuxCore step_size = min(step_sizes) definitions["steps.size"] = step_size # Find the max. count required in the worst case diagonal = domain_eval.dimensions.length worst_case_maxcount = math.ceil(diagonal / step_size) definitions["steps.maxcount"] = worst_case_maxcount print('INFO: "%s" in volume node tree "%s" Auto Step Settings:' % (self.name, self.id_data.name)) print(" Using steps.size = %.3f m" % step_size) print(" Using steps.maxcount =", worst_case_maxcount) else: definitions["steps.size"] = self.step_size definitions["steps.maxcount"] = self.maxcount self.export_common_inputs(exporter, depsgraph, props, definitions) return self.create_props(props, definitions, luxcore_name)