-- MatchLightToView 1.0 - (c) 2001 M. Breidt (martin@breidt.net) -- -- Works like the built-in "Match Camera to View" command (Ctrl-C) but with -- lights: select any non-omni light, activate a perspective viewport and -- invoke the script. This will match the light to the active viewport. -- -- Run this script and assign a keyboard shortcut to "Match Light to View" -- MacroScript MatchLightToView category:"MB Tools" tooltip:"Match Light to View" ( on isEnabled return ( if ((getCurrentSelection()).count == 1) and ($ != undefined) then if (superClassOf $ == light) and (classOf $ != Omnilight) then true else false ) on execute do ( if gw.IsPerspView() then ( lt = $ viewTM = inverse(getViewTM()) fov = getViewFOV() lt.transform = viewTM lt.falloff = 2 * atan(tan(fov/2)/sqrt(GetRendImageAspect())) if (classOf lt == targetSpot) or (classOf lt == targetDirect) then ( in coordsys viewTM (lt.target.pos = [0,0, -gw.getFocalDist()]) ) ) ) )