/* Shader Attribute Cycler version: 0.1 By Tito Sciortino June 2008 This is a tool that uses MEL in Maya to cycle through up to three attributes of a shader, rendering and image for each combination of attributes. The values of the three attributes are shown in the rendered images, and are orthogonal to the persp camera. (Make sure persp is the active (rendering) camera, otherwise you won't see the attribute values.) See incblots.com for more information. To do: inputs (1) Get file ext from Maya defaultRenderGlobals. outputs (2) Add notes field to appear in renderings (renderer, render settings, etc.) (3) Add date/time stamp option in renderings. (4) Show name of shader in rendering. (5) Show name of Maya file in rendering. (? It's already in the output file names.) (6) Add render time to image (post-process?). other (7) Save and restore original shader values. (8) Flag to overwrite files. (9) Permutations option. (10) Installation/use instructions. (11) Use batch render. */ global string $shaderGroup; global float $totalSteps; global float $totalIterations; global int $deleteTempObjects; global string $attrName[]; global float $attrStart[]; global float $attrEnd[]; global float $attrIncrement[]; global int $char_count[]; global string $the_output[]; global string $outputShader; global int $iterate_attr[]; global float $units_from_camera; global float $scale_x_base; global float $scale_y_base; global float $translate_x_base; global float $translate_y_base; global float $translate_x_offset; global float $translate_y_offset; global float $line_spacing; global float $rotate_pivot_x_base; global float $rotate_pivot_y_base; global float $rotate_pivot_z_base; global float $rotate_x_base; global float $rotate_y_base; global float $rotate_z_base; global float $scale_x[]; global float $scale_y[]; global float $translate_x[]; global float $translate_y[]; global float $rotate_pivot_x[]; global float $rotate_pivot_y[]; global float $rotate_pivot_z[]; global float $rotate_x[]; global float $rotate_y[]; global float $rotate_z[]; global string $wordStem; global string $charStem; global string $trimStem; global string $groupStem; global string $planeStem; global string $shaderStem; global string $windowStem; global string $file_path; global string $file_nameStem; global string $file_ext; global string $file_type; global int $file_type_code; global int $file_padding; global int $output_precision; global float $camera_rotatePivot[]; global float $camera_rotate[]; global float $camera_translate[]; global vector $camera_wci; global vector $camera_position; global vector $camera_up; global float $camera_wci_f[]; global float $camera_position_f[]; global float $camera_up_f[]; global int $temp; /* ----------------------------- Selected default values ------------------------ */ $wordStem = "SAC_Word_"; $charStem = "SAC_Char_"; $trimStem = "SAC_Trim_Char_"; $groupStem = "SAC_Group_"; $planeStem = "SAC_camera_orthogonal_plane"; $shaderStem = "SAC_output_shader"; $windowStem = "SAC_window"; /* ---- set output parameters ---- */ $outputShader = "SAC_output_shaderSG"; $file_path = workspace("-fn") + "/" + workspace("-rte", "images") + "/"; $file_nameStem = file("-query","-sceneName","-shortName", "-withoutCopyNumber"); $file_nameStem = match(".*\\.", $file_nameStem); $temp = size($file_nameStem) - 1; $file_nameStem = substring($file_nameStem, 1, $temp); $file_ext = ".tif"; /* get the extension */ // $file_type_code = getAttr("defaultRenderGlobals.outFormatControl"); // $file_type = lookup_image_format($file_type_code); /* ----------------- */ // $file_type = getAttr("defaultRenderGlobals.oft"); // print($file_type+"\n"); $file_type_code = getAttr("defaultRenderGlobals.imageFormat"); $file_type = lookup_image_format($file_type_code); $file_padding = getAttr("defaultRenderGlobals.extensionPadding"); /* ---- set shader modification parameters ---- */ $shaderGroup = "lambert2"; $totalSteps = 3; $deleteTempObjects = 1; $attrName = { "A_zero", "translucence", "translucenceDepth", "translucenceFocus" }; $attrLabel = { "L_zero", "trans", "depth", "focus" }; $attrStart = { 0.0, 0.0, 0.0, 0.0 }; $attrEnd = { 0.0, 1.0, 10.0, 1.0 }; $attrIncrement = { 0.0, 0.333, 3.333, 0.333 }; $iterate_attr = { 0, 1, 1, 1 }; $totalIterations = pow($totalSteps + 1, $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3]); /* ---- set label parameters ---- */ $units_from_camera = 1; $scale_x_base = 0.006; $scale_y_base = 0.006; $translate_x_base = 0.20; $translate_y_base = 0; $translate_x_offset = 0.75; $translate_y_offset = 0.25; $line_spacing = -0.05; $rotate_pivot_x_base = -2.0; $rotate_pivot_y_base = -$translate_y_base; $rotate_pivot_z_base = 0.0; $rotate_x_base = -28.04951; $rotate_y_base = 27.63278; $rotate_z_base = 1.74993; $output_precision = 3; /* ---------------------------------- Start Procedures -------------------------------*/ proc prepare_tool_window() { global string $shaderGroup; global float $totalSteps; global float $totalIterations; global int $deleteTempObjects; global string $attrName[]; global string $attrLabel[]; global float $attrStart[]; global float $attrEnd[]; global float $attrIncrement[]; global int $iterate_attr[]; global string $outputShader; global float $units_from_camera; global float $scale_x_base; global float $scale_y_base; global float $translate_x_base; global float $translate_y_base; global float $translate_x_offset; global float $translate_y_offset; global float $line_spacing; global float $rotate_pivot_x_base; global float $rotate_pivot_y_base; global float $rotate_pivot_z_base; global float $rotate_x_base; global float $rotate_y_base; global float $rotate_z_base; global float $scale_x[]; global float $scale_y[]; global float $translate_x[]; global float $translate_y[]; global float $rotate_pivot_x[]; global float $rotate_pivot_y[]; global float $rotate_pivot_z[]; global float $rotate_x[]; global float $rotate_y[]; global float $rotate_z[]; global string $file_path; global string $file_nameStem; global string $file_ext; global string $file_type; global int $file_type_code; global int $file_padding; global int $output_precision; global string $wordStem; global string $charStem; global string $trimStem; global string $groupStem; global string $planeStem; global string $shaderStem; global string $windowStem; reset_label_parameter_arrays; /* ----------------------- do window setup ------------------- */ window -title "Shader Attribute Cycler" -titleBar true -sizeable true -height 500 -width 450 $windowStem ; scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16; rowColumnLayout -numberOfColumns 2 -columnWidth 1 250 -columnWidth 2 200 -columnAlign 1 "left" ; text -align "right" -label " "; text -align "right" -label " "; text -align "right" -label "Name of shader group to be adjusted :"; textField -changeCommand "$shaderGroup = `textField -q -text shaderGroup`;" -text $shaderGroup shaderGroup; text -align "right" -label "Total steps :"; textField -changeCommand "$totalSteps = `textField -q -text totalSteps`; $totalIterations = pow($totalSteps + 1, $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3]); textField -e -text $totalIterations totalIterations; $attrIncrement[1] = ($attrEnd[1] - $attrStart[1]) / $totalSteps; textField -e -text $attrIncrement[1] attrIncrement_1; $attrIncrement[2] = ($attrEnd[2] - $attrStart[2]) / $totalSteps; textField -e -text $attrIncrement[2] attrIncrement_2; $attrIncrement[3] = ($attrEnd[3] - $attrStart[3]) / $totalSteps; textField -e -text $attrIncrement[3] attrIncrement_3;" -text $totalSteps totalSteps; text -align "right" -label "Total iterations (images to be rendered) :"; textField -enable 0 -changeCommand "$totalIterations = `textField -q -text totalIterations`;" -text $totalIterations totalIterations; text -align "right" -label "Delete all temp objects after last step :"; checkBox -label " " -changeCommand "$deleteTempObjects = `checkBox -q -value deleteTempObjects`;" -value $deleteTempObjects deleteTempObjects; separator - style "in"; separator - style "in"; text -align "right" -label "Name of first attribute :"; textField -changeCommand "$attrName[1] = `textField -q -text attrName_1`;" -text $attrName[1] attrName_1; text -align "right" -label "Attribute label in render :"; textField -changeCommand "$attrLabel[1] = `textField -q -text attrLabel_1`;" -text $attrLabel[1] attrLabel_1; text -align "right" -label "Start value :"; textField -changeCommand "$attrStart[1] = `textField -q -text attrStart_1`; $attrIncrement[1] = ($attrEnd[1] - $attrStart[1]) / $totalSteps; textField -e -text $attrIncrement[1] attrIncrement_1; " -text $attrStart[1] attrStart_1; text -align "right" -label "End value :"; textField -changeCommand "$attrEnd[1] = `textField -q -text attrEnd_1`; $attrIncrement[1] = ($attrEnd[1] - $attrStart[1]) / $totalSteps; textField -e -text $attrIncrement[1] attrIncrement_1; " -text $attrEnd[1] attrEnd_1; $attrIncrement[1] = ($attrEnd[1] - $attrStart[1]) / $totalSteps; text -align "right" -label "Increment amount :"; textField -enable 0 -text $attrIncrement[1] attrIncrement_1; separator - style "in"; separator - style "in"; text -align "right" -label "Iterate this attribute :"; /* checkBox -label " " -changeCommand " $iterate_attr[2] = `checkBox -q -value iterate_attr_2`; textField -e -enable #1 attrName_2; textField -e -enable #1 attrLabel_2; textField -e -enable #1 attrStart_2; textField -e -enable #1 attrIncrement_2; checkBox -e -enable -value #1 iterate_attr_3; $iterate_attr[3] = `checkBox -q -value iterate_attr_2`; textField -e -enable #1 attrName_3; textField -e -enable #1 attrLabel_3; textField -e -enable #1 attrStart_3; textField -e -enable #1 attrIncrement_3; $totalIterations = pow($totalSteps + 1, $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3]); textField -e -text $totalIterations totalIterations; " -value $iterate_attr[1] iterate_attr_1; */ checkBox -label " " -changeCommand "$iterate_attr[2] = `checkBox -q -value iterate_attr_2`; textField -e -enable #1 attrName_2; textField -e -enable #1 attrLabel_2; textField -e -enable #1 attrStart_2; textField -e -enable #1 attrIncrement_2; checkBox -e -enable #1 -value #1 iterate_attr_3; $iterate_attr[3] = `checkBox -q -value iterate_attr_2`; textField -e -enable #1 attrName_3; textField -e -enable #1 attrLabel_3; textField -e -enable #1 attrStart_3; textField -e -enable #1 attrIncrement_3; $totalIterations = pow($totalSteps + 1, $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3]); textField -e -text $totalIterations totalIterations; " -value $iterate_attr[2] iterate_attr_2; text -align "right" -label "Name of second attribute :"; textField -changeCommand "$attrName[2] = `textField -q -text attrName_2`;" -text $attrName[2] attrName_2; text -align "right" -label "Attribute label in render :"; textField -changeCommand "$attrLabel[2] = `textField -q -text attrLabel_2`;" -text $attrLabel[2] attrLabel_2; text -align "right" -label "Start value :"; textField -changeCommand "$attrStart[2] = `textField -q -text attrStart_2`; $attrIncrement[2] = ($attrEnd[2] - $attrStart[2]) / $totalSteps; textField -e -text $attrIncrement[2] attrIncrement_2; " -text $attrStart[2] attrStart_2; text -align "right" -label "End value :"; textField -changeCommand "$attrEnd[2] = `textField -q -text attrEnd_2`; $attrIncrement[2] = ($attrEnd[2] - $attrStart[2]) / $totalSteps; textField -e -text $attrIncrement[2] attrIncrement_2; " -text $attrEnd[2] attrEnd_2; $attrIncrement[2] = ($attrEnd[2] - $attrStart[2]) / $totalSteps; text -align "right" -label "Increment amount :"; textField -enable 0 -text $attrIncrement[2] attrIncrement_2; separator - style "in"; separator - style "in"; text -align "right" -label "Iterate this attribute :"; checkBox -label " " -changeCommand "$iterate_attr[3] = `checkBox -q -value iterate_attr_3`; textField -e -enable #1 attrName_3; textField -e -enable #1 attrLabel_3; textField -e -enable #1 attrStart_3; textField -e -enable #1 attrIncrement_3; $totalIterations = power($totalSteps + 1, $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3]); textField -e -text $totalIterations totalIterations; " -value $iterate_attr[3] iterate_attr_3; text -align "right" -label "Name of third attribute :"; textField -changeCommand "$attrName[3] = `textField -q -text attrName_3`;" -text $attrName[3] attrName_3; text -align "right" -label "Attribute label in render :"; textField -changeCommand "$attrLabel[3] = `textField -q -text attrLabel_3`;" -text $attrLabel[3] attrLabel_3; text -align "right" -label "Start value :"; textField -changeCommand "$attrStart[3] = `textField -q -text attrStart_3`; $attrIncrement[3] = ($attrEnd[3] - $attrStart[3]) / $totalSteps; textField -e -text $attrIncrement[3] attrIncrement_3; " -text $attrStart[3] attrStart_3; text -align "right" -label "End value :"; textField -changeCommand "$attrEnd[3] = `textField -q -text attrEnd_3`; $attrIncrement[3] = ($attrEnd[3] - $attrStart[3]) / $totalSteps; textField -e -text $attrIncrement[3] attrIncrement_3; " -text $attrEnd[3] attrEnd_3; $attrIncrement[3] = ($attrEnd[3] - $attrStart[3]) / $totalSteps; text -align "right" -label "Increment amount :"; textField -enable 0 -text $attrIncrement[3] attrIncrement_3; separator - style "in"; separator - style "in"; text -align "right" -label " "; text -align "right" -label " "; text -align "right" -label " "; button -label "Render" -command do_render; text -align "right" -label " "; text -align "right" -label " "; separator - style "in"; separator - style "in"; text -align "right" -label "Shader to use for output :"; textField -changeCommand "$outputShader = `textField -q -text outputShader`;" -text $outputShader outputShader; separator - style "in"; separator - style "in"; text -align "right" -label "Path to rendered images :"; textField -changeCommand "$file_path = `textField -q -text file_path`;" -text $file_path file_path; text -align "right" -label "Start of image names :"; textField -changeCommand "$file_nameStem = `textField -q -text file_nameStem`;" -text $file_nameStem file_nameStem; text -align "right" -label "File type :"; textField -enable 0 -changeCommand "$file_type = `textField -q -text file_type`;" -text $file_type file_type; text -align "right" -label "File extension :"; textField -changeCommand "$file_ext = `textField -q -text file_ext`;" -text $file_ext file_ext; text -align "right" -label "Frame padding :"; textField -enable 0 -changeCommand "$file_padding = `textField -q -text file_padding`;" -text $file_padding file_padding; separator - style "in"; separator - style "in"; text -align "right" -label "Output precision :"; textField -changeCommand "$output_precision = `textField -q -text output_precision`;" -text $output_precision output_precision; separator - style "in"; separator - style "in"; text -align "right" -label "Stem 1 for temp objects :"; textField -changeCommand "$wordStem = `textField -q -text wordStem`;" -text $wordStem wordStem; text -align "right" -label "Stem 2 for temp objects :"; textField -changeCommand "$charStem = `textField -q -text charStem`;" -text $charStem charStem; text -align "right" -label "Stem 3 for temp objects :"; textField -changeCommand "$trimStem = `textField -q -text trimStem`;" -text $trimStem trimStem; text -align "right" -label "Stem 4 for temp objects :"; textField -changeCommand "$groupStem = `textField -q -text groupStem`;" -text $groupStem groupStem; text -align "right" -label "Stem 5 for temp objects :"; textField -changeCommand "$planeStem = `textField -q -text planeStem`;" -text $planeStem planeStem; text -align "right" -label "Stem 6 for temp objects :"; textField -changeCommand "$shaderStem = `textField -q -text shaderStem`;" -text $shaderStem shaderStem; text -align "right" -label "Stem 7 for temp objects :"; textField -changeCommand "$windowStem = `textField -q -text windowStem`;" -text $windowStem windowStem; separator - style "in"; separator - style "in"; text -align "right" -label "Scale x :"; textField -changeCommand "$scale_x_base = `textField -q -text scale_x`; reset_label_parameter_arrays;" -text $scale_x_base scale_x; text -align "right" -label "Scale y :"; textField -changeCommand "$scale_y_base = `textField -q -text scale_y`; reset_label_parameter_arrays;" -text $scale_y_base scale_y; text -align "right" -label "Translate x :"; textField -changeCommand "$translate_x_base = `textField -q -text translate_x`; reset_label_parameter_arrays;" -text $translate_x_base translate_x; text -align "right" -label "Translate y :"; textField -changeCommand "$translate_y_base = `textField -q -text translate_y`; reset_label_parameter_arrays;" -text $translate_y_base translate_y; text -align "right" -label "Translate x offset :"; textField -changeCommand "$translate_x_offset = `textField -q -text translate_x_offset`; reset_label_parameter_arrays;" -text $translate_x_offset translate_x_offset; text -align "right" -label "Translate y offset :"; textField -changeCommand "$translate_y_offset = `textField -q -text translate_y_offset`; reset_label_parameter_arrays;" -text $translate_y_offset translate_y_offset; text -align "right" -label "Line spacing :"; textField -changeCommand "$line_spacing = `textField -q -text line_spacing`; reset_label_parameter_arrays;" -text $line_spacing line_spacing; text -align "right" -label "Rotate pivot x :"; textField -changeCommand "$rotate_pivot_x_base = `textField -q -text rotate_pivot_x`; reset_label_parameter_arrays;" -text $rotate_pivot_x_base rotate_pivot_x; text -align "right" -label "Rotate pivot y :"; textField -changeCommand "$rotate_pivot_y_base = `textField -q -text rotate_pivot_y`; reset_label_parameter_arrays;" -text $rotate_pivot_y_base rotate_pivot_y; text -align "right" -label "Rotate pivot z :"; textField -changeCommand "$rotate_pivot_z_base = `textField -q -text rotate_pivot_z`; reset_label_parameter_arrays;" -text $rotate_pivot_z_base rotate_pivot_z; text -align "right" -label "Rotate x :"; textField -changeCommand "$rotate_x_base = `textField -q -text rotate_x`; reset_label_parameter_arrays;" -text $rotate_x_base rotate_x; text -align "right" -label "Rotate y :"; textField -changeCommand "$rotate_y_base = `textField -q -text rotate_y`; reset_label_parameter_arrays;" -text $rotate_y_base rotate_y; text -align "right" -label "Rotate z :"; textField -changeCommand "$rotate_z_base = `textField -q -text rotate_z`; reset_label_parameter_arrays;" -text $rotate_z_base rotate_z; text -align "right" -height 50 -label "About :"; scrollField -enable false -width 200 -height 200 -numberOfLines 20 -insertionPosition 1 -wordWrap true -editable false -text "This tool will adjust up to three numerical attributes of the specified shader, the specified number of times. The currently selected view will be rendered on each iteration with the values of the three attributes shown in the rendered image."; } proc reset_label_parameter_arrays() { /* This fills the label parameter arrays using the label parameter base values. */ global float $scale_x_base; global float $scale_y_base; global float $translate_x_base; global float $translate_y_base; global float $translate_x_offset; global float $translate_y_offset; global float $line_spacing; global float $rotate_pivot_x_base; global float $rotate_pivot_y_base; global float $rotate_pivot_z_base; global float $rotate_x_base; global float $rotate_y_base; global float $rotate_z_base; global float $scale_x[]; global float $scale_y[]; global float $translate_x[]; global float $translate_y[]; global float $rotate_pivot_x[]; global float $rotate_pivot_y[]; global float $rotate_pivot_z[]; global float $rotate_x[]; global float $rotate_y[]; global float $rotate_z[]; $scale_x = {0.0, $scale_x_base, $scale_x_base, $scale_x_base }; $scale_y = {0.0, $scale_y_base, $scale_y_base, $scale_y_base }; $translate_x = {0.0, $translate_x_base + ($translate_x_offset - 0.5), $translate_x_base + ($translate_x_offset - 0.5), $translate_x_base + ($translate_x_offset - 0.5) }; $translate_y = {0.0, $translate_y_base + ($translate_y_offset - 0.12), ($translate_y_base + ($translate_y_offset - 0.12)) + $line_spacing, ($translate_y_base + ($translate_y_offset - 0.12)) + $line_spacing*2 }; $rotate_pivot_x = {0.0, $rotate_pivot_x_base, $rotate_pivot_x_base, $rotate_pivot_x_base }; $rotate_pivot_y = {0.0, -$translate_y[1], -$translate_y[2], -$translate_y[3] }; $rotate_pivot_z = {0.0, $rotate_pivot_z_base, $rotate_pivot_z_base, $rotate_pivot_z_base}; $rotate_x = {0.0, $rotate_x_base, $rotate_x_base, $rotate_x_base}; $rotate_y = {0.0, $rotate_y_base, $rotate_y_base, $rotate_y_base}; $rotate_z = {0.0, $rotate_z_base, $rotate_z_base, $rotate_z_base}; } proc do_render() { /* This is run when the Render button is clicked. */ global string $shaderGroup; global float $totalSteps; global int $deleteTempObjects; global string $attrName[]; global string $attrLabel[]; global float $attrStart[]; global float $attrIncrement[]; global int $iterate_attr[]; global string $file_path; global string $file_nameStem; global string $file_ext; global string $file_type; global int $file_padding; global string $planeStem; global string $shaderStem; global int $output_precision; float $new_value[]; string $the_shader_attr; string $file_path_and_name; int $i; int $j; int $k; int $n; string $n_formatted; int $temp_int; float $temp_float; $n = 1; print("\n\n_________________ Shader Attribute Cycler Output _________________\n\n"); if (catch(`listAttr $shaderStem`) ) { create_output_shader; } if (catch(`listAttr $planeStem`) ) { make_camera_orthogonal_plane; } for ($i = 1; $i <= $iterate_attr[1] + $iterate_attr[2] + $iterate_attr[3] ; $i++) { if ($iterate_attr[$i]) { $temp_float = round($attrIncrement[$i] * $totalSteps, $output_precision); print($attrName[$i] + " (" + $attrLabel[$i] + ") will go from " + round($attrStart[$i], $output_precision) + " to " + $temp_float + " in increments of " + round($attrIncrement[$i], $output_precision) + ".\n"); } } print("\n\n"); for ($k = 0; $k <= $totalSteps * $iterate_attr[3]; $k++) { if ( $iterate_attr[3] ) { $new_value[3] = $attrStart[3] + ($k * $attrIncrement[3]); $the_shader_attr = $shaderGroup + "." + $attrName[3]; setAttr $the_shader_attr $new_value[3]; } for ($j = 0; $j <= $totalSteps * $iterate_attr[2]; $j++) { if ( $iterate_attr[2] ) { $new_value[2] = $attrStart[2] + ($j * $attrIncrement[2]); $the_shader_attr = $shaderGroup + "." + $attrName[2]; setAttr $the_shader_attr $new_value[2]; } for ($i = 0; $i <= $totalSteps; $i++) { $new_value[1] = $attrStart[1] + ($i * $attrIncrement[1]); $the_shader_attr = $shaderGroup + "." + $attrName[1]; setAttr $the_shader_attr $new_value[1]; $temp_int = $n; print("iteration: " + $temp_int + " " + $attrLabel[1] + ": " + $i + " " + $attrLabel[2] + ": " + $j + " " + $attrLabel[3] + ": " + $k + " ( " + round($new_value[1], $output_precision) + " , " + round($new_value[2], $output_precision) + " , " + round($new_value[3], $output_precision) + " )\n"); draw_labels; scale_and_place_labels; render; $n_formatted = format_counter($n, $file_padding); $file_path_and_name = $file_path + $file_nameStem + "." + $n_formatted + $file_ext; renderWindowSaveImageCallback "renderView" $file_path_and_name $file_type; if ($n == pow(($totalSteps + 1), 3) ) { if ($deleteTempObjects) { clear_labels; select -r $shaderStem ; delete; select -r $planeStem; delete; } } else { clear_labels; } $n++; } } } } proc string format_counter(int $n, int $file_padding) { int $char_to_pad = 0; int $n_size = 0; string $return_value = ""; $n_size = size( (string) $n ); if ($file_padding >= $n_size) $chars_to_pad = $file_padding - $n_size; else $chars_to_pad = 0; for ($i = 1; $i <= $chars_to_pad; $i++) $return_value = $return_value + "0"; $return_value = $return_value + $n; return $return_value; } proc draw_labels() { global string $shaderGroup; global string $attrName[]; global string $attrLabel[]; global int $char_count[]; global string $the_output[]; global string $wordStem; global string $charStem; global string $trimStem; global int $output_precision; int $i; int $j; int $k; int $label_chars; string $the_shader_parameter; float $the_value; string $name_start; string $name_last; string $name_this; string $name_trim; string $pickwalk_names[]; $k = 0; for($j = 1; $j <= 3; $j++) { $name_start = $wordStem + $j; $the_shader_parameter = $shaderGroup + "." + $attrName[$j]; $the_value = `getAttr $the_shader_parameter`; $the_output[$j] = $attrLabel[$j] + ": " + round($the_value, $output_precision); textCurves -name $name_start -ch 0 -f "Arial-Regular" -t $the_output[$j]; $name_start = $name_start + "Shape"; $label_chars = size($the_output[$j]); $char_count[$j] = $label_chars; for ($i = 1; $i <= $label_chars; $i++) { $k++; $name_last = $name_this; $name_trim = $trimStem + $k; $name_this = $charStem + $k; if ($i == 1) { select $name_start; $pickwalk_names = pickWalk("-d", "down", $name_start); } else { select $name_last; $pickwalk_names = pickWalk("-d", "right"); } rename $pickwalk_names[0] $name_this; planarSrf -name $name_trim -ch 1 -tol 0.01 -o on -po 0 $name_this; } } }; proc clear_labels() { global string $wordStem; global string $trimStem; global string $groupStem; global int $char_count[]; int $i; for ($i = 1; $i <= 3; $i++) { $the_object = $wordStem + $i + "Shape"; select -r $the_object; delete; } for ($i = 1; $i <= $char_count[1] + $char_count[2] + $char_count[3]; $i++) { $the_object = $trimStem + $i; select -r $the_object; delete; } select -r $groupStem ; delete; } proc scale_and_place_labels() { global string $wordStem; global string $trimStem; global string $groupStem; global string $planeStem; global float $translate_x_offset; global float $translate_y_offset; global float $scale_x[]; global float $scale_y[]; global float $translate_x[]; global float $translate_y[]; global float $rotate_pivot_x[]; global float $rotate_pivot_y[]; global float $rotate_pivot_z[]; global float $rotate_x[]; global float $rotate_y[]; global float $rotate_z[]; global int $char_count[]; global string $outputShader; string $the_object; string $the_object_plus_attr; string $the_plane; string $the_plane_plus_attr; int $i; float $x; for ( $i = 1; $i <= 3; $i++) { $the_object = $wordStem + $i +"Shape"; $the_object_plus_attr = $the_object + ".scaleX"; setAttr $the_object_plus_attr $scale_x[$i]; $the_object_plus_attr = $the_object + ".scaleY"; setAttr $the_object_plus_attr $scale_y[$i]; $the_object_plus_attr = $the_object + ".translateY"; setAttr $the_object_plus_attr $translate_y[$i]; } for ($i = 1; $i <= $char_count[1] + $char_count[2] + $char_count[3]; $i++) { $the_object = $trimStem + $i; select -r $the_object; sets -e -forceElement $outputShader; } $the_object = $trimStem + 1; select -r $the_object; for ($i = 2; $i <= $char_count[1] + $char_count[2] + $char_count[3]; $i++) { $the_object = $trimStem + $i; select -add $the_object; } group -name $groupStem; xform -os -piv 0 0 0; $the_object = $groupStem; $the_plane = $planeStem; $the_object_plus_attr = $the_object + ".rotateX"; $the_plane_plus_attr = $the_plane + ".rotateX"; $x = `getAttr $the_plane_plus_attr`; setAttr $the_object_plus_attr $x; $the_object_plus_attr = $the_object + ".rotateY"; $the_plane_plus_attr = $the_plane + ".rotateY"; $x = `getAttr $the_plane_plus_attr`; setAttr $the_object_plus_attr $x; $the_object_plus_attr = $the_object + ".translateX"; $the_plane_plus_attr = $the_plane + ".translateX"; $x = `getAttr $the_plane_plus_attr` + $translate_x_offset - 0.5; setAttr $the_object_plus_attr $x; $the_object_plus_attr = $the_object + ".translateY"; $the_plane_plus_attr = $the_plane + ".translateY"; $x = `getAttr $the_plane_plus_attr` + $translate_y_offset - 0.5; setAttr $the_object_plus_attr $x; $the_object_plus_attr = $the_object + ".translateZ"; $the_plane_plus_attr = $the_plane + ".translateZ"; $x = `getAttr $the_plane_plus_attr`; setAttr $the_object_plus_attr $x; } proc string lookup_image_format(int $the_format_code) { string $return_value; int $return_chars = 0; string $image_types[] = { "GIF", "SI", "RLA", "Tiff", "Tiff16", "SGI", "Alias", "IFF", "JPEG", "EPS", "IFF16", "Cineon", "Quantel", "SGI16", "???", "???", "???", "???", "???","TARGA", "BMP", "SGIMV", "QT", "AVI", "???", "???", "???", "???", "???", "???", "MACPAINT", "PHOTOSHOP", "PNG", "QUICKDRAW", "QTIMAGE", "DDS", "DDS", "???", "???", "???", "???", "???", "???", "???", "???", "???", "???", "???", "???", "???", "IMFplugin", "Custom", "???", "???", "???", "???", "???", "???", "???", "???", "SWF", "AI", "SVG", "SWFT" }; $return_value = $image_types[$the_format_code]; $return_chars = size($return_value); if ($return_chars == 0) $return_value = "???"; return($return_value); } proc int power(int $base, int $exponent) { int $return_value; if ($exponent == 0) { $return_value = 1; } else { $return_value = $base; for($i = 2; $i <= $exponent; $i++) { $return_value = $return_value * $base; } } return $return_value; } proc float round(float $roundee, int $precision) { float $return_value; $return_value = $roundee * pow(10, $precision); $return_value = floor($return_value + 0.5); $return_value = $return_value / pow(10, $precision); return $return_value; } proc create_output_shader() { global string $shaderStem; string $shaderSG; string $shaderSG_surface; string $shader_color; shadingNode -asShader -name $shaderStem surfaceShader; $shaderSG = $shaderStem + "SG"; $shaderSG_surface = $shaderSG + ".surfaceShader"; $shader_color = $shaderStem + ".outColor"; sets -renderable true -noSurfaceShader true -empty -name $shaderSG; connectAttr -f $shader_color $shaderSG_surface; setAttr $shader_color -type double3 0 0 1 ; } proc make_camera_orthogonal_plane() { global vector $camera_position; global vector $camera_wci; global float $camera_rotatePivot[]; global float $camera_rotate[]; global float $units_from_camera = 1; global string $planeStem; global string $shaderStem; global string $windowStem; vector $camera_position_excl_wci; vector $camera_position_scaled; float $magnitude_cam_pos_excl_wci; vector $orthogonal_plane_pos_excl_wci; float $trans_x; float $trans_y; float $trans_z; string $plane_translate; int $my_debug = 0; $camera_rotatePivot[1] = `getAttr persp.rotatePivotX`; $camera_rotatePivot[2] = `getAttr persp.rotatePivotY`; $camera_rotatePivot[3] = `getAttr persp.rotatePivotZ`; $camera_rotate[1] = `getAttr persp.rotateX`; $camera_rotate[2] = `getAttr persp.rotateY`; $camera_rotate[3] = `getAttr persp.rotateZ`; $camera_wci = `camera -q -worldCenterOfInterest "persp"`; $camera_position = `camera -q -position "persp"`; if ($my_debug) { print "\n\n"; } $camera_position_excl_wci = $camera_position - $camera_wci; if ($my_debug) { print("new camera position (temp1)\nx: " + $camera_position_excl_wci.x + "\ny: " + $camera_position_excl_wci.y + "\nz: " + $camera_position_excl_wci.z); print"\n\n"; } $magnitude_cam_pos_excl_wci = mag($camera_position_excl_wci); if ($my_debug) { print("mag (magnitude_cam_pos_excl_wci) new camera position (camera_position_excl_wci)\n" + $magnitude_cam_pos_excl_wci + "\n\n"); } $camera_position_scaled = <<$camera_position_excl_wci.x/$magnitude_cam_pos_excl_wci, $camera_position_excl_wci.y/$magnitude_cam_pos_excl_wci, $camera_position_excl_wci.z/$magnitude_cam_pos_excl_wci>>; if ($my_debug) { print("new camera position (camera_position_excl_wci) scaled to unit sphere\ndivisor: " + $magnitude_cam_pos_excl_wci + "\nx: " + $camera_position_scaled.x + "\ny: " + $camera_position_scaled.y + "\nz: " + $camera_position_scaled.z + "\n\n"); } nurbsPlane -ch off -o on -p $camera_rotatePivot[1] $camera_rotatePivot[2] $camera_rotatePivot[3] -po 0 -ax 0 0 1 -w 1 -lr 1 -u 1 -v 1 -name $planeStem ; rotate -r -os $camera_rotate[1] $camera_rotate[2] 0; $orthogonal_plane_pos_excl_wci = $camera_position_scaled * ($magnitude_cam_pos_excl_wci - $units_from_camera); $trans_x = $orthogonal_plane_pos_excl_wci.x + $camera_wci.x; $trans_y = $orthogonal_plane_pos_excl_wci.y + $camera_wci.y; $trans_z = $orthogonal_plane_pos_excl_wci.z + $camera_wci.z; $plane_translate = $planeStem + ".translate"; setAttr $plane_translate $trans_x $trans_y $trans_z; HideSelectedObjects; } /* ----------------------------------------------- */ if (`window -exists $windowStem` ) deleteUI $windowStem; if (catch(`listAttr $planeStem`)) { print("Creating " + $planeStem + ".\n"); make_camera_orthogonal_plane; } if (catch(`listAttr $shaderStem`)) { print("Creating " + $shaderStem + ".\n"); create_output_shader; } prepare_tool_window; showWindow $windowStem;