add texture resolution setting when loading mesh to set up project in substance painter

This commit is contained in:
moonyuet 2024-04-10 23:24:28 +08:00
parent 1ece2defc9
commit c5ccf8a390

View file

@ -2,6 +2,7 @@ from ayon_core.pipeline import (
load,
get_representation_path,
)
from ayon_core.lib import BoolDef, EnumDef
from ayon_core.pipeline.load import LoadError
from ayon_core.hosts.substancepainter.api.pipeline import (
imprint_container,
@ -11,7 +12,6 @@ from ayon_core.hosts.substancepainter.api.pipeline import (
from ayon_core.hosts.substancepainter.api.lib import prompt_new_file_with_mesh
import substance_painter.project
import qargparse
class SubstanceLoadProjectMesh(load.LoaderPlugin):
@ -25,26 +25,35 @@ class SubstanceLoadProjectMesh(load.LoaderPlugin):
icon = "code-fork"
color = "orange"
options = [
qargparse.Boolean(
"preserve_strokes",
default=True,
help="Preserve strokes positions on mesh.\n"
"(only relevant when loading into existing project)"
),
qargparse.Boolean(
"import_cameras",
default=True,
help="Import cameras from the mesh file."
)
]
@classmethod
def get_options(cls, contexts):
return [
BoolDef("preserve_strokes",
default=True,
label="Preserve Strokes",
tooltip=("Preserve strokes positions on mesh.\n"
"(only relevant when loading into "
"existing project)")),
BoolDef("import_cameras",
default=True,
label="Import Cameras",
tooltip="Import cameras from the mesh file."
),
EnumDef("texture_resolution",
items=[128, 256, 512, 1024, 2048, 4096],
default=1024,
label="Texture Resolution",
tooltip="Set texture resolution for the project")
]
def load(self, context, name, namespace, data):
def load(self, context, name, namespace, options=None):
# Get user inputs
import_cameras = data.get("import_cameras", True)
preserve_strokes = data.get("preserve_strokes", True)
import_cameras = options.get("import_cameras", True)
preserve_strokes = options.get("preserve_strokes", True)
texture_resolution = options.get("texture_resolution", 1024)
sp_settings = substance_painter.project.Settings(
default_texture_resolution=texture_resolution,
import_cameras=import_cameras
)
if not substance_painter.project.is_open():