Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Substance Painter: Allow users to set texture resolutions when loading mesh to create project #6262

Merged
merged 20 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions openpype/hosts/substancepainter/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def _setup_prompt():
mesh_select.setVisible(False)

# Ensure UI is visually up-to-date
app.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
app.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents, 8000)

# Trigger the 'select file' dialog to set the path and have the
# new file dialog to use the path.
Expand All @@ -623,8 +623,6 @@ def _setup_prompt():
"Failed to set mesh path with the prompt dialog:"
f"{mesh_filepath}\n\n"
"Creating new project directly with the mesh path instead.")
else:
dialog.done(dialog.Accepted)

new_action = _get_new_project_action()
if not new_action:
Expand Down
59 changes: 40 additions & 19 deletions openpype/hosts/substancepainter/plugins/load/load_mesh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from openpype.lib import BoolDef, EnumDef
from openpype.pipeline import (
load,
get_representation_path,
Expand All @@ -11,7 +12,6 @@
from openpype.hosts.substancepainter.api.lib import prompt_new_file_with_mesh

import substance_painter.project
import qargparse


class SubstanceLoadProjectMesh(load.LoaderPlugin):
Expand All @@ -25,27 +25,48 @@ 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."
)
]

def load(self, context, name, namespace, data):
@classmethod
def get_options(cls, contexts):
project_workflow_option = {
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
substance_painter.project.ProjectWorkflow.Default: "default",
substance_painter.project.ProjectWorkflow.UVTile: "uvTile",
substance_painter.project.ProjectWorkflow.TextureSetPerUVTile: "textureSetPerUVTile" # noqa
}
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 when creating new project"),
EnumDef("project_uv_workflow",
items=project_workflow_option,
default="default",
label="UV Workflow",
tooltip="Set UV workflow when creating new project")
]

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)
uv_workflow = options.get("project_uv_workflow", "default")
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
sp_settings = substance_painter.project.Settings(
import_cameras=import_cameras
default_texture_resolution=texture_resolution,
import_cameras=import_cameras,
project_workflow=uv_workflow
)
if not substance_painter.project.is_open():
# Allow to 'initialize' a new project
Expand Down
Loading