From 5d393a1e3022b57311b95a33d421a21b0e6d5071 Mon Sep 17 00:00:00 2001 From: indigo Date: Thu, 19 Mar 2026 09:49:10 +0800 Subject: [PATCH] Update AETemplete --- README.md | 22 ++++ .../AETemplateMediaPlane.mel | 112 ++++++++++++++++++ src/MayaImagePlaneNode/CMakeLists.txt | 1 + src/MayaImagePlaneNode/Plugin.cpp | 4 + 4 files changed, 139 insertions(+) create mode 100644 src/MayaImagePlaneNode/AETemplateMediaPlane.mel diff --git a/README.md b/README.md index 168ffb2..3f7087e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ MediaPlane/ │ └── MayaImagePlaneNode/ │ ├── CMakeLists.txt # Plugin CMake configuration │ ├── Plugin.cpp # Maya plugin entry point +│ ├── AETemplateMediaPlane.mel # Attribute Editor template │ ├── MayaMediaPlaneNode.h # Node header file │ ├── MayaMediaPlaneNode.cpp # Node implementation │ ├── FFmpegVideoDecoder.h # FFmpeg decoder header @@ -108,6 +109,27 @@ C:\Program Files\Autodesk\Maya2023\plug-ins\ createNode MediaPlane; ``` +### Use AE Template + +The plugin includes a custom Attribute Editor template. When the plugin loads, you'll see instructions in the Script Editor. To manually load the AE template: + +```mel +// Source the AE template +source "AETemplateMediaPlane.mel"; +``` + +For automatic loading, copy the MEL file to your Maya scripts directory: +``` +C:\Users\\Documents\maya\2023\scripts\ +``` + +Or add this to your `userSetup.mel`: +```mel +// Add to userSetup.mel +if (!`exists AETemplateMediaPlane`) + source "AETemplateMediaPlane.mel"; +``` + ### Set Video File ```mel diff --git a/src/MayaImagePlaneNode/AETemplateMediaPlane.mel b/src/MayaImagePlaneNode/AETemplateMediaPlane.mel new file mode 100644 index 0000000..ea173a8 --- /dev/null +++ b/src/MayaImagePlaneNode/AETemplateMediaPlane.mel @@ -0,0 +1,112 @@ +// AETemplateMediaPlane.mel +// Attribute Editor Template for MayaMediaPlaneNode +// This file customizes the appearance of MediaPlane node attributes in Maya's Attribute Editor + +global proc AETemplateMediaPlane(string $nodeName) +{ + editorTemplate -beginScrollLayout; + + // Video File Section + editorTemplate -beginLayout "Video File" -collapse 0; + // Use custom control for video file with browse button + editorTemplate -callCustom "AETemplateMediaPlaneVideoFileCreate" "AETemplateMediaPlaneVideoFileUpdate" "videoFile"; + editorTemplate -endLayout; + + // Playback Section + editorTemplate -beginLayout "Playback" -collapse 0; + editorTemplate -addControl "currentTime"; + editorTemplate -addControl "frameRate"; + editorTemplate -addControl "playbackRate"; + editorTemplate -addControl "useMayaFrameRate"; + editorTemplate -addControl "loop"; + editorTemplate -endLayout; + + // Post Effects Section + editorTemplate -beginLayout "Post Effects" -collapse 0; + editorTemplate -addControl "postEffectCrop"; + editorTemplate -addControl "postEffectResize"; + editorTemplate -addControl "postEffectFlip"; + editorTemplate -endLayout; + + // Cache Section + editorTemplate -beginLayout "Cache" -collapse 0; + editorTemplate -addControl "cachePolicy"; + editorTemplate -addControl "cacheSize"; + editorTemplate -addControl "clearCache"; + editorTemplate -addControl "outCacheHitRatio"; + editorTemplate -endLayout; + + // Output Section + editorTemplate -beginLayout "Output" -collapse 0; + editorTemplate -addControl "outFrameWidth"; + editorTemplate -addControl "outFrameHeight"; + editorTemplate -addControl "outFrameTimestamp"; + editorTemplate -addControl "outFrameCount"; + editorTemplate -addControl "outIsValid"; + editorTemplate -endLayout; + + // Add AE call to the base class + editorTemplate -addExtraControls; + + editorTemplate -endScrollLayout; +} + +// Custom control creation for video file with browse button +global proc AETemplateMediaPlaneVideoFileCreate(string $nodeName) +{ + setUITemplate -pushTemplate attributeEditorTemplate; + + // Create label and textField in a row + rowLayout -numberOfColumns 3 + -columnWidth3 120 320 80 + -adjustableColumn 2 + -columnAlign3 "right" "center" "center" + -rowAttach 1 "left" 0; + + text -label "videoFile"; + + textField -tx "" -width 320 "AETemplateMediaPlaneVideoFileTextField"; + + button -label "Browse..." -width 80 + -command "AETemplateMediaPlaneBrowseButton()" + "AETemplateMediaPlaneBrowseButton"; + + setUITemplate -popTemplate; +} + +// Update callback for video file control +global proc AETemplateMediaPlaneVideoFileUpdate(string $nodeName) +{ + string $value = `getAttr ($nodeName + ".videoFile")`; + textField -edit -tx $value "AETemplateMediaPlaneVideoFileTextField"; +} + +// Browse button command +global proc AETemplateMediaPlaneBrowseButton() +{ + // Get the current text field value + string $currentFile = `textField -q -tx "AETemplateMediaPlaneVideoFileTextField"`; + + // Set up file filters + string $filters = "Video Files (*.mp4 *.mov *.avi *.mkv *.webm);;MP4 (*.mp4);;MOV (*.mov);;AVI (*.avi);;MKV (*.mkv);;WebM (*.webm);;All Files (*.*)"; + + // Open file dialog + string $result[] = `fileDialog2 + -fileFilter $filters + -dialogStyle 2 + -caption "Select Video File" + -startingDirectory ($currentFile != "" ? `dirname $currentFile` : "")`; + + // If user selected a file, update the text field + if (size($result) > 0) + { + textField -edit -tx $result[0] "AETemplateMediaPlaneVideoFileTextField"; + } +} + +// Registration procedure +global proc AEregisterMediaPlaneNode() +{ + // Register the AE template for MediaPlane node + // This is called from the plugin initialization +} diff --git a/src/MayaImagePlaneNode/CMakeLists.txt b/src/MayaImagePlaneNode/CMakeLists.txt index 9231cdb..e4292fe 100644 --- a/src/MayaImagePlaneNode/CMakeLists.txt +++ b/src/MayaImagePlaneNode/CMakeLists.txt @@ -37,6 +37,7 @@ set(PLUGIN_SRCS set(MOD_FILES MediaPlane.mod + AETemplateMediaPlane.mel ) # ============================================ diff --git a/src/MayaImagePlaneNode/Plugin.cpp b/src/MayaImagePlaneNode/Plugin.cpp index bac6de1..ce275b1 100644 --- a/src/MayaImagePlaneNode/Plugin.cpp +++ b/src/MayaImagePlaneNode/Plugin.cpp @@ -4,6 +4,7 @@ #include "MayaMediaPlaneNode.h" #include +#include // Forward declaration MStatus initializeMediaPlaneNode(); @@ -23,7 +24,10 @@ MStatus initializePlugin(MObject obj) &MayaMediaPlaneNode::kNodeClassification); if (!status) return status; + // Display info about AE Template MGlobal::displayInfo("MayaMediaPlaneNode plugin loaded"); + MGlobal::displayInfo("For Attribute Editor customization, source: source \"AETemplate_MediaPlane.mel\""); + return MS::kSuccess; }