home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2002 April / GSSH42002.iso / EDITOREN / DS / gmax / gmaxinst_1-1.exe / gmaxsetup11.cab / Macro_LightInclude.mcr < prev    next >
Text File  |  2002-02-13  |  6KB  |  232 lines

  1. -- MacroScript File
  2. -- Created:  Jan 10 1999
  3. -- Modified: Feb 15 1999
  4. -- Author:   Fred Ruff
  5. -- Modified: Frank DeLise May 24 1999
  6. -- Modified: Yann Bertaud January 25, 2001 
  7. -- Added support for mental ray area lights
  8. -- MacroScript for Light Include/Exclude
  9. --***********************************************************************************************
  10. -- MODIFY THIS AT YOUR OWN RISK
  11. -- This utility will allow you to quickly Include or Exclude 
  12. -- a selection set into a light.
  13.  
  14. Global floatlt = undefined 
  15.  
  16. MacroScript Light_Include 
  17. category:"Lights and Cameras" 
  18. internalcategory:"Lights and Cameras" 
  19. tooltip:"Light Include/Exclude Tool"
  20. buttontext:"Light Include/Exclude"
  21. icon:#("Lights",6)
  22. (
  23.     Rollout Incl "Includes / Exludes"
  24.     (
  25.     local curlight
  26.     local ex_names = #()
  27.     local inc_names = #()
  28.     local foo = #()
  29.         
  30.         
  31.     group "Geometry"
  32.     (
  33.         Radiobuttons inc_ex labels:#("Include","Exclude") 
  34.         pickbutton AssignToLight "Assign to Light"
  35.     )
  36.     Group "List Light Properties"
  37.     (
  38.         label l1 "Current displayed light:" across:2
  39.         label sellight "none"
  40.         pickbutton ViewLightExInc "Choose Light" across:2
  41.         button clr "Clear Light" enabled:false
  42.         Radiobuttons ltinex labels:#("Include","Exclude") enabled:false
  43.         listbox lst "Objects" items:#() enabled:false
  44.     )
  45.         Button help "Help"
  46.     
  47.     on help pressed do messagebox "Light Include/Exclude\nThis utility allows you to assign objects to lights in the viewport,\nrather than by choosing a light and selecting an object from a list.\n\n Example:\n 1) Select some geometry.\n 2) Choose Include or Exclude.\n 3) Click the \"Assign to Light\" button.\n 4) Then click the light you want.\n\nThose objects are now Included or Excluded from that light.\n\nLight Properties:\nInside Light properties, you can see the Include/Exclude list\nof any light in the scene. When assigning geometry to a light,\nit displayes that light's list in the listbox.\n\nChoose Light:\nWill allow you to pick another light to view it's include list.\nClear Light:\nWill clear the currently selected light's include list." beep:false
  48.     on AssignToLight picked obj do
  49.     (
  50.         NA =0
  51.         
  52.         objectname = obj.name
  53.         if ((classof obj) == miarealight) or ((classof obj) == miarealightomni) do
  54.         (
  55.             obj = getproperty obj (getpropnames obj)[(getpropnames obj).count]
  56.         )
  57.         curlight = obj
  58.         --     CHECK FOR ANY LIGHTS IN SELECTIOIN OF GEOMETRY
  59.         temp = selection as array
  60.         for i = 1 to temp.count do
  61.         (
  62.             temp2 = temp[i]
  63.             if iskindof temp2 light == true then  NA =1
  64.         )
  65.         If NA != 1 then 
  66.         (
  67.             if iskindof obj light == true then
  68.             (
  69.                 clr.enabled = true
  70.                 foo = selection as array
  71.                 if inc_ex.state == 1 then 
  72.                 (
  73.                     if curlight.includelist != undefined then join foo curlight.includelist
  74.                     curlight.includelist = foo 
  75.                 )
  76.                 else 
  77.                 (
  78.                     if curlight.excludelist != undefined then join foo curlight.excludelist
  79.                     curlight.excludelist = foo
  80.                 )
  81.                 -- PUT INCLUDE LIST INTO LIST BOX
  82.                 if inc_ex.state == 1 then
  83.                 (
  84.                     if obj.includelist.count > 1 then -- PUT INCLUDE LIST INTO LIST BOX
  85.                     (
  86.                         temp =#()
  87.                         for i = 1 to obj.includelist.count do
  88.                         (
  89.                             temp[i] = obj.includelist[i].name
  90.                         )
  91.                         lst.items = temp
  92.                         ltinex.state = 1
  93.                         ltinex.enabled = true
  94.                         lst.enabled = true
  95.                     )
  96.                     else -- IF OBJECT IS SINGLE DO THIS 
  97.                     (
  98.                         if obj.includelist[1] != undefined then
  99.                         (
  100.                             print obj.includelist[1].name
  101.                             lst.items = #(obj.includelist[1].name)
  102.                             ltinex.state = 1
  103.                             ltinex.enabled = true
  104.                             lst.enabled = true
  105.                         )
  106.                         else messagebox "Please select Geometry!"
  107.                     )
  108.                 )
  109.                 Else -- PUT EXCLUSUION LIST INTO LIST BOX
  110.                 (
  111.                 if obj.excludelist.count > 1 then
  112.                     (
  113.                         temp =#()
  114.                         for i = 1 to obj.excludelist.count do
  115.                         (
  116.                             temp[i] = obj.excludelist[i].name
  117.                         )
  118.                         lst.items = temp
  119.                         ltinex.state = 2
  120.                         ltinex.enabled = true
  121.                         lst.enabled = true
  122.                     )
  123.                     else
  124.                     (
  125.                         lst.items = #(obj.excludelist[1].name)
  126.                         ltinex.state = 2
  127.                         ltinex.enabled = true
  128.                         lst.enabled = true
  129.                     )
  130.                 )
  131.                 sellight.text = objectname
  132.             )
  133.             else messagebox "Please pick a Light!"
  134.         )    
  135.         Else messagebox "Please pick geometry first, then choose a light to assign it to."
  136.     )
  137.     On ltinex changed state do
  138.     (
  139.         if ltinex.state == 1 then 
  140.         (
  141.             --     SWITCH EXCLUDE TO INCLUDE
  142.             curlight.includelist = curlight.excludelist
  143.         )
  144.         else 
  145.         (
  146.             -- SWITCH INCLUDE TO EXCLUDE
  147.             curlight.excludelist =     curlight.includelist
  148.         )
  149.     )
  150.     On clr pressed do
  151.     (
  152.         curlight.excludelist = #()
  153.         curlight.includelist = #()
  154.         ex_names = #()
  155.         inc_names = #()
  156.         ex_list = curlight.excludelist 
  157.         if curlight.excludelist != undefined then for i=1 to ex_list.count do
  158.         (
  159.             ex_names[i] = ex_list[i].name
  160.         )
  161.         lst.items = ex_names
  162.                 
  163.         inc_list = curlight.includelist 
  164.         if curlight.includelist != undefined then for i=1 to inc_list.count do
  165.         (
  166.             inc_names[i] = inc_list[i].name
  167.         )
  168.         lst.items = inc_names
  169.     )    
  170.         
  171.     on ViewLightExInc picked obj do
  172.     (
  173.         if iskindof obj light == true then
  174.         (
  175.             sellight.text = obj.name
  176.             if ((classof obj) == miarealight) or ((classof obj) == miarealightomni) then
  177.             (
  178.                 obj = getproperty obj (getpropnames obj)[(getpropnames obj).count]
  179.             )
  180.             curlight = obj
  181.             clr.enabled = true
  182.             ex_names = #()
  183.             inc_names = #()
  184.             ex_list = obj.excludelist 
  185.             inc_list = obj.includelist 
  186.             -- IF EXCLUDE LIST EXISTS DO THESE LINES
  187.             if obj.excludelist != undefined then 
  188.             (
  189.                 for i=1 to ex_list.count do
  190.                 (
  191.                     ex_names[i] = ex_list[i].name
  192.                 )
  193.                 lst.items = ex_names
  194.                 print lst.items
  195.                 ltinex.state = 2
  196.                 ltinex.enabled = true
  197.                 lst.enabled = true
  198.             )
  199.             
  200.             Else if obj.includelist != undefined then 
  201.             (
  202.                 for i=1 to inc_list.count do
  203.                 (
  204.                     inc_names[i] = inc_list[i].name
  205.                 )
  206.                         
  207.                 lst.items = inc_names
  208.                 ltinex.state = 1
  209.                 ltinex.enabled = true
  210.                 lst.enabled = true
  211.             )
  212.         )
  213.         else messagebox "Please pick a light"
  214.             
  215.     )
  216. )
  217.             
  218.         
  219. if floatLt != undefined then
  220.                                 (
  221.                                 closerolloutfloater floatLt
  222.                                 floatlt = undefined
  223.                                 )
  224.  
  225. floatLt = newRolloutFloater "Light Incl/Exl" 250 410 10 170
  226. addRollout Incl floatLt                                    
  227.  
  228.  
  229. )    
  230.  
  231.  
  232.