- Added interaction helpers for cutout region validation and shape menu interaction. - Created main operator for converting image regions into cutout shapes, including AI artifact generation. - Introduced object creation logic for cutout shapes, handling depth and normal textures. - Defined cutout shape identifiers and node groups for various shape types. - Implemented depth texture writing and prediction artifact generation for MoGe-2. - Developed server jobs for generating cutout artifacts, depth planes, and refining image regions. - Added region refinement logic to enhance gesture masks using BEN2.
76 lines
2.3 KiB
Python
76 lines
2.3 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import bpy
|
|
|
|
PROJECT_ROOT = Path(__file__).parents[2]
|
|
sys.path.insert(0, str(PROJECT_ROOT / "src"))
|
|
sys.path.insert(
|
|
0,
|
|
str(next((PROJECT_ROOT / "src" / "anyimage" / "wheels").glob("blendjob-*.whl"))),
|
|
)
|
|
|
|
from anyimage.operators.common.mesh_result import (
|
|
load_asset_node_group,
|
|
)
|
|
from anyimage.operators.cutout_tool.shape import (
|
|
CUTOUT_NODE_GROUP_NAME,
|
|
CUTOUT_NODE_GROUP_NAMES,
|
|
)
|
|
|
|
|
|
def input_names(group):
|
|
return [
|
|
item.name
|
|
for item in group.interface.items_tree
|
|
if item.item_type == "SOCKET" and item.in_out == "INPUT"
|
|
]
|
|
|
|
|
|
def main():
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
mesh_plane = load_asset_node_group("O Mesh Plane")
|
|
shadeless = load_asset_node_group("O Shadeless")
|
|
cutout = load_asset_node_group(CUTOUT_NODE_GROUP_NAME)
|
|
cutout_groups = {
|
|
name: bpy.data.node_groups[name] for name in CUTOUT_NODE_GROUP_NAMES.values()
|
|
}
|
|
|
|
assert mesh_plane.name == "O Mesh Plane"
|
|
assert mesh_plane.bl_idname == "GeometryNodeTree"
|
|
assert mesh_plane.is_modifier
|
|
assert input_names(mesh_plane) == [
|
|
"Geometry",
|
|
"Subdivide",
|
|
"Thickness",
|
|
"Material",
|
|
]
|
|
assert shadeless.name == "O Shadeless"
|
|
assert shadeless.bl_idname == "ShaderNodeTree"
|
|
assert input_names(shadeless) == ["Color"]
|
|
|
|
assert cutout.name == CUTOUT_NODE_GROUP_NAME
|
|
assert cutout.bl_idname == "GeometryNodeTree"
|
|
assert cutout.is_modifier
|
|
assert input_names(cutout)[:3] == ["Geometry", "Shape", "Thickness"]
|
|
assert set(cutout_groups) == set(CUTOUT_NODE_GROUP_NAMES.values())
|
|
for group in cutout_groups.values():
|
|
assert group.bl_idname == "GeometryNodeTree"
|
|
assert not group.is_modifier
|
|
assert input_names(group)[0] == "Geometry"
|
|
|
|
public_groups = {mesh_plane, shadeless, cutout}
|
|
loaded = {*public_groups, *cutout_groups.values()}
|
|
assert all(group.use_fake_user for group in public_groups)
|
|
assert all(group.users > 0 for group in cutout_groups.values())
|
|
if bpy.app.version >= (5, 0, 0):
|
|
assert all(group.library is not None for group in loaded)
|
|
print(
|
|
f"Validated Blender {bpy.app.version_string}: "
|
|
+ ", ".join(sorted(group.name for group in loaded))
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|