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

Commit

Permalink
[Automated] Merged develop into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ynbot authored Sep 30, 2023
2 parents 70d3f20 + a66edaf commit 33e69dc
Show file tree
Hide file tree
Showing 20 changed files with 658 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ body:
label: Version
description: What version are you running? Look to OpenPype Tray
options:
- 3.17.1
- 3.17.1-nightly.3
- 3.17.1-nightly.2
- 3.17.1-nightly.1
Expand Down Expand Up @@ -134,7 +135,6 @@ body:
- 3.14.10-nightly.7
- 3.14.10-nightly.6
- 3.14.10-nightly.5
- 3.14.10-nightly.4
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,7 @@ def _get_attrs(node):
new_name = "{0}_baked".format(short_name)
new_node = cmds.duplicate(node,
name=new_name,
renameChildren=True)[0]
renameChildren=True)[0] # noqa

# Connect all attributes on the node except for transform
# attributes
Expand Down
32 changes: 32 additions & 0 deletions openpype/hosts/maya/plugins/create/create_matchmove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from openpype.hosts.maya.api import (
lib,
plugin
)
from openpype.lib import BoolDef


class CreateMatchmove(plugin.MayaCreator):
"""Instance for more complex setup of cameras.
Might contain multiple cameras, geometries etc.
It is expected to be extracted into .abc or .ma
"""

identifier = "io.openpype.creators.maya.matchmove"
label = "Matchmove"
family = "matchmove"
icon = "video-camera"

def get_instance_attr_defs(self):

defs = lib.collect_animation_defs()

defs.extend([
BoolDef("bakeToWorldSpace",
label="Bake Cameras to World-Space",
tooltip="Bake Cameras to World-Space",
default=True),
])

return defs
68 changes: 40 additions & 28 deletions openpype/hosts/maya/plugins/load/load_audio.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from maya import cmds, mel

from openpype.client import (
get_asset_by_id,
get_subset_by_id,
get_version_by_id,
)
from openpype.pipeline import (
get_current_project_name,
load,
get_representation_path,
)
Expand All @@ -18,7 +12,7 @@ class AudioLoader(load.LoaderPlugin):
"""Specific loader of audio."""

families = ["audio"]
label = "Import audio"
label = "Load audio"
representations = ["wav"]
icon = "volume-up"
color = "orange"
Expand All @@ -27,10 +21,10 @@ def load(self, context, name, namespace, data):

start_frame = cmds.playbackOptions(query=True, min=True)
sound_node = cmds.sound(
file=context["representation"]["data"]["path"], offset=start_frame
file=self.filepath_from_context(context), offset=start_frame
)
cmds.timeControl(
mel.eval("$tmpVar=$gPlayBackSlider"),
mel.eval("$gPlayBackSlider=$gPlayBackSlider"),
edit=True,
sound=sound_node,
displaySound=True
Expand Down Expand Up @@ -59,32 +53,50 @@ def update(self, container, representation):
assert audio_nodes is not None, "Audio node not found."
audio_node = audio_nodes[0]

path = get_representation_path(representation)
cmds.setAttr("{}.filename".format(audio_node), path, type="string")
cmds.setAttr(
container["objectName"] + ".representation",
str(representation["_id"]),
type="string"
current_sound = cmds.timeControl(
mel.eval("$gPlayBackSlider=$gPlayBackSlider"),
query=True,
sound=True
)
activate_sound = current_sound == audio_node

# Set frame range.
project_name = get_current_project_name()
version = get_version_by_id(
project_name, representation["parent"], fields=["parent"]
)
subset = get_subset_by_id(
project_name, version["parent"], fields=["parent"]
)
asset = get_asset_by_id(
project_name, subset["parent"], fields=["parent"]
)
path = get_representation_path(representation)

source_start = 1 - asset["data"]["frameStart"]
source_end = asset["data"]["frameEnd"]
cmds.sound(
audio_node,
edit=True,
file=path
)

# The source start + end does not automatically update itself to the
# length of thew new audio file, even though maya does do that when
# creating a new audio node. So to update we compute it manually.
# This would however override any source start and source end a user
# might have done on the original audio node after load.
audio_frame_count = cmds.getAttr("{}.frameCount".format(audio_node))
audio_sample_rate = cmds.getAttr("{}.sampleRate".format(audio_node))
duration_in_seconds = audio_frame_count / audio_sample_rate
fps = mel.eval('currentTimeUnitToFPS()') # workfile FPS
source_start = 0
source_end = (duration_in_seconds * fps)
cmds.setAttr("{}.sourceStart".format(audio_node), source_start)
cmds.setAttr("{}.sourceEnd".format(audio_node), source_end)

if activate_sound:
# maya by default deactivates it from timeline on file change
cmds.timeControl(
mel.eval("$gPlayBackSlider=$gPlayBackSlider"),
edit=True,
sound=audio_node,
displaySound=True
)

cmds.setAttr(
container["objectName"] + ".representation",
str(representation["_id"]),
type="string"
)

def switch(self, container, representation):
self.update(container, representation)

Expand Down
3 changes: 2 additions & 1 deletion openpype/hosts/maya/plugins/load/load_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
"camerarig",
"staticMesh",
"skeletalMesh",
"mvLook"]
"mvLook",
"matchmove"]

representations = ["ma", "abc", "fbx", "mb"]

Expand Down
22 changes: 14 additions & 8 deletions openpype/hosts/maya/plugins/publish/extract_camera_alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
from openpype.hosts.maya.api import lib


class ExtractCameraAlembic(publish.Extractor):
class ExtractCameraAlembic(publish.Extractor,
publish.OptionalPyblishPluginMixin):
"""Extract a Camera as Alembic.
The cameras gets baked to world space by default. Only when the instance's
The camera gets baked to world space by default. Only when the instance's
`bakeToWorldSpace` is set to False it will include its full hierarchy.
'camera' family expects only single camera, if multiple cameras are needed,
'matchmove' is better choice.
"""

label = "Camera (Alembic)"
label = "Extract Camera (Alembic)"
hosts = ["maya"]
families = ["camera"]
families = ["camera", "matchmove"]
bake_attributes = []

def process(self, instance):
Expand All @@ -35,10 +39,11 @@ def process(self, instance):

# validate required settings
assert isinstance(step, float), "Step must be a float value"
camera = cameras[0]

# Define extract output file path
dir_path = self.staging_dir(instance)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
filename = "{0}.abc".format(instance.name)
path = os.path.join(dir_path, filename)

Expand All @@ -64,9 +69,10 @@ def process(self, instance):

# if baked, drop the camera hierarchy to maintain
# clean output and backwards compatibility
camera_root = cmds.listRelatives(
camera, parent=True, fullPath=True)[0]
job_str += ' -root {0}'.format(camera_root)
camera_roots = cmds.listRelatives(
cameras, parent=True, fullPath=True)
for camera_root in camera_roots:
job_str += ' -root {0}'.format(camera_root)

for member in members:
descendants = cmds.listRelatives(member,
Expand Down
Loading

0 comments on commit 33e69dc

Please sign in to comment.