// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // ========== pEditCompSetAttrCB ========== // // Description: // User has selected the "Set Attribute" in the Edit Component // dialog; so set the selected attribute with the correct values. // global proc pEditCompSetAttrCB(string $nodeName, string $attrName, string $attrType) { // global string $dynParticleSaveParent; // setParent $dynParticleSaveParent; string $cmd; if (size($attrName) == 0) { warning( (uiRes("m_AEparticleEditComponent.kNoValidSelection")) ); return; } int $relative = `checkBoxGrp -q -v1 particleRelativeCB`; int $editType = `radioButtonGrp -q -sl pEditCompRB`; if ($attrType == "Float") { float $offset = `floatSliderGrp -q -v particleRandomOffset`; float $value = `floatSliderGrp -q -v particleComponentVal`; if ($editType == 1) { $cmd = "setParticleAttr -at "+$attrName+" -fv "+ $value +" -rf "+$offset + " -r " +$relative; evalEcho $cmd; } else { $cmd = "setParticleAttr -at "+$attrName+" -fv "+ $value +" -rf "+$offset + " -r " +$relative +" -o "+$nodeName; evalEcho $cmd; } } else { float $offsetX = `floatSliderGrp -q -v particleRandomOffsetX`; float $offsetY = `floatSliderGrp -q -v particleRandomOffsetY`; float $offsetZ = `floatSliderGrp -q -v particleRandomOffsetZ`; float $valueX = `floatSliderGrp -q -v particleComponentValX`; float $valueY = `floatSliderGrp -q -v particleComponentValY`; float $valueZ = `floatSliderGrp -q -v particleComponentValZ`; if ($editType == 1) { $cmd = "setParticleAttr -at "+$attrName+" -vv "+$valueX+" "+$valueY+" "+$valueZ+" -rv "+$offsetX+" "+$offsetY+" "+$offsetZ+" -r " +$relative; evalEcho $cmd; } else { $cmd = "setParticleAttr -at "+$attrName+" -vv "+$valueX+" "+$valueY+" "+$valueZ+" -rv "+$offsetX+" "+$offsetY+" "+$offsetZ+" -r " +$relative+" -o "+$nodeName; evalEcho $cmd; } } pEditCompSetAverage($nodeName, $attrName, $attrType, $editType); int $saveState = `checkBoxGrp -q -v2 particleRelativeCB`;; if ($saveState) { evalEcho("saveInitialState -attribute " + $attrName + " " +$nodeName); } } // pEditCompSetAttrCB global proc pEditCompSetAverage(string $nodeName, string $attrName, string $attrType, int $editType) { if (!`attributeQuery -exists -node $nodeName $attrName`) { string $fmt = (uiRes("m_AEparticleEditComponent.kAttrInexistant")); warning( `format -s $attrName -s $nodeName $fmt` ); textFieldGrp -e -en 1 pEditCompAttrTF; checkBoxGrp -e -en 0 particleRelativeCB; radioButtonGrp -e -en 0 pEditCompRB; tabLayout -e -en 0 pEditCompValsTL; rowLayout -e -en 0 particleEditCompAverageValue; rowLayout -e -en 0 particleEditCompMaxAverageOffset; return; } else { float $average[6]; if ($editType == 2) $average = `getParticleAttr -at $attrName -o $nodeName`; else $average = `getParticleAttr -at $attrName`; if ($attrType == "Float") { floatField -e -v $average[0] particleEditCompAverageValueX; floatField -e -vis 0 particleEditCompAverageValueY; floatField -e -vis 0 particleEditCompAverageValueZ; floatField -e -v $average[1] particleEditCompMaxAverageOffsetX; floatField -e -vis 0 particleEditCompMaxAverageOffsetY; floatField -e -vis 0 particleEditCompMaxAverageOffsetZ; } else { floatField -e -v $average[0] particleEditCompAverageValueX; floatField -e -vis 1 -v $average[1] particleEditCompAverageValueY; floatField -e -vis 1 -v $average[2] particleEditCompAverageValueZ; floatField -e -v $average[3] particleEditCompMaxAverageOffsetX; floatField -e -vis 1 -v $average[4] particleEditCompMaxAverageOffsetY; floatField -e -vis 1 -v $average[5] particleEditCompMaxAverageOffsetZ; } } } // pEditCompSetAverage // **************************************************************** // // COMPONENT EDITOR PROCEDURES // // **************************************************************** global proc pEditCompSetSliderLabels(string $attrName) { if ($attrName != "rgbPP") { floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kX")) particleComponentValX; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kY")) particleComponentValY; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kZ")) particleComponentValZ; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kX")) particleRandomOffsetX; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kY")) particleRandomOffsetY; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kZ")) particleRandomOffsetZ; } else { floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kR")) particleComponentValX; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kG")) particleComponentValY; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kB")) particleComponentValZ; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kR")) particleRandomOffsetX; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kG")) particleRandomOffsetY; floatSliderGrp -e -label (uiRes("m_AEparticleEditComponent.kB")) particleRandomOffsetZ; } } // ========== pEditCompGetAttrCB ========== // // Description: // User has selected the "Get Attribute" in the Edit Component // dialog; so get the values of the selected attribute. // global proc pEditCompGetAttrCB(string $nodeName, string $attrName, string $attrType) { global string $dynParticleSaveParent; // setParent $dynParticleSaveParent; int $editType = `radioButtonGrp -q -sl pEditCompRB`; pEditCompSetAverage($nodeName, $attrName, $attrType, $editType); } // pEditCompGetAttrCB // ========== pEditCompSelectTypeCB ========== // // Description: // User has changed the selection method (object, selected comps). // If editing whole object, enable the object name textfield. // If editing selected components, disable it. // global proc pEditCompSelectTypeCB(string $nodeName, string $attrName, string $attrType, int $editType) { global string $dynParticleSaveParent; // setParent $dynParticleSaveParent; textFieldGrp -e -text $nodeName pEditCompObjTF; if ($editType == 2) { textFieldGrp -e -enable true pEditCompObjTF; } else { textFieldGrp -e -enable false pEditCompObjTF; } pEditCompSetAverage($nodeName, $attrName, $attrType, $editType); } // pEditCompSelectTypeCB // ========== pEditCompAttrNameCB ========== // // Description: // User has changed the attribute name. // Get the values for the new attribute, and reset appropriate // callbacks. // global proc pEditCompAttrNameCB( string $attrName ) { global string $dynParticleSaveParent; // setParent $dynParticleSaveParent; // string $attrName = `textFieldGrp -q -text pEditCompAttrTF`; string $nodeName = `textFieldGrp -q -text pEditCompObjTF`; // If the attribute doesn't exist, warn the user and return. // I can only do this if there is an object name. // if (size($nodeName) > 0) { if (!`attributeQuery -exists -node $nodeName $attrName`) { warning( `format -s $attrName -s $nodeName (uiRes("m_AEparticleEditComponent.kAttrInexistant"))` ); checkBoxGrp -e -en 0 particleRelativeCB; radioButtonGrp -e -en 0 pEditCompRB; tabLayout -e -en 0 pEditCompValsTL; rowLayout -e -en 0 particleEditCompAverageValue; rowLayout -e -en 0 particleEditCompMaxAverageOffset; return; } else { checkBoxGrp -e -en 1 particleRelativeCB; radioButtonGrp -e -en 1 pEditCompRB; tabLayout -e -en 1 pEditCompValsTL; rowLayout -e -en 1 particleEditCompAverageValue; rowLayout -e -en 1 particleEditCompMaxAverageOffset; } } // Have to figure out what type it is; first check the list // of static array attributes. If it's not in there, then get // the list of dynamic attributes from the particle command, // and check it out. // Also, it has to be a float or vector array type. // string $attrType; if ($attrName == "position" || $attrName == "velocity" || $attrName == "acceleration") { $attrType = "Vector"; tabLayout -e -selectTab pEditCompVecValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 1") pEditCompRB; } else if ($attrName == "mass") { $attrType = "Float"; tabLayout -e -selectTab pEditCompFloatValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 1") pEditCompRB; } else { string $dynamicAttrList[] = `particle -q -dal $nodeName`; int $numDynAttrs = size($dynamicAttrList); if ($numDynAttrs > 0) { int $i; string $dynTokenAry[]; for ($i = 0; $i < $numDynAttrs; $i++) { tokenize( $dynamicAttrList[$i], ":", $dynTokenAry ); if ($dynTokenAry[0] == $attrName) { if ($dynTokenAry[1] == "vectorArray") { $attrType = "Vector"; tabLayout -e -selectTab pEditCompVecValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 1") pEditCompRB; break; } else if ($dynTokenAry[1] == "doubleArray") { $attrType = "Float"; tabLayout -e -selectTab pEditCompFloatValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 1") pEditCompRB; break; } else { warning( (uiRes("m_AEparticleEditComponent.kAttrWrongType")) ); return; } } } clear ($dynTokenAry); } clear ($dynamicAttrList); } // If the new attr is rgbPP, have to set XYX slider labels to RGB, // otherwise set the labels to XYZ. // if ($attrType == "Vector") pEditCompSetSliderLabels($attrName); button -e -c ("pEditCompSetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompSetAttrBtn; button -e -c ("pEditCompGetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompGetAttrBtn; if (size($nodeName) == 0) $nodeName = " "; pEditCompGetAttrCB($nodeName, $attrName, $attrType); } // pEditCompAttrNameCB // ========== pEditCompObjNameCB ========== // // Description: // User has changed the object name. // Get the values for the new object, and reset appropriate // callbacks. // global proc pEditCompObjNameCB( string $nodeName ) { global string $dynParticleSaveParent; // setParent $dynParticleSaveParent; // MAKE SURE THE OBJ NAME IS CORRECT ???? // string $attrName = `textFieldGrp -q -text pEditCompAttrTF`; // string $nodeName = `textFieldGrp -q -text pEditCompObjTF`; if (`objExists $nodeName`) { // enable all the devices in case a wrong nodeName was entered textFieldGrp -e -en 1 pEditCompAttrTF; checkBoxGrp -e -en 1 particleRelativeCB; radioButtonGrp -e -en 1 pEditCompRB; tabLayout -e -en 1 pEditCompValsTL; rowLayout -e -en 1 particleEditCompAverageValue; rowLayout -e -en 1 particleEditCompMaxAverageOffset; // check for which tab is selected int $whichTab = `tabLayout -q -selectTabIndex pEditCompValsTL`; if ($whichTab == 1) $attrType = "Float"; else $attrType = "Vector"; button -e -c ("pEditCompSetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompSetAttrBtn; button -e -c ("pEditCompGetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompGetAttrBtn; pEditCompGetAttrCB($nodeName, $attrName, $attrType); } else { // disable all the widgets because an invalid node was // entered textFieldGrp -e -en 0 pEditCompAttrTF; checkBoxGrp -e -en 0 particleRelativeCB; radioButtonGrp -e -en 0 pEditCompRB; tabLayout -e -en 0 pEditCompValsTL; rowLayout -e -en 0 particleEditCompAverageValue; rowLayout -e -en 0 particleEditCompMaxAverageOffset; string $fmt = (uiRes("m_AEparticleEditComponent.kNodeInexistant")); warning( `format -s $nodeName $fmt` ); return; } } // pEditCompObjNameCB // ========== AEparticleEditComponent ========== // // Description: // Bring up the Edit Component dialog. // global proc AEparticleEditComponent ( string $nodeName, string $attrName, string $attrType) { setUITemplate -pst attributeEditorTemplate; global float $gDynMaxFloatField; global float $gDynMinFloatField; string $buffer[]; tokenize($nodeName, "|", $buffer); $nodeName = $buffer[size($buffer) - 1]; if (!`window -exists "pEditCompWin"`) { window -title (uiRes("m_AEparticleEditComponent.kParticleComponents")) -rtf false -wh 460 460 pEditCompWin; setUITemplate -pst attributeEditorTemplate; // setup the main look of the window formLayout -nd 100 pEditCompBtnsF; columnLayout -adj false pEditCompCL; setParent ..; setUITemplate -pst attributeEditorPresetsTemplate; rowLayout -nc 4 -cat 1 right 5 -cat 2 both 0 -cat 3 both 0 -cat 4 both 0 particleEditCompAverageValue; text -label (uiRes("m_AEparticleEditComponent.kAverageValue")) ; floatField -ed 0 particleEditCompAverageValueX; floatField -ed 0 particleEditCompAverageValueY; floatField -ed 0 particleEditCompAverageValueZ; setParent ..; rowLayout -nc 4 -cat 1 right 5 -cat 2 both 0 -cat 3 both 0 -cat 4 both 0 particleEditCompMaxAverageOffset; text -label (uiRes("m_AEparticleEditComponent.kMaxOffsetfromAverage")) ; floatField -ed 0 particleEditCompMaxAverageOffsetX; floatField -ed 0 particleEditCompMaxAverageOffsetY; floatField -ed 0 particleEditCompMaxAverageOffsetZ; setParent ..; setUITemplate -ppt; button -label (uiRes("m_AEparticleEditComponent.kSetAttribute")) -c ("pEditCompSetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompSetAttrBtn; button -label (uiRes("m_AEparticleEditComponent.kGetAttribute")) -c ("pEditCompGetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompGetAttrBtn; button -label (uiRes("m_AEparticleEditComponent.kClose")) -c ("window -e -vis 0 pEditCompWin") pEditCompWinCloseButton; separator -hr true -h 20 particleEditWndSeparator; tabLayout -tabsVisible false -cr true -scrollable true -hst 0 -vst 0 pEditCompValsTL; setParent ..; setParent ..; formLayout -e -af pEditCompCL top 4 -af pEditCompCL right 0 -af pEditCompCL left 0 -an pEditCompCL bottom -ac pEditCompValsTL top 0 pEditCompCL -af pEditCompValsTL left 0 -af pEditCompValsTL right 0 -ac pEditCompValsTL bottom 0 particleEditCompAverageValue -af particleEditCompAverageValue left 0 -af particleEditCompAverageValue right 0 -an particleEditCompAverageValue top -ac particleEditCompAverageValue bottom 0 particleEditCompMaxAverageOffset -af particleEditCompMaxAverageOffset left 0 -af particleEditCompMaxAverageOffset right 0 -an particleEditCompMaxAverageOffset top -ac particleEditCompMaxAverageOffset bottom 0 particleEditWndSeparator -an particleEditWndSeparator top -af particleEditWndSeparator left 0 -af particleEditWndSeparator right 0 -af particleEditWndSeparator bottom 30 -ac pEditCompSetAttrBtn top 0 particleEditWndSeparator -ap pEditCompSetAttrBtn left 0 2 -ap pEditCompSetAttrBtn right 0 32 -af pEditCompSetAttrBtn bottom 5 -ac pEditCompGetAttrBtn top 0 particleEditWndSeparator -ap pEditCompGetAttrBtn left 0 34 -ap pEditCompGetAttrBtn right 0 66 -af pEditCompGetAttrBtn bottom 5 -ac pEditCompWinCloseButton top 0 particleEditWndSeparator -ap pEditCompWinCloseButton left 0 68 -ap pEditCompWinCloseButton right 0 98 -af pEditCompWinCloseButton bottom 5 pEditCompBtnsF; // start building the widgets // setParent pEditCompCL; textFieldGrp -label (uiRes("m_AEparticleEditComponent.kObjectName")) -text $nodeName -cc ("pEditCompObjNameCB #1") pEditCompObjTF; textFieldGrp -label (uiRes("m_AEparticleEditComponent.kAttributeName")) -text $attrName -cc ("pEditCompAttrNameCB #1") pEditCompAttrTF; radioButtonGrp -label (uiRes("m_AEparticleEditComponent.kEdit")) -label2 (uiRes("m_AEparticleEditComponent.kEntireObject")) -label1 (uiRes("m_AEparticleEditComponent.kSelectedComponents")) -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +$attrType+" 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +$attrType+" 1") -nrb 2 pEditCompRB; radioButtonGrp -e -select 1 pEditCompRB; checkBoxGrp -ncb 2 -label "" -label1 (uiRes("m_AEparticleEditComponent.kRelative")) -label2 (uiRes("m_AEparticleEditComponent.kSaveInitialState")) -v2 1 particleRelativeCB; string $attrValue = (uiRes("m_AEparticleEditComponent.kAttributeValue")) ; string $randomOffset = (uiRes("m_AEparticleEditComponent.kRandomOffset")) ; // create the widgets for the tabLayout setParent pEditCompValsTL; columnLayout pEditCompFloatValsCL; frameLayout -bv 0 -cll false -lv false ; columnLayout; floatSliderGrp -label $attrValue -field true -min -10 -max 10 -fmn $gDynMinFloatField -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleComponentVal; floatSliderGrp -label $randomOffset -field true -min 0 -max 10 -fmn 0 -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleRandomOffset; setParent ..; setParent ..; setParent ..; // columnLayout columnLayout pEditCompVecValsCL; string $x = (uiRes("m_AEparticleEditComponent.kX")) ; string $y = (uiRes("m_AEparticleEditComponent.kY")) ; string $z = (uiRes("m_AEparticleEditComponent.kZ")) ; string $r = (uiRes("m_AEparticleEditComponent.kR")) ; string $g = (uiRes("m_AEparticleEditComponent.kG")) ; string $b = (uiRes("m_AEparticleEditComponent.kB")) ; frameLayout -bv 0 -cll false -label $attrValue columnLayout; floatSliderGrp -label $x -field true -min -10 -max 10 -fmn $gDynMinFloatField -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleComponentValX; floatSliderGrp -label $y -field true -min -10 -max 10 -fmn $gDynMinFloatField -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleComponentValY; floatSliderGrp -label $z -field true -min -10 -max 10 -fmn $gDynMinFloatField -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleComponentValZ; setParent ..; setParent ..; separator; frameLayout -bv 0 -cll false -label $randomOffset columnLayout; floatSliderGrp -label $x -field true -min 0 -max 10 -fmn 0 -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleRandomOffsetX; floatSliderGrp -label $y -field true -min 0 -max 10 -fmn 0 -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleRandomOffsetY; floatSliderGrp -label $z -field true -min 0 -max 10 -fmn 0 -fmx $gDynMaxFloatField -pre 3 -step 0.1 particleRandomOffsetZ; setParent ..; setParent ..; setParent ..; // columnLayout setParent ..; // tabLayout setUITemplate -ppt; } else { textFieldGrp -e -text $nodeName pEditCompObjTF; textFieldGrp -e -text $attrName pEditCompAttrTF; button -e -c ("pEditCompSetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompSetAttrBtn; button -e -c ("pEditCompGetAttrCB " +$nodeName+" " +$attrName+" " +$attrType) pEditCompGetAttrBtn; // make sure everything is enabled when a new attribute // is selected from the attribute editor textFieldGrp -e -en 1 pEditCompObjTF; textFieldGrp -e -en 1 pEditCompAttrTF; checkBoxGrp -e -en 1 particleRelativeCB; radioButtonGrp -e -en 1 pEditCompRB; tabLayout -e -en 1 pEditCompValsTL; rowLayout -e -en 1 particleEditCompAverageValue; rowLayout -e -en 1 particleEditCompMaxAverageOffset; int $RBselected = `radioButtonGrp -q -sl pEditCompRB`; pEditCompSelectTypeCB $nodeName $attrName $attrType $RBselected; } if ($attrType == "Float") { floatSliderGrp -e -v 0.0 particleComponentVal; floatSliderGrp -e -v 0.0 particleRandomOffset; tabLayout -e -selectTab pEditCompFloatValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Float 1") pEditCompRB; } else { floatSliderGrp -e -v 0.0 particleComponentValX; floatSliderGrp -e -v 0.0 particleComponentValY; floatSliderGrp -e -v 0.0 particleComponentValZ; floatSliderGrp -e -v 0.0 particleRandomOffsetX; floatSliderGrp -e -v 0.0 particleRandomOffsetY; floatSliderGrp -e -v 0.0 particleRandomOffsetZ; pEditCompSetSliderLabels($attrName); tabLayout -e -selectTab pEditCompVecValsCL pEditCompValsTL; radioButtonGrp -e -cc2 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 2") -cc1 ("pEditCompSelectTypeCB " +$nodeName+" " +$attrName+" " +" Vector 1") pEditCompRB; } pEditCompGetAttrCB($nodeName, $attrName, $attrType); int $RBselected = `radioButtonGrp -q -sl pEditCompRB`; pEditCompSelectTypeCB $nodeName $attrName $attrType $RBselected; setUITemplate -ppt; showWindow pEditCompWin; } // AEparticleEditComponent