- Introduced color_image.py for preparing standalone color images for tests. - Added hdr_image.py to create HDR textures for testing. - Implemented test_image_depth_panorama.py to evaluate panorama topology, UVs, and depth discontinuities. - Created test_shadeless.py to validate the opacity and HDR color endpoints of the Shadeless group. - Developed moge3_export.py for exporting dynamic MoGe-3 backbone and ONNX graphs. - Added material.py to inherit material slots onto generated geometry. - Built image_depth_panorama.py to construct a quad panorama with depth separation and sampling.
100 lines
2.8 KiB
Python
100 lines
2.8 KiB
Python
import bpy
|
||
|
||
from .common.image import is_image_empty
|
||
from .common.image_target import active_texture_node, image_edit_owner, owner_image
|
||
from .operators.upscale import upscale_output_size
|
||
|
||
|
||
class AnyImageImageMenu(bpy.types.Menu):
|
||
bl_idname = "ANYIMAGE_MT_image_context"
|
||
bl_label = "AnyImage"
|
||
|
||
def draw(self, context):
|
||
layout = self.layout
|
||
layout.operator_context = "INVOKE_DEFAULT"
|
||
layout.operator(
|
||
"anyimage.convert_to_plane",
|
||
text="Convert to Plane",
|
||
icon="IMAGE_PLANE",
|
||
)
|
||
layout.operator(
|
||
"anyimage.convert_to_depth_plane",
|
||
text="Convert to Depth Plane",
|
||
icon="MOD_DISPLACE",
|
||
)
|
||
layout.operator(
|
||
"anyimage.convert_to_relief_plane",
|
||
text="Convert to Relief Plane",
|
||
icon="MOD_DISPLACE",
|
||
)
|
||
layout.operator(
|
||
"anyimage.convert_to_panorama",
|
||
text="Convert to Panorama",
|
||
icon="SPHERE",
|
||
)
|
||
layout.separator()
|
||
draw_image_actions(layout, context)
|
||
|
||
|
||
class AnyImageTextureNodeMenu(bpy.types.Menu):
|
||
bl_idname = "ANYIMAGE_MT_texture_node_context"
|
||
bl_label = "AnyImage"
|
||
|
||
def draw(self, context):
|
||
draw_image_actions(self.layout, context)
|
||
|
||
|
||
def draw_image_actions(layout, context):
|
||
from .properties import ai_setup_label, ai_status
|
||
|
||
layout.operator_context = "INVOKE_DEFAULT"
|
||
layout.operator(
|
||
"anyimage.remove_image_background",
|
||
text="Remove Background",
|
||
icon="IMAGE_ALPHA",
|
||
)
|
||
layout.operator(
|
||
"anyimage.upscale_image",
|
||
text=upscale_menu_label(context),
|
||
icon="FULLSCREEN_ENTER",
|
||
)
|
||
layout.separator()
|
||
status = ai_status()
|
||
if status["ready"]:
|
||
layout.operator(
|
||
"anyimage.open_ai_environment_settings",
|
||
text="Settings",
|
||
icon="PREFERENCES",
|
||
)
|
||
else:
|
||
layout.operator(
|
||
"anyimage.setup_ai_environment",
|
||
text=ai_setup_label(status),
|
||
icon="IMPORT",
|
||
)
|
||
|
||
|
||
def upscale_menu_label(context):
|
||
owner = image_edit_owner(context)
|
||
if owner is None:
|
||
return "Upscale"
|
||
output_size = upscale_output_size(owner_image(owner))
|
||
if output_size is None:
|
||
return "Upscale"
|
||
width, height = output_size
|
||
return f"Upscale ({width} × {height})"
|
||
|
||
|
||
def draw_image_context_menu(self, context):
|
||
if not is_image_empty(context.object):
|
||
return
|
||
self.layout.menu(AnyImageImageMenu.bl_idname, text="AnyImage", icon="PLUGIN")
|
||
self.layout.separator()
|
||
|
||
|
||
def draw_texture_node_context_menu(self, context):
|
||
if active_texture_node(context) is None:
|
||
return
|
||
self.layout.menu(AnyImageTextureNodeMenu.bl_idname, text="AnyImage", icon="PLUGIN")
|
||
self.layout.separator()
|