Skip to content

Instantly share code, notes, and snippets.

@hdev-moliver
Last active November 19, 2016 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdev-moliver/8d3f8eb76ec5b4a86d8e4e18b1e1332f to your computer and use it in GitHub Desktop.
Save hdev-moliver/8d3f8eb76ec5b4a86d8e4e18b1e1332f to your computer and use it in GitHub Desktop.
// Copyright (C) 1997-2014 Autodesk, Inc., and/or its licensors.
// All rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors,
// which is protected by U.S. and Canadian federal copyright law and by
// international treaties.
//
// The Data is provided for use exclusively by You. You have the right to use,
// modify, and incorporate this Data into other products for purposes authorized
// by the Autodesk software license agreement, without fee.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK
// DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES
// INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT,
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE
// OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS
// LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
// DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS
// LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
//
//
// Creation Date:
//
// Procedure Name:
// AEdynParticleInstancerNew
//
// Description Name;
//
// Input Value:
//
// Output Value:
// None
//
global string $AEselectedParticle;
global string $AEmenuParent;
proc enableParticleInstancerLayout( int $enable )
{
$enable = min(1,max(0,$enable));
checkBoxGrp -e -enable $enable AEdisplayAllTypes;
optionMenuGrp -e -enable $enable AEdynInstancerNodeOM;
string $menuName = "";
string $names[] =
{
"Position",
"Rotation",
"AimDirection",
"AimPosition",
"AimAxis",
"AimUpAxis",
"AimWorldUp",
"Scale",
"Shear",
"RotationType",
"ObjectIndex",
"Visibility",
"CycleStartObject",
"Age"
};
int $i;
for( $i = 0; $i < size($names); $i ++ )
{
$menuName = "AE" + $names[$i] + "OM";
if( `optionMenuGrp -q -exists $menuName` )
{
optionMenuGrp -e -enable $enable $menuName;
}
}
}
proc int itemInList(string $itemName, string $itemList[])
{
int $found = 0;
for ($i = 0; $i < size( $itemList ); $i++)
{
if ($itemName == $itemList[$i])
{
$found = 1;
break;
}
}
return $found;
}
global proc AEdynParticleInstancerNew( string $nodeAttr )
{
global string $AEselectedParticle;
string $buffer[];
tokenize($nodeAttr, ".", $buffer);
string $nodeName = $buffer[0];
string $attrName = $buffer[1];
setUITemplate -pst attributeEditorTemplate;
columnLayout ("ParticleInstancerColumn");
setParent ..;
setUITemplate -ppt;
$AEselectedParticle = $nodeName;
string $instancerNodes[] = `particleInstancer -q -name $nodeName`;
checkBoxGrp -label (uiRes("m_AEdynParticleInstancerNew.kAllowAllDataTypes"))
-ncb 1 -v1 0 -l1 ""
-cc ("AEeditInstancerOptionMenus " + $nodeName)
AEdisplayAllTypes;
AEcreateInstancerOptionMenus( $instancerNodes[0], $nodeName );
AEdynParticleInstancerReplace( $nodeName );
}
global proc AEdynParticleInstancerReplace( string $nodeAttr )
{
global string $AEselectedParticle;
global string $AEmenuParent;
string $buffer[];
string $nodeAttr;
tokenize($nodeAttr, ".", $buffer);
string $nodeName = $buffer[0];
string $attrName = $buffer[1];
$AEselectedParticle = $nodeName;
setUITemplate -pst attributeEditorTemplate;
if (!`columnLayout -ex ParticleInstancerColumn`)
{
setUITemplate -pst attributeEditorTemplate;
columnLayout ParticleInstancerColumn;
setUITemplate -ppt;
checkBoxGrp -label (uiRes("m_AEdynParticleInstancerNew.kAllowAllDataTypes2"))
-ncb 1 -v1 0 -l1 ""
-cc ("AEeditInstancerOptionMenus " + $nodeName)
AEdisplayAllTypes;
}
setParent ParticleInstancerColumn;
string $parent = `setParent -q`;
string $instancerNodes[] = `particleInstancer -q -name $nodeName`;
int $instancerCount = size( $instancerNodes );
string $oldInstancerList[];
if (`optionMenuGrp -ex AEdynInstancerNodeOM`)
{
setParent $AEmenuParent;
// Option menu exists. So, get the list of old items. Those that
// no longer exist will be deleted later.
//
$oldInstancerList = `optionMenuGrp -q -ils AEdynInstancerNodeOM`;
setParent AEdynInstancerNodeOM;
}
else
{
// Option menu does not exist. So create it.
//
optionMenuGrp -label (uiRes("m_AEdynParticleInstancerNew.kInstancerNodes"))
-cc ("AEinstancerNodeChanged " + $nodeName)
AEdynInstancerNodeOM;
setParent AEdynInstancerNodeOM;
$AEmenuParent = `setParent -q`;
}
if ( $instancerCount == 0 )
{
// There are no instancers, so create one "None" menuItem,
// and disable the layout controls.
//
if (!(`menuItem -q -exists noneItem_noneItem`))
{
$parent = `setParent -m ($AEmenuParent + "|OptionMenu")`;
menuItem -label `instancerMenuAttrs_melToUI "None"` noneItem_noneItem;
}
enableParticleInstancerLayout( 0 );
}
else
{
// There is at least one instancer, so enable the layout controls
// and add new menuItems for each instancer. If there already
// is a menuItem for this instancer, though, just re-use it.
//
enableParticleInstancerLayout( 1 );
string $instancerName;
// Add the new instancer nodes to AEdynInstancerNodeOM
//
$parent = `setParent -m ($AEmenuParent + "|OptionMenu")`;
int $i;
for ( $i = 0; $i < $instancerCount; $i++ )
{
// If the new item's name is same as one in the old list, then
// just leave it there and don't make a new item (because this
// will cause an error).
//
int $index;
$instancerName = ($nodeName + "_" + $instancerNodes[$i]);
if (!itemInList($instancerName, $oldInstancerList))
{
menuItem -label $instancerNodes[$i] $instancerName;
}
}
}
// Now delete all the old menuItems that are no longer relevant.
//
int $i;
for ( $i = 0; $i < size( $oldInstancerList ); $i++ )
{
// If the old items name is the same as one in the new list, don't
// delete it, because we are reusing it.
//
string $temp[];
tokenize( $oldInstancerList[$i], "_", $temp );
int $numTokens = size($temp);
int $lastToken = $numTokens > 0 ? $numTokens-1 : 0;
if( $temp[$lastToken] == "noneItem"
&& size($instancerNodes) == 0 )
{
// Don't delete the "None" menuItem if there are no
// instancers.
//
continue;
}
if (!itemInList($temp[$lastToken], $instancerNodes))
{
deleteUI $oldInstancerList[$i];
}
}
if ($instancerCount > 0)
AEparticleInstWatchCycleAttribute();
checkBoxGrp -e
-cc ("AEeditInstancerOptionMenus " + $nodeName)
AEdisplayAllTypes;
if ( $instancerCount > 0 )
{
AEeditInstancerOptionMenus( $nodeName );
}
// Go back to the column.
//
setParent ..;
setUITemplate -ppt;
}
global proc AEinstancerNodeChanged( string $nodeName )
{
string $instancerList[] = `particleInstancer -q -name $nodeName`;
string $selectedInstancer;
// We only want to create the dynamic attribute list if we have
// a valid particle shape.
//
if ( size( $instancerList ) > 0 )
{
AEchangeInstancerOptionMenus( $nodeName );
AEparticleInstWatchCycleAttribute();
}
}
global proc AEchangeInstancerOptionMenus( string $particleName )
{
string $instancer = `optionMenuGrp -q -v AEdynInstancerNodeOM`;
string $attrName = `particleInstancer -name $instancer -q -position $particleName`;
AEchangeInstancerMenuItem( "Position", $attrName );
$attrName = `particleInstancer -name $instancer -q -rotation $particleName`;
AEchangeInstancerMenuItem( "Rotation", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimDirection $particleName`;
AEchangeInstancerMenuItem( "AimDirection", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimPosition $particleName`;
AEchangeInstancerMenuItem( "AimPosition", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimAxis $particleName`;
AEchangeInstancerMenuItem( "AimAxis", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimUpAxis $particleName`;
AEchangeInstancerMenuItem( "AimUpAxis", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimWorldUp $particleName`;
AEchangeInstancerMenuItem( "AimWorldUp", $attrName );
$attrName = `particleInstancer -name $instancer -q -scale $particleName`;
AEchangeInstancerMenuItem( "Scale", $attrName );
$attrName = `particleInstancer -name $instancer -q -shear $particleName`;
AEchangeInstancerMenuItem( "Shear", $attrName );
$attrName = `particleInstancer -name $instancer -q -rotationType $particleName`;
AEchangeInstancerMenuItem( "RotationType", $attrName );
$attrName = `particleInstancer -name $instancer -q -objectIndex $particleName`;
AEchangeInstancerMenuItem( "ObjectIndex", $attrName );
$attrName = `particleInstancer -name $instancer -q -visibility $particleName`;
AEchangeInstancerMenuItem( "Visibility", $attrName );
$attrName = `particleInstancer -name $instancer -q -cycleStartObject $particleName`;
AEchangeInstancerMenuItem( "CycleStartObject", $attrName );
$attrName = `particleInstancer -name $instancer -q -age $particleName`;
AEchangeInstancerMenuItem( "Age", $attrName );
}
global proc AEchangeInstancerMenuItem( string $attrName, string $value )
{
string $omName = "AE" + $attrName + "OM";
int $menuItemExists = `optionMenuGrp -q -exists $omName`;
// Only edit the option group if it exists.
//
if ( $menuItemExists == 1 )
{
if ( $value == "" )
{
$value = "None";
}
optionMenuGrp -e -v `instancerMenuAttrs_melToUI $value` $omName;
}
}
global proc AEcreateInstancerOptionMenus( string $instancer, string $particleName )
{
string $vectorList[];
string $doubleList[];
int $displayAll = `checkBoxGrp -q -v1 AEdisplayAllTypes`;
if ( $displayAll == 0 )
{
$vectorList = listParticleAttrs( $particleName, "vectorArray", 0 );
$doubleList = listParticleAttrs( $particleName, "doubleArray", 0 );
}
else
{
$vectorList = listParticleAttrs( $particleName, "vectorArray", 1 );
$doubleList = listParticleAttrs( $particleName, "doubleArray", 1 );
}
string $none = "None";
separator AEdynParticleInstancerGeneralSeparator;
frameLayout
-collapse 0
-collapsable 0
-borderVisible 0
-label (uiRes("m_AEdynParticleInstancerNew.kGeneralOptions"))
AEdynParticleInstancerGeneralFrame;
columnLayout AEdynParticleInstancerGeneralFrameColumn;
string $attrName = `particleInstancer -name $instancer -q -position $particleName`;
if( $attrName == "" ) $attrName = "worldPosition";
AEcreateInstancerMenuItem( $vectorList, "Position", $attrName );
$attrName = `particleInstancer -name $instancer -q -scale $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "Scale", $attrName );
$attrName = `particleInstancer -name $instancer -q -shear $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "Shear", $attrName );
$attrName = `particleInstancer -name $instancer -q -visibility $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $doubleList, "Visibility", $attrName );
$attrName = `particleInstancer -name $instancer -q -objectIndex $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $doubleList, "ObjectIndex", $attrName );
setParent ..;
setParent ..;
separator AEdynParticleInstancerRotationSeparator;
frameLayout
-collapse 0
-collapsable 0
-borderVisible 0
-label (uiRes("m_AEdynParticleInstancerNew.kRotationOptions"))
AEdynParticleInstancerRotationFrame;
columnLayout AEdynParticleInstancerRotationFrameColumn;
$attrName = `particleInstancer -name $instancer -q -rotationType $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $doubleList, "RotationType", $attrName );
$attrName = `particleInstancer -name $instancer -q -rotation $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "Rotation", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimDirection $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "AimDirection", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimPosition $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "AimPosition", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimAxis $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "AimAxis", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimUpAxis $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "AimUpAxis", $attrName );
$attrName = `particleInstancer -name $instancer -q -aimWorldUp $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $vectorList, "AimWorldUp", $attrName );
setParent ..;
setParent ..;
separator AEdynParticleInstancerCycleSeparator;
frameLayout
-collapse 0
-collapsable 0
-borderVisible 0
-label (uiRes("m_AEdynParticleInstancerNew.kCycleOptions"))
AEdynParticleInstancerCycleFrame;
columnLayout AEdynParticleInstancerCycleFrameColumn;
$attrName = `particleInstancer -name $instancer -q -cycleStartObject $particleName`;
if( $attrName == "" ) $attrName = $none;
AEcreateInstancerMenuItem( $doubleList, "CycleStartObject", $attrName );
$attrName = `particleInstancer -name $instancer -q -age $particleName`;
if( $attrName == "" ) $attrName = "age";
AEcreateInstancerMenuItem( $doubleList, "Age", $attrName );
setParent ..;
setParent ..;
}
global proc AEeditInstancerOptionMenus( string $particleName )
{
global string $AEmenuParent;
string $vectorList[];
string $doubleList[];
int $displayAll = `checkBoxGrp -q -v1 AEdisplayAllTypes`;
int $validHeadSize = 0;
if ( $displayAll == 0 )
{
$vectorList = listParticleAttrs( $particleName, "vectorArray", 0 );
$doubleList = listParticleAttrs( $particleName, "doubleArray", 0 );
$validHeadSize = 9;
}
else
{
$vectorList = listParticleAttrs( $particleName, "vectorArray", 1 );
$doubleList = listParticleAttrs( $particleName, "doubleArray", 1 );
$validHeadSize = 9;
}
int $no_of_items = `optionMenuGrp -q -ni AEdynInstancerNodeOM`;
if( $no_of_items != 0 ){
string $selectedInstancer = `optionMenuGrp -q -v AEdynInstancerNodeOM`;
scriptJob -replacePrevious -parent $AEmenuParent
-attributeChange ($selectedInstancer+".cycle") "AEparticleInstWatchCycleAttribute";
}
AEeditInstancerMenuItem( $vectorList, "Position", 9 );
AEeditInstancerMenuItem( $vectorList, "Scale", 9 );
AEeditInstancerMenuItem( $vectorList, "Shear", 9 );
AEeditInstancerMenuItem( $doubleList, "Visibility", 4 );
AEeditInstancerMenuItem( $doubleList, "ObjectIndex", 4 );
AEeditInstancerMenuItem( $doubleList, "RotationType", 4 );
AEeditInstancerMenuItem( $vectorList, "Rotation", 9 );
AEeditInstancerMenuItem( $vectorList, "AimDirection", 9 );
AEeditInstancerMenuItem( $vectorList, "AimPosition", 9 );
AEeditInstancerMenuItem( $vectorList, "AimAxis", 9 );
AEeditInstancerMenuItem( $vectorList, "AimUpAxis", 9 );
AEeditInstancerMenuItem( $vectorList, "AimWorldUp", 9 );
AEeditInstancerMenuItem( $doubleList, "CycleStartObject", 4 );
AEeditInstancerMenuItem( $doubleList, "Age", 4 );
}
global proc string instancerMenuLabels_melToUI( string $mel )
//
// Description:
// These are mostly the optionMenuGrp labels
//
{
string $result = $mel;
switch( $mel ) {
case "Position":
$result = (uiRes("m_AEdynParticleInstancerNew.kPosition"));
break;
case "Scale":
$result = (uiRes("m_AEdynParticleInstancerNew.kScale"));
break;
case "Shear":
$result = (uiRes("m_AEdynParticleInstancerNew.kShear"));
break;
case "Visibility":
$result = (uiRes("m_AEdynParticleInstancerNew.kVisibility"));
break;
case "ObjectIndex":
$result = (uiRes("m_AEdynParticleInstancerNew.kObjectIndex"));
break;
case "RotationType":
$result = (uiRes("m_AEdynParticleInstancerNew.kRotationType"));
break;
case "Rotation":
$result = (uiRes("m_AEdynParticleInstancerNew.kRotation"));
break;
case "AimDirection":
$result = (uiRes("m_AEdynParticleInstancerNew.kAimDirection"));
break;
case "AimPosition":
$result = (uiRes("m_AEdynParticleInstancerNew.kAimPosition"));
break;
case "AimAxis":
$result = (uiRes("m_AEdynParticleInstancerNew.kAimAxis"));
break;
case "AimUpAxis":
$result = (uiRes("m_AEdynParticleInstancerNew.kAimUpAxis"));
break;
case "AimWorldUp":
$result = (uiRes("m_AEdynParticleInstancerNew.kAimWorldUp"));
break;
case "CycleStartObject":
$result = (uiRes("m_AEdynParticleInstancerNew.kCycleStartObject"));
break;
case "Age":
$result = (uiRes("m_AEdynParticleInstancerNew.kAge"));
break;
default:
uiToMelMsg "instancerMenuLabels_melToUI" $mel 0;
}
return $result;
}
global proc string instancerMenuAttrs_melToUI( string $mel )
//
// Description:
// These are mostly the optionMenuGrp pulldown menu values
//
{
string $result = $mel;
switch( $mel ) {
case "None":
$result = (uiRes("m_AEdynParticleInstancerNew.kNoAttr"));
break;
case "acceleration":
$result = (uiRes("m_AEdynParticleInstancerNew.kAccelerationAttr"));
break;
case "age":
$result = (uiRes("m_AEdynParticleInstancerNew.kAgeAttr"));
break;
case "betterIllumination":
$result = (uiRes("m_AEdynParticleInstancerNew.kBetterIlluminationAttr"));
break;
case "birthTime":
$result = (uiRes("m_AEdynParticleInstancerNew.kBirthTimeAttr"));
break;
case "colorAccum":
$result = (uiRes("m_AEdynParticleInstancerNew.kColorAccumAttr"));
break;
case "flatShaded":
$result = (uiRes("m_AEdynParticleInstancerNew.kFlatShadedAttr"));
break;
case "force":
$result = (uiRes("m_AEdynParticleInstancerNew.kForceAttr"));
break;
case "lifespan":
$result = (uiRes("m_AEdynParticleInstancerNew.kLifespanAttr"));
break;
case "lifespanPP":
$result = (uiRes("m_AEdynParticleInstancerNew.kLifespanPPAttr"));
break;
case "lineWidth":
$result = (uiRes("m_AEdynParticleInstancerNew.kLineWidthAttr"));
break;
case "mass":
$result = (uiRes("m_AEdynParticleInstancerNew.kMassAttr"));
break;
case "multiCount":
$result = (uiRes("m_AEdynParticleInstancerNew.kMultiCountAttr"));
break;
case "multiRadius":
$result = (uiRes("m_AEdynParticleInstancerNew.kMultiRadiusAttr"));
break;
case "normalDir":
$result = (uiRes("m_AEdynParticleInstancerNew.kNormalDirAttr"));
break;
case "opacityPP":
$result = (uiRes("m_AEdynParticleInstancerNew.kOpacityPPAttr"));
break;
case "particleId":
$result = (uiRes("m_AEdynParticleInstancerNew.kParticleIDAttr"));
break;
case "pointSize":
$result = (uiRes("m_AEdynParticleInstancerNew.kPointSizeAttr"));
break;
case "position":
$result = (uiRes("m_AEdynParticleInstancerNew.kPositionAttr"));
break;
case "radius1":
$result = (uiRes("m_AEdynParticleInstancerNew.kRadius1Attr"));
break;
case "radiusPP":
$result = (uiRes("m_AEdynParticleInstancerNew.kRadiusPPAttr"));
break;
case "rampAcceleration":
$result = (uiRes("m_AEdynParticleInstancerNew.kRampAccelerationAttr"));
break;
case "rampPosition":
$result = (uiRes("m_AEdynParticleInstancerNew.kRampPositionAttr"));
break;
case "rampVelocity":
$result = (uiRes("m_AEdynParticleInstancerNew.kRampVelocityAttr"));
break;
case "rgbPP":
$result = (uiRes("m_AEdynParticleInstancerNew.kRgbPPAttr"));
break;
case "selectedOnly":
$result = (uiRes("m_AEdynParticleInstancerNew.kSelectedOnlyAttr"));
break;
case "spriteNum":
$result = (uiRes("m_AEdynParticleInstancerNew.kSpriteNumAttr"));
break;
case "spriteScaleX":
$result = (uiRes("m_AEdynParticleInstancerNew.kSpriteScaleXAttr"));
break;
case "spriteScaleY":
$result = (uiRes("m_AEdynParticleInstancerNew.kSpriteScaleYAttr"));
break;
case "spriteTwist":
$result = (uiRes("m_AEdynParticleInstancerNew.kSpriteTwistAttr"));
break;
case "surfaceShading":
$result = (uiRes("m_AEdynParticleInstancerNew.kSurfaceShadingAttr"));
break;
case "tailFade":
$result = (uiRes("m_AEdynParticleInstancerNew.kTailFadeAttr"));
break;
case "tailSize":
$result = (uiRes("m_AEdynParticleInstancerNew.kTailSizeAttr"));
break;
case "useLighting":
$result = (uiRes("m_AEdynParticleInstancerNew.kUseLightingAttr"));
break;
case "velocity":
$result = (uiRes("m_AEdynParticleInstancerNew.kVelocityAttr"));
break;
case "worldPosition":
$result = (uiRes("m_AEdynParticleInstancerNew.kWorldPositionAttr"));
break;
case "worldVelocity":
$result = (uiRes("m_AEdynParticleInstancerNew.kWorldVelocityAttr"));
break;
default:
uiToMelMsg "instancerMenuAttrs_melToUI" $mel 0;
break;
}
return $result;
}
global proc string instancerMenuLabels_uiToMel( string $ui )
//
// Description:
// These are the optionMenuGrp labels
//
//
{
string $result = $ui;
if( $ui == `uiRes "m_AEdynParticleInstancerNew.kPosition"` ) {
$result = "Position";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kScale"` ) {
$result = "Scale";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kShear"` ) {
$result = "Shear";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kVisibility"` ) {
$result = "Visibility";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kObjectIndex"` ) {
$result = "ObjectIndex";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRotationType"` ) {
$result = "RotationType";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRotation"` ) {
$result = "Rotation";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAimDirection"` ) {
$result = "AimDirection";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAimPosition"` ) {
$result = "AimPosition";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAimAxis"` ) {
$result = "AimAxis";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAimUpAxis"` ) {
$result = "AimUpAxis";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAimWorldUp"` ) {
$result = "AimWorldUp";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kCycleStartObject"` ) {
$result = "CycleStartObject";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAge"` ) {
$result = "Age";
} else {
uiToMelMsg "instancerMenuLabels_uiToMel" $ui 0;
}
return $result;
}
global proc string instancerMenuAttrs_uiToMel( string $ui )
//
// Description:
// These are the optionMenuGrp pulldown menu values
//
{
string $result = $ui;
if( $ui == `uiRes "m_AEdynParticleInstancerNew.kNoAttr"` ) {
$result = "None";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAccelerationAttr"` ) {
$result = "acceleration";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kAgeAttr"` ) {
$result = "age";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kBetterIlluminationAttr"` ) {
$result = "betterIllumination";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kBirthTimeAttr"` ) {
$result = "birthTime";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kColorAccumAttr"` ) {
$result = "colorAccum";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kFlatShadedAttr"` ) {
$result = "flatShaded";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kForceAttr"` ) {
$result = "force";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kLifespanAttr"` ) {
$result = "lifespan";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kLifespanPPAttr"` ) {
$result = "lifespanPP";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kLineWidthAttr"` ) {
$result = "lineWidth";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kMassAttr"` ) {
$result = "mass";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kMultiCountAttr"` ) {
$result = "multiCount";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kMultiRadiusAttr"` ) {
$result = "multiRadius";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kNormalDirAttr"` ) {
$result = "normalDir";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kOpacityPPAttr"` ) {
$result = "opacityPP";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kParticleIDAttr"` ) {
$result = "particleId";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kPointSizeAttr"` ) {
$result = "pointSize";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kPositionAttr"` ) {
$result = "position";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRadius1Attr"` ) {
$result = "radius1";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRadiusPPAttr"` ) {
$result = "radiusPP";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRampAccelerationAttr"` ) {
$result = "rampAcceleration";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRampPositionAttr"` ) {
$result = "rampPosition";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRampVelocityAttr"` ) {
$result = "rampVelocity";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kRgbPPAttr"` ) {
$result = "rgbPP";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSelectedOnlyAttr"` ) {
$result = "selectedOnly";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSpriteNumAttr"` ) {
$result = "spriteNum";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSpriteScaleXAttr"` ) {
$result = "spriteScaleX";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSpriteScaleYAttr"` ) {
$result = "spriteScaleY";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSpriteTwistAttr"` ) {
$result = "spriteTwist";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kSurfaceShadingAttr"` ) {
$result = "surfaceShading";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kTailFadeAttr"` ) {
$result = "tailFade";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kTailSizeAttr"` ) {
$result = "tailSize";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kUseLightingAttr"` ) {
$result = "useLighting";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kVelocityAttr"` ) {
$result = "velocity";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kWorldPositionAttr"` ) {
$result = "worldPosition";
} else if( $ui == `uiRes "m_AEdynParticleInstancerNew.kWorldVelocityAttr"` ) {
$result = "worldVelocity";
} else {
uiToMelMsg "instancerMenuAttrs_uiToMel" $ui 0;
}
return $result;
}
global proc AEcreateInstancerMenuItem( string $list[], string $attrName, string $default )
{
int $index = 1;
string $miName;
string $omName = "AE" + $attrName + "OM";
optionMenuGrp -label `instancerMenuLabels_melToUI $attrName`
-cc ("AEparticleAttrChanged " + $attrName) $omName;
// Add the "None" option for the option menu. Position must always be defined so
// it cannot have a "None" option.
//
string $none = "None";
if ( $attrName != "Position" )
{
// If the attribute does not have an assigned value then set the default to
// "None".
//
if ( $default == "" )
{
$default = $none;
}
// Else, make sure "None" is an option.
//
$miName = "AE" + $attrName + "MenuItem" + $index;
menuItem -label `instancerMenuAttrs_melToUI $none` $miName;
$index++;
}
for ( $i = 0; $i < size( $list ); $i++ )
{
$miName = "AE" + $attrName + "MenuItem" + $index;
menuItem -label `instancerMenuAttrs_melToUI $list[$i]` $miName;
$index++;
}
if( $default != $none )
{
if( !itemInList( $default, $list ) )
{
$miName = "AE" + $attrName + "MenuItem" + $index;
menuItem -label `instancerMenuAttrs_melToUI $default` $miName;
$index++;
}
}
// Select the default item.
//
optionMenuGrp -e -value `instancerMenuAttrs_melToUI $default` $omName;
}
global proc AEeditInstancerMenuItem( string $list[], string $attrName, int $validHeadSize )
{
global string $AEselectedParticle;
int $index = 1;
string $miName;
string $omName = "AE" + $attrName + "OM";
optionMenuGrp -e -label `instancerMenuLabels_melToUI $attrName` $omName;
string $omList[] = `optionMenuGrp -q -itemListShort $omName`;
int $currentSize = size( $omList );
int $listSize = size( $list );
setParent $omName;
string $menuParent = `setParent -q`;
setParent -m ($menuParent + "|OptionMenu");
// Make sure that all attributes have a "None" menu item except
// for "Position" which always needs to have a valid value.
//
string $default = "worldPosition";
int $offset = 0;
if ( $attrName != "Position" )
{
$listSize += 1;
$offset = 1;
$default = "None";
}
if ( $listSize > $currentSize )
{
//
// Add more entries if needed.
//
for ( $i = $currentSize; $i < $listSize; $i++ )
{
$index = $i + 1;
$miName = "AE" + $attrName + "MenuItem" + $index;
string $label = $list[$i];
// Seems by design that $list[$i] can be empty. When this
// happens, don't try to do a lookup.
//
if( $label != "" ) {
$label = `instancerMenuAttrs_melToUI $label`;
}
menuItem -label $label $miName;
}
}
else if ( $listSize < $currentSize )
{
//
// Remove extra entries.
//
for ( $i = $listSize; $i < $currentSize; $i++ )
{
deleteUI $omList[$i];
}
}
$index = $validHeadSize+$offset+1;
int $listIndex = $validHeadSize;
for ( $i = $validHeadSize + $offset; $i < $listSize; $i++ )
{
$miName = "AE" + $attrName + "MenuItem" + $index;
menuItem -e -label `instancerMenuAttrs_melToUI $list[$listIndex]` $miName;
$index++;
$listIndex++;
}
int $no_of_items = `optionMenuGrp -q -ni AEdynInstancerNodeOM`;
if( $no_of_items != 0 ){
string $selectedInstancer = `optionMenuGrp -q -v AEdynInstancerNodeOM`;
string $flag = AEparticleInstancerCmdFlag( $attrName );
string $value = `particleInstancer -name $selectedInstancer -q $flag $AEselectedParticle`;
if ( size( $value ) > 0 )
{
if( !itemInList( $value, $list ) )
{
$miName = "AE" + $attrName + "MenuItem" + $index;
menuItem -label `instancerMenuAttrs_melToUI $value` $miName;
$index++;
}
// If I do not select this default one first and then
// select the real one, it does not always update.
// It might have to do with the fact that the times it
// does not update is when the one to select is the
// last one.
//
optionMenuGrp -e -value `instancerMenuAttrs_melToUI $default` $omName;
optionMenuGrp -e -value `instancerMenuAttrs_melToUI $value` $omName;
}
else
{
optionMenuGrp -e -value `instancerMenuAttrs_melToUI $default` $omName;
}
}
}
global proc AEparticleAttrChanged( string $nodeName )
{
global string $AEselectedParticle;
string $selectedInstancer = `optionMenuGrp -q -v AEdynInstancerNodeOM`;
string $omName = "AE" + $nodeName + "OM";
string $value = instancerMenuAttrs_uiToMel( `optionMenuGrp -q -v $omName` );
string $flag = AEparticleInstancerCmdFlag( $nodeName );
if( $value == "None" ) {
$value = "\"\"";
}
string $cmdString = ("particleInstancer -e -name "+$selectedInstancer+" "+$flag+" "+$value+" "+$AEselectedParticle);
evalEcho $cmdString;
}
global proc string AEparticleInstancerCmdFlag( string $attrName )
{
string $flag;
if ( $attrName == "Position" )
{
$flag = "-position";
}
else if ( $attrName == "Rotation" )
{
$flag = "-rotation";
}
else if ( $attrName == "AimDirection" )
{
$flag = "-aimDirection";
}
else if ( $attrName == "AimPosition" )
{
$flag = "-aimPosition";
}
else if ( $attrName == "AimAxis" )
{
$flag = "-aimAxis";
}
else if ( $attrName == "AimUpAxis" )
{
$flag = "-aimUpAxis";
}
else if ( $attrName == "AimWorldUp" )
{
$flag = "-aimWorldUp";
}
else if ( $attrName == "Scale" )
{
$flag = "-scale";
}
else if ( $attrName == "Shear" )
{
$flag = "-shear";
}
else if ( $attrName == "RotationType" )
{
$flag = "-rotationType";
}
else if ( $attrName == "ObjectIndex" )
{
$flag = "-objectIndex";
}
else if ( $attrName == "Visibility" )
{
$flag = "-visibility";
}
else if ( $attrName == "CycleStartObject" )
{
$flag = "-cycleStartObject";
}
else if ( $attrName == "Age" )
{
$flag = "-age";
}
return $flag;
}
global proc AEparticleInstWatchCycleAttribute()
{
int $no_of_items = `optionMenuGrp -q -ni AEdynInstancerNodeOM`;
if( $no_of_items == 0 ){
return;
}
string $selectedInstancer = `optionMenuGrp -q -v AEdynInstancerNodeOM`;
if(( $selectedInstancer == `instancerMenuAttrs_melToUI "None"` )
|| ( $selectedInstancer == "" ))
{
return;
}
string $attr = ($selectedInstancer+".cycle");
int $cycleValue = `getAttr $attr`;
if( $cycleValue == 0 )
{
optionMenuGrp -e -enable 1 AEObjectIndexOM;
optionMenuGrp -e -enable 0 AECycleStartObjectOM;
optionMenuGrp -e -enable 0 AEAgeOM;
}
else
{
optionMenuGrp -e -enable 0 AEObjectIndexOM;
optionMenuGrp -e -enable 1 AECycleStartObjectOM;
optionMenuGrp -e -enable 1 AEAgeOM;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment