initial
This commit is contained in:
@@ -0,0 +1,352 @@
|
||||
global proc AEDirectXShaderTemplate ( string $node )
|
||||
{
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
editorTemplate -label "Maya Viewer Color" -addControl "color" ;
|
||||
|
||||
editorTemplate -callCustom AEDirectXNew AEDirectXReplace $node;
|
||||
|
||||
editorTemplate -endLayout;
|
||||
|
||||
// Hide "Extra Attributes" UI for dynamic attributes.
|
||||
editorTemplate -addExtraControls;
|
||||
|
||||
editorTemplate -endScrollLayout;
|
||||
}
|
||||
|
||||
global proc AEDirectXNew( string $messagePlug )
|
||||
{
|
||||
AEDirectXReplace($messagePlug);
|
||||
}
|
||||
|
||||
proc DxFxParameterLayout( string $shaderNode )
|
||||
{
|
||||
string $dxfxScript= `getAttr ($shaderNode + ".FxScript")`;
|
||||
eval( $dxfxScript );
|
||||
}
|
||||
|
||||
global proc DxFxScriptTest(string $shaderNode )
|
||||
{
|
||||
string $dxfxWindow= "FxShaderTest";
|
||||
|
||||
if ( `window -exists $dxfxWindow` )
|
||||
deleteUI $dxfxWindow;
|
||||
window -widthHeight 200 300 $dxfxWindow;
|
||||
|
||||
|
||||
if ( `frameLayout -exists dxfxAEFrame` )
|
||||
deleteUI dxfxAEFrame;
|
||||
|
||||
frameLayout -label "DirectX Effect Parameters"
|
||||
-borderStyle "etchedIn"
|
||||
-collapsable true
|
||||
-marginWidth 10
|
||||
-visible true
|
||||
dxfxAEFrame;
|
||||
{
|
||||
columnLayout -adjustableColumn true -columnAlign "left";
|
||||
{
|
||||
DxFxParameterLayout($shaderNode);
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
showWindow $dxfxWindow;
|
||||
|
||||
}
|
||||
|
||||
global proc string plugNode( string $plug )
|
||||
{
|
||||
string $buffer[];
|
||||
tokenize($plug, ".", $buffer);
|
||||
return $buffer[0];
|
||||
}
|
||||
|
||||
global proc dxfxDeleteAttribute(string $AttrName, string $Node)
|
||||
{
|
||||
if( `attributeExists $AttrName $Node` )
|
||||
{
|
||||
catch( `deleteAttr -attribute $AttrName $Node` );
|
||||
}
|
||||
}
|
||||
|
||||
global proc dxfxStackDown(int $change)
|
||||
{
|
||||
int $index;
|
||||
for($index= $change; $index < 0; $index++)
|
||||
{
|
||||
setParent ..;
|
||||
setParent ..;
|
||||
}
|
||||
}
|
||||
global proc dxfxStackUp( string $UIName, int $NoChildren)
|
||||
{
|
||||
if($NoChildren)
|
||||
{
|
||||
columnLayout -adjustableColumn true;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameLayout -label $UIName
|
||||
-borderStyle "out"
|
||||
-font "smallPlainLabelFont"
|
||||
-marginWidth 10
|
||||
-collapse true
|
||||
-collapsable true
|
||||
-visible true;
|
||||
}
|
||||
|
||||
columnLayout -adjustableColumn true;
|
||||
}
|
||||
|
||||
global proc dxfxControlColorCreate(string $UIName, string $plug, int $length)
|
||||
{
|
||||
string $colorUIName = $UIName;
|
||||
if($length == 4)
|
||||
$colorUIName = ($colorUIName + ".rgb");
|
||||
|
||||
|
||||
string $colorSlider = `colorSliderGrp -label $colorUIName`;
|
||||
|
||||
string $quotedColorSlider = ("\"" + $colorSlider + "\"");
|
||||
string $quotedPlug = ("\"" + $plug + "\"");
|
||||
string $callback = "dxfxControlColorCallback( " + $quotedColorSlider + " , " + $quotedPlug + " )";
|
||||
|
||||
float $P0Value= `getAttr ($plug + "[0]")`;
|
||||
float $P1Value= `getAttr ($plug + "[1]")`;
|
||||
float $P2Value= `getAttr ($plug + "[2]")`;
|
||||
//print ("ColorValues: " + $P0Value + " " + $P1Value + " " + $P2Value + " ");
|
||||
|
||||
colorSliderGrp -edit -rgbValue $P0Value $P1Value $P2Value $colorSlider;
|
||||
|
||||
//print ("ColorValues2: " + $P0Value + " " + $P1Value + " " + $P2Value + " ");
|
||||
|
||||
colorSliderGrp -edit -changeCommand $callback $colorSlider;
|
||||
|
||||
if($length == 4)
|
||||
{
|
||||
string $alphaPlug = ($plug + "[3]");
|
||||
string $alphaUIName = ($UIName + ".a");
|
||||
|
||||
dxfxControlSliderCreate( "float", $alphaUIName, 0.0, 1.0, 0.01, $alphaPlug);;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
global proc dxfxControlColorCallback(string $control, string $plug)
|
||||
{
|
||||
float $colorValues[3]= `colorSliderGrp -q -rgbValue $control`;
|
||||
setAttr ($plug + "[0]") $colorValues[0];
|
||||
setAttr ($plug + "[1]") $colorValues[1];
|
||||
setAttr ($plug + "[2]") $colorValues[2];
|
||||
}
|
||||
|
||||
global proc dxfxControlSliderCreate(string $type, string $UIName, float $min, float $max, float $step, string $plug)
|
||||
{
|
||||
|
||||
string $quotedUIName = ("\"" + $UIName + "\"");
|
||||
string $Slider;
|
||||
|
||||
if(0 == strcmp( $type, "float" ))
|
||||
{
|
||||
float $floatMin = $min;
|
||||
float $floatMax = $max;
|
||||
float $floatStep = $step;
|
||||
|
||||
$Slider = `floatSliderGrp -label $UIName -minValue $floatMin -maxValue $floatMax -step $floatStep -field true`;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "int" ))
|
||||
{
|
||||
int $intMin = $min;
|
||||
int $intMax = $max;
|
||||
int $intStep = $step;
|
||||
|
||||
$Slider = `intSliderGrp -label $UIName -minValue $intMin -maxValue $intMax -step $intStep -field true`;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "bool" ))
|
||||
{
|
||||
$Slider = `intSliderGrp -label $UIName -minValue 0 -maxValue 1 -step 1 -field true`;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connectControl $Slider $plug;
|
||||
}
|
||||
|
||||
global proc dxfxControlScalarCreate(string $type, string $UIName, string $plug)
|
||||
{
|
||||
string $control;
|
||||
if(0 == strcmp( $type, "float" ))
|
||||
{
|
||||
$control = "floatFieldGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "int" ))
|
||||
{
|
||||
$control = "intFieldGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "bool" ))
|
||||
{
|
||||
$control = "checkBoxGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string $command = ( $control + " -numberOfFields 1" + " -label \"" + $UIName + "\"" + " -columnWidth 2 220" );
|
||||
string $rowCtrl= eval($command);
|
||||
connectControl -index 2 $rowCtrl $plug;
|
||||
}
|
||||
|
||||
global proc dxfxControlVectorCreate(string $type, string $UIName, string $plug, int $length)
|
||||
{
|
||||
dxfxControlMatrixCreate($type, $UIName, $plug, 1, $length);
|
||||
}
|
||||
|
||||
global proc dxfxControlMatrixCreate(string $type, string $UIName, string $plug, int $rows, int $columns )
|
||||
{
|
||||
string $control;
|
||||
if(0 == strcmp( $type, "float" ))
|
||||
{
|
||||
$control = "floatFieldGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "int" ))
|
||||
{
|
||||
$control = "intFieldGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == strcmp( $type, "bool" ))
|
||||
{
|
||||
$control = "checkBoxGrp";
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int $rowIndex;
|
||||
for($rowIndex= 0; $rowIndex < $rows; $rowIndex++)
|
||||
{
|
||||
string $command;
|
||||
int $columnIndex;
|
||||
|
||||
$command = ($control + " -numberOfFields " + $columns );
|
||||
if($rowIndex == 0)
|
||||
$command = ($command + " -label \"" + $UIName + "\"");
|
||||
|
||||
for( $columnIndex = 0; $columnIndex < $columns; $columnIndex++ )
|
||||
{
|
||||
$command = ($command + " -columnWidth " + ($columnIndex + 2) + " " + (220 / $columns) );
|
||||
}
|
||||
|
||||
string $rowCtrl= eval($command);
|
||||
for( $columnIndex = 0; $columnIndex < $columns; $columnIndex++ )
|
||||
{
|
||||
int $plugIndex = ( $rowIndex * $rows ) + $columnIndex;
|
||||
string $subPlugName = ($plug + "[" + $plugIndex + "]");
|
||||
connectControl -index ( $columnIndex + 2 ) $rowCtrl $subPlugName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc dxfxControlStringCreate(string $UIName, string $plug)
|
||||
{
|
||||
string $rowCtrl= `textFieldGrp -label $UIName`;
|
||||
connectControl -index 2 $rowCtrl $plug;
|
||||
}
|
||||
|
||||
global proc dxfxControlTextureCreate(string $UIName, string $plug)
|
||||
{
|
||||
string $quotedPlug = ("\"" + $plug + "\"");
|
||||
|
||||
string $buttonCmd = ("setAttr -type \"string\" " + $quotedPlug + " `fileDialog -directoryMask \"*.dds;*.jpg;*.bmp;*.tga;*.png;*.ppm;*.dib;*.hdr;*.pfm\"`;");
|
||||
|
||||
string $rowCtrl= `textFieldButtonGrp -label $UIName -buttonLabel "..." -buttonCommand $buttonCmd`;
|
||||
|
||||
connectControl -index 2 $rowCtrl $plug;
|
||||
}
|
||||
|
||||
global proc AEDirectXReplace( string $messagePlug )
|
||||
{
|
||||
string $shaderNode = plugNode($messagePlug);
|
||||
|
||||
{
|
||||
string $dxfxFileAttribute = $shaderNode + ".FxFile";
|
||||
|
||||
string $dxfxFile= `getAttr $dxfxFileAttribute`;
|
||||
|
||||
string $dxfxSetFile = "setAttr -type \"string\" " + $dxfxFileAttribute + " `fileDialog -directoryMask \"*.fx\"`";
|
||||
|
||||
string $dxfxReloadFile = "setAttr -type \"string\" " + $dxfxFileAttribute + " `getAttr -asString " + $dxfxFileAttribute + "`";
|
||||
|
||||
if ( `textFieldButtonGrp -exists dxfxFileControl` )
|
||||
deleteUI dxfxFileControl;
|
||||
|
||||
textFieldButtonGrp
|
||||
-label "DirectX Effect File"
|
||||
-text $dxfxFile
|
||||
-editable false
|
||||
-buttonLabel "..."
|
||||
-buttonCommand $dxfxSetFile
|
||||
dxfxFileControl;
|
||||
|
||||
scriptJob
|
||||
-parent dxfxFileControl
|
||||
-replacePrevious
|
||||
-killWithScene
|
||||
-runOnce false
|
||||
-compressUndo true
|
||||
-attributeChange $dxfxFileAttribute "refreshAE;";
|
||||
|
||||
if ( `button -exists dxfxReloadControl` )
|
||||
deleteUI dxfxReloadControl;
|
||||
|
||||
button
|
||||
-label "Reload Effect File"
|
||||
-command $dxfxReloadFile
|
||||
dxfxReloadControl;
|
||||
|
||||
if ( `frameLayout -exists dxfxRollOut` )
|
||||
deleteUI dxfxRollOut;
|
||||
|
||||
frameLayout -label "DirectX Effect Parameters"
|
||||
-collapse false
|
||||
-collapsable true
|
||||
-visible false
|
||||
dxfxRollOut;
|
||||
{
|
||||
columnLayout -adjustableColumn true;
|
||||
{
|
||||
DxFxParameterLayout($shaderNode);
|
||||
setParent ..;
|
||||
}
|
||||
layout -edit -visible true dxfxRollOut;
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
setUITemplate -popTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
154
dx10sdk/Utilities/Bin/PlugIns/Maya/binary65/Scripts/DirectX.mel
Normal file
154
dx10sdk/Utilities/Bin/PlugIns/Maya/binary65/Scripts/DirectX.mel
Normal file
@@ -0,0 +1,154 @@
|
||||
|
||||
global string $g_dxMenu;
|
||||
global string $g_dxPreviewToggle;
|
||||
global string $g_dxViewerStartupToggle;
|
||||
|
||||
{
|
||||
DirectX_BuildMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
global proc DirectX_SetPreviewState(int $state)
|
||||
{
|
||||
global string $g_dxPreviewToggle;
|
||||
|
||||
menuItem -e -checkBox $state $g_dxPreviewToggle;
|
||||
}
|
||||
|
||||
global proc int DirectX_GetPreviewState()
|
||||
{
|
||||
global string $g_dxPreviewToggle;
|
||||
|
||||
int $result= `menuItem -q -checkBox $g_dxPreviewToggle`;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
global proc DirectX_SetViewerStartupState(int $state)
|
||||
{
|
||||
global string $g_dxViewerStartupToggle;
|
||||
|
||||
menuItem -e -checkBox $state $g_dxViewerStartupToggle;
|
||||
}
|
||||
|
||||
global proc int DirectX_GetViewerStartupState()
|
||||
{
|
||||
global string $g_dxViewerStartupToggle;
|
||||
|
||||
int $result= `menuItem -q -checkBox $g_dxViewerStartupToggle`;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
global proc DirectX_RemoveMenu()
|
||||
{
|
||||
global string $g_dxMenu;
|
||||
|
||||
if(`menu -q -exists $g_dxMenu`)
|
||||
deleteUI $g_dxMenu;
|
||||
|
||||
}
|
||||
|
||||
global string $g_dxMenu;
|
||||
global proc DirectX_BuildMenu()
|
||||
{
|
||||
global string $gMainWindow;
|
||||
global string $g_dxMenu;
|
||||
global string $g_dxPreviewToggle;
|
||||
global string $g_dxSkinToggle;
|
||||
global string $g_dxAnimationToggle;
|
||||
global string $g_dxViewerStartupToggle;
|
||||
|
||||
// If menu exists or if main window doesn't exist, just return.
|
||||
if(`menu -q -exists $g_dxMenu`
|
||||
|| !(`window -q -exists $gMainWindow`))
|
||||
return;
|
||||
|
||||
$g_dxMenu= `menu -parent $gMainWindow -tearOff true -aob true
|
||||
-label "DirectX"`;
|
||||
|
||||
setParent -m $g_dxMenu;
|
||||
|
||||
$g_dxPreviewToggle= `menuItem -l "Realtime Previewing"
|
||||
-annotation "Realtime Previewing of scene in Direct3D viewers."
|
||||
-cb 1
|
||||
-c ("DXCCPreviewChanged")`;
|
||||
|
||||
menuItem -d true;
|
||||
|
||||
menuItem -l "Rebuild All"
|
||||
-annotation "Rebuild scene data for realtime viewers and export"
|
||||
-c "DXCCRebuildScene"
|
||||
dxRebuildSceneItem;
|
||||
|
||||
menuItem -l "Rebuild Dirty"
|
||||
-aob true
|
||||
-annotation "Rebuild dirty data for realtime viewers and export"
|
||||
-c ("DXCCRebuildDirty")
|
||||
dxRebuildDirtyItem;
|
||||
|
||||
menuItem -d true;
|
||||
|
||||
menuItem -l "Export All"
|
||||
-annotation "Export the scene to an X-File."
|
||||
-c ("DXCCExportScene")
|
||||
dxExportSceneItem;
|
||||
|
||||
menuItem -l "Export Options"
|
||||
-annotation "Popup the Export Options dialog"
|
||||
-c ("DXCCExportOptions")
|
||||
dxExportOptionsItem;
|
||||
|
||||
menuItem -d true;
|
||||
|
||||
menuItem -l "Viewers..."
|
||||
-sm 1
|
||||
-to 1
|
||||
-annotation "Realtime Viewers"
|
||||
dxViewerItem;
|
||||
|
||||
$g_dxViewerStartupToggle= `menuItem -l "Open on Startup"
|
||||
-annotation "Open the viewer when Maya starts"
|
||||
-cb 0`;
|
||||
|
||||
menuItem -l "None"
|
||||
-annotation "Close the Viewer"
|
||||
-c "DXCCCloseViewer"
|
||||
dxCloseViewerItem;
|
||||
|
||||
menuItem -l "Floating"
|
||||
-annotation "Floating Viewers"
|
||||
-c "DXCCFloatingView"
|
||||
dxFloatingViewerItem;
|
||||
|
||||
menuItem -l "Top"
|
||||
-annotation "Place Viewer over Top Pane"
|
||||
-c "DXCCTopView"
|
||||
dxTopViewerItem;
|
||||
|
||||
menuItem -l "Side"
|
||||
-annotation "Place Viewer over Side Pane"
|
||||
-c "DXCCSideView"
|
||||
dxSideViewerItem;
|
||||
|
||||
menuItem -l "Front"
|
||||
-annotation "Place Viewer over Front Pane"
|
||||
-c "DXCCFrontView"
|
||||
dxFrontViewerItem;
|
||||
|
||||
menuItem -d true;
|
||||
|
||||
|
||||
setParent -m $g_dxMenu;
|
||||
|
||||
menuItem -d true;
|
||||
|
||||
menuItem -l "Help"
|
||||
-annotation "Help"
|
||||
-c "DXMUiHelp"
|
||||
dxHelpItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user