//============================================================================= // // le_path_edit.mel - handles all functions for path entry/maintenance, etc. // //============================================================================= global int $le_path_point_script_job[]; global int $le_path_moved_script_job, $le_path_rotated_script_job; global int $le_path_spans; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_path_buttons (string $thing) { global int $le_path_point_script_job[]; global int $le_path_moved_script_job, $le_path_rotated_script_job; global int $le_path_spans; global string $le_dialog_name; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/3 - 2; $layout = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 $cwidth -columnSpacing 1 2 -columnWidth 2 $cwidth -columnSpacing 2 2 -columnWidth 3 $cwidth -columnSpacing 3 1`; button -label "Set path type"; popupMenu -button 1; menuItem -label "Camera path" -c ("le_set_path_type (\"" + $thing + "\", \"cam_path\")"); menuItem -label "AI path" -c ("le_set_path_type (\"" + $thing + "\", \"ai_path\")"); string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $type = le_find_param_in_pairs ($pairs, "type"); textField -editable false -text $type "path_type"; setParent ..; le_build_separator(); //------------------------------------------ string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/3 - 2; $layout = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 $cwidth -columnSpacing 1 2 -columnWidth 2 $cwidth -columnSpacing 2 2 -columnWidth 3 $cwidth -columnSpacing 3 1`; button -label "Set 'object' mode" -command ("le_select_path (\"" + $thing + "\")"); button -label "Set 'point' mode" -command ("le_set_point_mode ()"); button -label "Center pivot" -command ("le_center_path_pivot (\"" + $thing + "\")"); setParent ..; //------------------------------------------ $layout = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 $cwidth -columnSpacing 1 2 -columnWidth 2 $cwidth -columnSpacing 2 2 -columnWidth 3 $cwidth -columnSpacing 3 1`; button -label "Add points to end" -command ("le_add_points_to_end (\"" + $thing + "\")"); button -label "Stop adding points" -command ("le_stop_adding_points (\"" + $thing + "\")"); setParent ..; //------------------------------------------ $layout = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 $cwidth -columnSpacing 1 2 -columnWidth 2 $cwidth -columnSpacing 2 2 -columnWidth 3 $cwidth -columnSpacing 3 1`; button -label "Insert point" -command ("le_insert_path_point (\"" + $thing + "\")"); button -label "Reverse path points" -command ("le_reverse_path_points (\"" + $thing + "\")"); button -label "Delete selected point(s)" -command ("le_delete_selected_point (\"" + $thing + "\")"); setParent ..; $le_path_spans = `getAttr ($thing + ".spans")`; // kill old one if ($le_path_moved_script_job != 0) scriptJob -kill $le_path_moved_script_job; string $attr = $thing + ".translate"; $le_path_moved_script_job = `scriptJob -parent $le_dialog_name -disregardIndex -attributeChange $attr ("le_path_moved (\"" + $thing + "\")")`; // kill old one if ($le_path_rotated_script_job != 0) scriptJob -kill $le_path_rotated_script_job; $attr = $thing + ".rotate"; $le_path_rotated_script_job = `scriptJob -parent $le_dialog_name -disregardIndex -attributeChange $attr ("le_path_moved (\"" + $thing + "\")")`; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_path_moved (string $thing) { FreezeTransformations $thing; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_set_path_type (string $thing, string $type) { le_update_path ($thing, $type); textField -e -text $type "path_type"; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_select_path (string $thing) { changeSelectMode -object; select $thing; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_center_path_pivot (string $thing) { int $i, $j; float $sum[3], $pos[3]; string $point; int $num = `getAttr ($thing + ".spans")`; if ($num == 0) return; // calculated weighted center for ($i=0; $i<$num; $i++) { $point = $thing + ".ep[" + $i + "]"; $pos = `getAttr $point`; for ($j=0; $j<3; $j++) $sum[$j] += $pos[$j]; } $pos[0] = $sum[0] / $num; $pos[1] = $sum[1] / $num; $pos[2] = $sum[2] / $num; move $pos[0] $pos[1] $pos[2] ($thing+".scalePivot") ($thing+".rotatePivot"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_insert_path_point (string $thing) { string $sel[] = `ls -sl`; print ($sel[0] + "\n"); InsertKnot; int $i; int $num = `getAttr ($thing + ".spans")`; float $pos[] = `pointPosition $sel[0]`; float $pos2[]; string $point; for ($i=0; $i<=$num; $i++) { $point = $thing + ".ep[" + $i +"]"; $pos2 = `pointPosition $point`; if (abs ($pos[0] - $pos2[0]) < .0001 && abs ($pos[1] - $pos2[1]) < .0001 && abs ($pos[2] - $pos2[2]) < .0001) select $point; } hilite $thing; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_add_points_to_end (string $thing) { changeSelectMode -component; setComponentPickMask "Point" false; setComponentPickMask "ParmPoint" true; select ($thing + ".ep[0]"); AddPointsTool; hilite $thing; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_stop_adding_points (string $thing) { setToolTo "selectSuperContext"; int $num = `getAttr ($thing + ".spans")`; select ($thing + ".ep[" + $num + "]"); hilite $thing; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_reverse_path_points (string $thing) { global int $le_path_point_script_job[]; global string $le_dialog_name; global int $le_path_spans; int $i; for ($i=0; $i= $len) { $point = `substring $point 1 $len`; if ($point == $cmp) { delete; select $sel[0]; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_path_point_editor (string $thing, int $index) { global int $le_path_point_script_job[]; global string $le_dialog_name; string $values[3]; float $pos[3]; string $label; string $point = "ep[" + $index + "]"; string $name = $thing + "." + $point; $pos = `getAttr $name`; // indicate which one is currently selected string $sel[] = `ls -sl -flatten`; string $selected = ""; string $item; for ($item in $sel) { if ($name == $item) $selected = "==> "; } $label = ($selected + "Point " + $index); $values[0] = (string)$pos[0]; $values[1] = (string)$pos[1]; $values[2] = (string)$pos[2]; // parent window will be set up for us and returned with one slot available for button le_build_float ($label, ("point"+$index), $values, "le_handle_path", 1); button -label "Select" -command ("le_select_path_point (\"" + $thing + "\", \"" + $point + "\")"); setParent ..; $le_path_point_script_job[$index] = `scriptJob -parent $le_dialog_name -runOnce true -attributeChange $name ("le_update_path_point(\"" + $thing + "\", \"" + $index + "\")")`; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_update_path_point (string $thing, int $index) { global int $le_path_point_script_job[]; global string $le_dialog_name; global int $le_path_spans; if (`objExists $thing` == false) return; int $i; string $shape[] = `listRelatives ($thing)`; int $cur_spans = `getAttr ($thing + "|" + $shape[0] + ".spans")`; if ($le_path_spans != $cur_spans) { for ($i=0; $i