// =========================================================================== // 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. // =========================================================================== // // // // // Description: // Changes the normal of the selected light points based on the value // in the Light Point Normal editor. // global proc fltLPChangeNormal() { float $normal[3]; if(`about -mac`){ $normal = `floatFieldGrp -q -value OF_LPNEditor|OF_LPNEditor|Attributes|Normal`; }else{ $normal = `floatFieldGrp -q -value OF_LPNEditor|Attributes|Normal`; } fltLightPoints -e -nml $normal[0] $normal[1] $normal[2]; } // // Description: // Updates the normal displayed in the Light Point Normal Editor to // reflect the latest selection. // global proc fltUpdateNormal() { // Update the ordered selection list fltSelectInOrder; global string $selectedLPs[]; string $lpQuery[] = `fltLightPoints -q -nml`; float $lpNormals[3]; int $i; if ( !`window -exists OF_LPNEditor` ) { return; } for ( $i = 0 ; $i < size($lpQuery) ; $i += 5 ) { if ( $lpQuery[$i] == $selectedLPs[0] && $lpQuery[$i+1] == $selectedLPs[1] ) { $lpNormals[0] = $lpQuery[$i + 2]; $lpNormals[1] = $lpQuery[$i + 3]; $lpNormals[2] = $lpQuery[$i + 4]; if(`about -mac`){ floatFieldGrp -e -value $lpNormals[0] $lpNormals[1] $lpNormals[2] 0 OF_LPNEditor|OF_LPNEditor|Attributes|Normal; }else{ floatFieldGrp -e -value $lpNormals[0] $lpNormals[1] $lpNormals[2] 0 OF_LPNEditor|Attributes|Normal; } } } } // // Description: // Kills the script job used to keep the Light Point Normal Editor // up to date when it is no longer needed. // global proc fltNormalJobCleanup() { global int $fltNormalJobNum; if ( $fltNormalJobNum != -1 ) { scriptJob -kill $fltNormalJobNum -force; $fltNormalJobNum = -1; } } // // Description: // Brings up the Light Point Normal Editor. // global proc fltLightPointNormalEditor() { if ( `window -exists OF_LPNEditor` ) { return; } window -title (uiRes("m_fltLightPointNormalEditor.kLightPointNormalEditor")) -menuBar true OF_LPNEditor; formLayout Attributes; floatFieldGrp -label (uiRes("m_fltLightPointNormalEditor.kNormal")) -numberOfFields 3 -value 0 0 1 0 Normal; button -label (uiRes("m_fltLightPointNormalEditor.kApplyAndClose")) -command "fltLPChangeNormal; deleteUI OF_LPNEditor;" ApplyAndClose; button -label (uiRes("m_fltLightPointNormalEditor.kApply")) -command "fltLPChangeNormal" Apply; button -label (uiRes("m_fltLightPointNormalEditor.kClose")) -command "deleteUI OF_LPNEditor" Close; formLayout -e -attachForm Normal "top" 5 -attachForm Normal "left" 5 -attachForm Normal "right" 5 -attachForm ApplyAndClose "bottom" 5 -attachForm ApplyAndClose "left" 5 -attachPosition ApplyAndClose "right" 5 33 -attachForm Apply "bottom" 5 -attachControl Apply "left" 5 ApplyAndClose -attachPosition Apply "right" 5 66 -attachForm Close "bottom" 5 -attachControl Close "left" 5 Apply -attachForm Close "right" 5 Attributes; global int $fltNormalJobNum = -1; if ( $fltNormalJobNum == -1 ) { $fltNormalJobNum = `scriptJob -e SelectionChanged fltUpdateNormal`; } scriptJob -runOnce true -uiDeleted OF_LPNEditor fltNormalJobCleanup; fltUpdateNormal; showWindow OF_LPNEditor; }