home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 April / maximum-cd-2002-04.iso / Software / Apps / gmax / gmaxinst.exe / gmaxsetup11.cab / gMaterialED.ms < prev    next >
Encoding:
Text File  |  2001-09-12  |  55.2 KB  |  1,701 lines

  1.  /* gMaterialED.ms - gmax scripted material editor */
  2.  
  3. -- lam 8/28/01 - moved vUIParamChange = false into fUpdatePropertyDisplay. Callback is delayed until scene redraw, so this flag
  4. --               was always being set to false before the callback was performed. 
  5. -- mjy 8/06/01 - incorporated UI for 2-sided mtls. additional layout tweaks.
  6. -- lam 7/27/01 - turning off all callbacks if createDialog fails
  7.  
  8. -- orb 07-26-01 implemented show map in vieport functionality.
  9. -- added the following functions
  10. --  fGetMapSMIVState, fGetMaterialSMIVState
  11. -- finished the implementations of the following
  12. --  fShowMap, fShowMaterial, fUpdateTools, fUpdatePanel
  13. -- Mod on 7/25/01 by L. Minton: 
  14. -- Added vUIParamChange flag which is set to true before the UI changes a material parameter. This flag is tested
  15. --   in the callback function before updated the UI.
  16.  
  17. -- *** orb 07-24-01
  18. -- NOTE: not checking in the full implementation of fSetCurrentMaterial.
  19. -- This means that 302114, 302099, 302040 WILL NOT BE FIXED as described immediately
  20. -- following this note.  The fSetCurrentMaterial implementation slows down the editor
  21. -- too much, so I'm leaving this out 
  22. -- Fixes on 7/23/2001 by Mark Young:
  23. -- Defects 302114, 302099, 302040 - Added function fSetCurrentMaterial
  24. --   which is now called when vMaterialCurrent is reassigned. Besides
  25. --   setting vMaterialCurrent, the function sets a change handler for
  26. --   the current material to update the GUI when property edits are undone.
  27. -- Defect 302552 - Modified function fUpdateMaterials and added change handler
  28. --   for sceneMaterials. This also supports undo for "new", "copy" and "delete".
  29. -- Defect 301646 - Modified function fDeleteMaterial to handle multimaterials.
  30. -- Defect 302121 - Changed tooltip and title for SelectByName dialog to
  31. --   "Select from Objects with Material ..." to better reflect functionality.
  32. -- Defect 302870 - Modified function fGetMaterial to copy multimaterials.
  33. -- Defect 302860 - Modified function fApplyMaterial to apply multimaterials.
  34. -- Unlogged bug - Fixed a new bug in function fGetSelectedMaterial
  35. --   that blocked "get" for subobject selections.
  36.  
  37. -- orb 07-24-01 removed fChangeMaterials because it isn't needed, 
  38. -- changed "when subAnimStructure sceneMaterials" callback to call fResetGUI
  39.  
  40.  
  41. -- Modifications on 7/16/01 by L. Minton for removal of as many 'return's as possible, and some speed tweaks.
  42. -- Fixed known issue 2 - messagebox is run from listener thread, and the 2nd 'on enter' event was executing while the 
  43. --   messagebox from the first 'on enter' was up and blocking execution of the remainder of the handler. Moved the line
  44. --   field.text = material.name from after the messagebox call to before.
  45. -- Known issue 3 should not exist any more. Fixed earlier via defect 298613
  46. -- Known issue 4c (enabled property) fixed via defect 302171
  47. -- Defect 301368 (tab out of Name edittext and then change focus throws error) fixed. The tab was setting focus to the next
  48. --   ui item, which is the vEditMultiMaterial edittext. Changing focus then caused the 'on entered' handler to be called on that. But
  49. --   this wasn't being handled properly in the conditional at the top of fEditMaterial.
  50. -- Known issues 4a and 4b not reproducible here. Tried moving the 2 edittext fields to the bottom if the ui item definitions, no problems.
  51. --   Could have been related to problem fixed in defect 298613.
  52. -- Handler exception on Escape in edittext field fixed via defect 298264
  53. -- Handler exception on Escape when creating object fixed via defect 298264
  54. -- Random crashes after appending or deleting from sceneMaterials fix via defect 298231
  55. -- Fixed set of <array>.count via defect 302167. This can be used for "pre-allocating" arrays. See fUpdateMaterials, fUpdateSubMaterials.
  56.  
  57. /* Known Issues: */
  58. /* 1. FIXED: "Show Material/Map" toggle buttons currently have no effect. */
  59. /*    Functionality will require MAXScript exposure of the ability */
  60. /*    to read the state controlled by "showTextureMap ..." */
  61. /* 2. FIXED: Displays error messages (modal dialog) twice when invalid */
  62. /*    (i.e., blank or duplicate) material names are entered */
  63. /*    - apparently due to a MAXScript bug with "enter" events */
  64. /*    for EditText UI controls. */
  65. /* 3. FIXED: All application windows occassionally blink when materials are */
  66. /*    unloaded/loaded - apparently due to a MAXScript bug/unsupported-feature */
  67. /*    where some UI controls make the whole app redraw when their position */
  68. /*    properties are changed (DropDownList is the culprit in this script). */
  69. /* 4. FIXED: There are a couple of problems that workarounds currently avoid: */
  70. /*       - EditText control must be defined first for proper interaction */
  71. /*       - EditText control must be defined without specifying */
  72. /*         a height property for proper interaction */
  73. /*       - Controls that may be disabled need to be moved offscreen (by */
  74. /*         setting position property) and then moved back onscreen in order */
  75. /*         for the disabled state's color/font to be properly rendered */
  76.  
  77. try callbacks.removeScripts id:#gMaterialED
  78. catch ()
  79. if vMaterialED != undefined do
  80. (    try unRegisterTimeCallback vMaterialED.fUpdatePropertyDisplay
  81.     catch ()
  82.     try DestroyDialog vMaterialED
  83.     catch ()
  84. )
  85. try deleteAllChangeHandlers id:#gMaterialEdTransient
  86. catch ()
  87. try deleteAllChangeHandlers id:#gMaterialEdPersistent
  88. catch ()
  89.  
  90. /* vMaterialED.fSetMaterial uses the following global variable to support */
  91. /* external calls when vMaterialED is not open (i.e., defined, but not instanced). */
  92. /* This specifies the material, parent multimaterial and tab */
  93. /* to be loaded when vMaterialED subsequently opens. */
  94. vMaterialED_SetMaterial = #(undefined,undefined,undefined)
  95.  
  96. -- orb 07-23-01 defect 298557
  97. -- This global is indicates whether or not Flash 5 activeXcontrols loaded
  98. -- successfully.  See the fOpen() implementation
  99. vMaterialED_Flash5Installed = 1
  100.  
  101.  
  102. -- orb 08-20-2001 fixing defect 306451
  103. vMaterialED_Position = [300, 200]
  104.  
  105.  
  106. rollout vMaterialEd "gmax Material Editor" width:351 height:410
  107. (
  108.     -- orb -8-20-2001 Fixing Tab order
  109.     -- Please maintain the order for everything between the --******* symbols...
  110.     --******* please maintain order so tab order is preserved - BEGIN ******
  111.     label vLabelMaterials " Scene Materials" pos:[8,4] width:42 height:26
  112.     dropDownList vListMaterials "" pos:[54,10] width:258 height:21
  113.     button vButtonGet "get" pos:[8,39] width:32 height:24 toolTip:"Get material from selected object"
  114.     button vButtonNew "new" pos:[47,39] width:32 height:24 toolTip:"Create new material"
  115.     button vButtonCopy "copy" pos:[86,39] width:32 height:24 toolTip:"Create new material with current properties"
  116.     button vButtonApply "apply" pos:[125,39] width:32 height:24 toolTip:"Apply material to selected object(s)"
  117.     button vButtonDelete "delete" pos:[195,39] width:32 height:24 toolTip:"Delete material from scene"
  118.     
  119.     editText vEditMultiMaterial "Multi-Material " pos:[10,73] width:301
  120.     dropDownList vListSubMaterials "" pos:[79,91] width:233 height:21
  121.     editText vEditName "Name " pos:[44,119] width:267
  122.     label vLabelOptions "Option" pos:[41,145] width:50 height:13
  123.     checkBox vCheckboxTwoSided "2-sided" pos:[83,145] width:60 height:16
  124.     --******* please maintain order so tab order is preserved - END ******
  125.  
  126.  
  127.     -- orb 07-23-01 defect 298557
  128.     -- load the Flash 5 control, so we can give an appropriate error message
  129.     --
  130.     activeXControl vFlashTabs "ShockwaveFlash.ShockwaveFlash.5" pos:[7,187] width:120 height:211
  131.     activeXControl vFlashTop "ShockwaveFlash.ShockwaveFlash.5" pos:[126,167] width:218 height:20
  132.     activeXControl vFlashBottom "ShockwaveFlash.ShockwaveFlash.5" pos:[126,398] width:218 height:18
  133.     activeXControl vFlashRight "ShockwaveFlash.ShockwaveFlash.5" pos:[331,187] width:18 height:211
  134.  
  135.  
  136.     colorPicker vColor "Color" pos:[146,216] width:65 height:20 color:(color 197 197 197) modal:false
  137.     checkbox vCheckboxMap "on" pos:[143,304] width:39 height:16
  138.     bitmap vImageMap "" pos:[226,257] width:100 height:100
  139.     spinner vSpinnerMap "Amount" pos:[170,339] width:52 height:16 range:[0,100,100] type:#integer scale:1
  140.     button vButtonMapOpen "open" pos:[142,257] width:24 height:24 toolTip:"Assign texture - pick map file"
  141.     button vButtonMapClear "clear" pos:[170,257] width:24 height:24 toolTip:"Clear map"
  142.     groupBox vGroupMap "Map" pos:[138,241] width:193 height:120
  143.     checkbox vCheckboxMatchDiffuse "match Diffuse Color/Map" pos:[152,193] width:136 height:18
  144.     activeXControl vFlashArrow "ShockwaveFlash.ShockwaveFlash.1" pos:[127,192] width:25 height:18
  145.     label vLabelComponents "Components" pos:[13,170] width:60 height:13
  146.  
  147.     checkButton vButtonMaterialShow "show" pos:[320,140] width:24 height:24 toolTip:"Show material's maps in viewport"
  148.     checkButton vButtonMapShow "show" pos:[198,257] width:24 height:24 toolTip:"Show map in viewport"
  149.     button vButtonNavigator "nav" pos:[320,8] width:24 height:24 toolTip:"gmax Material Navigator"
  150.     label vLabelSubMaterials "Sub-Material" pos:[13,94] width:60 height:13
  151.     button vButtonSelect "select" pos:[320,39] width:24 height:24 toolTip:"Select from object(s) with material"
  152.  
  153.  
  154.     activeXControl vFlashHighlight "ShockwaveFlash.ShockwaveFlash.1" pos:[236,224] width:95 height:85
  155.     spinner vSpinnerSpecularLevel "Level " pos:[179,232] width:50 height:16 range:[0,999,0] type:#integer scale:1
  156.     spinner vSpinnerGlossiness "Glossiness " pos:[172,258] width:57 height:16 range:[0,100,10] type:#integer scale:1
  157.     spinner vSpinnerSoften "Soften " pos:[177,284] width:52 height:16 range:[0,1,0.1] type:#float scale:0.1
  158.  
  159.     colorPicker vColorSelfIllum "" pos:[202,220] width:48 height:18 color:(color 0 0 155) modal:false
  160.     spinner vSpinnerSelfIllum "" pos:[205,200] width:45 height:16 range:[0,100,0] type:#integer scale:1
  161.     checkbox vCheckboxSelfIllumAmount "Amount" pos:[147,200] width:56 height:16
  162.     checkbox vCheckboxSelfIllumColor "Color" pos:[147,221] width:47 height:16
  163.  
  164.     spinner vSpinnerOpacity "Amount " pos:[179,218] width:52 height:16 range:[0,100,100] type:#integer scale:1
  165.  
  166.     -- russom - 08/27/01 - 308413
  167.     -- Can't assume getdir #ui returns <root>/ui
  168.     -- removed getDir #ui references
  169.     local vFlashPath = (getDir #maxroot) + "\\UI\\Flash\\gMaterialED-"
  170.     local vIconPath = (getDir #maxroot) + "\\UI\\Icons\\gMaterialED"
  171.     local vMovieTabs = "tabs"
  172.     local vMovieTop = "top"
  173.     local vMovieBottom = "bottom"
  174.     local vMovieRight = "right"
  175.     local vMovieArrow = "arrow"
  176.     local vMovieHighlight = "highlight"
  177.     local vIconCount = 9
  178.     local vIconsNavigator = #(1,1)
  179.     local vIconsOpen = #(2,2)
  180.     local vIconsShow = #(2,4)
  181.     local vIconsDelete = #(2,6)
  182.     local vIconsSelect = #(2,8)
  183.  
  184.     local vOffsetInvisible = 500
  185.  
  186.     local vDimTabs = 0.80
  187.     local vDimDisabled = 0.20
  188.  
  189.     local vTabDiffuse = "Diffuse"
  190.     local vTabAmbient = "Ambient"
  191.     local vTabHighlight = "Highlight"
  192.     local vTabSpecularColor = "Color"
  193.     local vTabSpecularLevel = "Level"
  194.     local vTabGlossiness = "Glossiness"
  195.     local vTabSelfIllum = "Self-Illumination"
  196.     local vTabOpacity = "Opacity"
  197.     local vTabBump = "Bump"
  198.  
  199.     local vSymbolDiffuse = vTabDiffuse
  200.     local vSymbolAmbient = vTabAmbient
  201.     local vSymbolHighlight = vTabHighlight
  202.     local vSymbolSpecularColor = "Specular"
  203.     local vSymbolSpecularLevel = "SpecularLevel"
  204.     local vSymbolGlossiness = vTabGlossiness
  205.     local vSymbolSelfIllum = "SelfIllum"
  206.     local vSymbolOpacity = vTabOpacity
  207.     local vSymbolBump = vTabBump
  208.  
  209.     local vOffsetMaterialID = 0
  210.  
  211.     local vFlagVisible = false
  212.     local vTabCurrent = undefined
  213.     local vMaterialCurrent = undefined
  214.     local vMultiMaterial = undefined
  215.     local vMaterialUndefined = standardMaterial name:"undefined"
  216.     local vImageBuffer = bitmap 100 100 /* note: must be same size as vImageMap */
  217.     local vMapUndefined, vColorText, vColorBackground, vColorViewport
  218.     local vTabPrevious = undefined
  219.     local vCountMaterials = 0
  220.     local vUIParamChange = false -- flag for signaling material param change was due to UI action
  221.  
  222.     /* "fTabSymbol" converts a string from Flash tab's label or Mtl/Map Nav */
  223.     /* channel spec to string used by this script as an ID for a tab when */
  224.     /* it sends messages to Flash. The labels (which are also used as IDs) */
  225.     /* contain spaces and the tab IDs returned by "fTabSymbol" are used to */
  226.     /* form the prefix of names variables in Flash that this script will */
  227.     /* assign values to in order to control the tabs' Flash display. */
  228.     function fTabSymbol label =
  229.     (
  230.         local suffix = " Color"
  231.         case label of (
  232.             vTabDiffuse: vSymbolDiffuse
  233.             (vTabDiffuse+suffix): vSymbolDiffuse
  234.             vTabAmbient: vSymbolAmbient
  235.             (vTabAmbient+suffix): vSymbolAmbient
  236.             vTabHighlight: vSymbolHighlight
  237.             vTabSpecularColor: vSymbolSpecularColor        
  238.             vTabSpecularLevel: vSymbolSpecularLevel
  239.             vTabGlossiness: vSymbolGlossiness
  240.             vTabSelfIllum: vSymbolSelfIllum
  241.             vTabOpacity: vSymbolOpacity
  242.             vTabBump: vSymbolBump
  243.             default: undefined
  244.         )
  245.     )
  246.  
  247.     /* convert color to Flash's color values */
  248.     function fFlashColor rgb =
  249.     (
  250.         local x = rgb as color
  251.         local i = ((x.red as integer) * 256 + (x.green as integer)) * 256 + (x.blue as integer)
  252.         (i as string)
  253.     )
  254.  
  255.     function fEnableFlash item enabled =
  256.     (
  257.         if (item == vFlashHighlight) then (
  258.             item.SetVariable "vEnabled" (enabled as string)
  259.         ) else if (item == vFlashTabs and not enabled) then (
  260.             local c = vColorBackground * (1.0 + vDimTabs) / 2
  261.             item.SetVariable "colorText" (fFlashColor c)
  262.         ) else (
  263.             local c = vColorText
  264.             if (not enabled) do
  265.                 c = vColorBackground + (c - vColorBackground) * vDimDisabled
  266.             item.SetVariable "colorText" (fFlashColor c)
  267.         )
  268.         item.TCallLabel "/" "fUpdate"
  269.     )
  270.  
  271.     function fEnable item enabled =
  272.     (
  273.         if ((classof item) == activeXControl) then 
  274.             fEnableFlash item enabled
  275.         else
  276.             item.enabled = enabled
  277.     )
  278.  
  279.     function fSetPosition item visible enabled =
  280.     (
  281.         if (visible and item.pos.y > vOffsetInvisible) then
  282.             item.pos.y = item.pos.y - vOffsetInvisible
  283.         else if (not visible and item.pos.y < vOffsetInvisible) do
  284.             item.pos.y = item.pos.y + vOffsetInvisible
  285.         if (visible) do fEnable item enabled
  286.     )
  287.  
  288.     function fSetPositionMap visible enabled mapDefined mapEnabled =
  289.     (
  290.         fSetPosition vGroupMap visible enabled
  291.         fSetPosition vCheckboxMap visible mapDefined
  292.         fSetPosition vSpinnerMap visible (mapDefined and mapEnabled)
  293.         fSetPosition vButtonMapOpen visible enabled
  294.         fSetPosition vButtonMapShow visible mapDefined
  295.         fSetPosition vButtonMapClear visible mapDefined
  296.         fSetPosition vImageMap visible false
  297.     )
  298.  
  299.     function fSetPositionMatchDiffuse visible enabled =
  300.     (
  301.         fSetPosition vFlashArrow visible enabled
  302.         fSetPosition vCheckboxMatchDiffuse visible enabled
  303.     )
  304.  
  305.     function fSetPositionHighlight visible enabled =
  306.     (
  307.         fSetPosition vFlashHighlight visible enabled
  308.         fSetPosition vSpinnerSpecularLevel visible enabled
  309.         fSetPosition vSpinnerGlossiness visible enabled
  310.         fSetPosition vSpinnerSoften visible enabled
  311.     )
  312.  
  313.     function fSetPositionSelfIllum visible enabled color =
  314.     (
  315.         fSetPosition vCheckboxSelfIllumAmount visible enabled
  316.         fSetPosition vSpinnerSelfIllum visible (enabled and not color)
  317.         fSetPosition vCheckboxSelfIllumColor visible enabled
  318.         fSetPosition vColorSelfIllum visible (enabled and color)
  319.     )
  320.  
  321.     function fGetResizedImage map =
  322.     (
  323.         renderMap map into:vImageBuffer
  324.         vImageBuffer
  325.     )
  326.  
  327.     function fUpdateMaterials =
  328.     (
  329.         if (vMaterialED.vFlagVisible) do
  330.         (    
  331.             local i, j=0, k=0, v = #()
  332.             vCountMaterials = sceneMaterials.count
  333.             v.count = vCountMaterials
  334.             for i=1 to vCountMaterials do
  335.             (
  336.                 local m = sceneMaterials[i] 
  337.                 -- orb 08-22-2001 Fixing Defect 306419
  338.                 v[i] = if m != undefined then m.name else ""
  339.  
  340.                 if (m == vMaterialCurrent) then j = i
  341.                 else if (m == vMultiMaterial) do k = i
  342.             )
  343.             vListMaterials.items = v
  344.     
  345.             local enabled = (vCountMaterials > 0)
  346.             fEnable vLabelMaterials enabled
  347.             fEnable vListMaterials enabled
  348.     
  349.             -- orb 07-30-01 fixing defect 298254
  350.             if (k > 0) then i = k
  351.             else if (j > 0) then i = j
  352.             else i = 0
  353.             vListMaterials.selection = i
  354.         )
  355.     )
  356.  
  357.     function fUpdateSubMaterials state =
  358.     (
  359.         if (state) then (
  360.             local m = vMultiMaterial
  361.             local i, j=0, v=#()
  362.             
  363.             -- orb 08-08-2001 Fixing defect 301873
  364.             -- Apparently, some of the submaterials for a given multi-material
  365.             -- are allowed to be undefined.  This seems like it shouldn't be the case.
  366.             -- Oh well, we have to look to see if any of the submtls are "fake".
  367.             --
  368.             local fakeSubs = 0
  369.             for i=1 to m.numSubs do 
  370.             (
  371.                 if (m.materialList[i] == undefined) then
  372.                 (
  373.                     fakeSubs = fakeSubs + 1
  374.                 )
  375.             )
  376.             
  377.             -- our array will only contain "real" submaterials
  378.             v.count = m.numSubs - fakeSubs
  379.  
  380.             
  381.             local vIdx = 0 -- index into our "real" array
  382.             for i=1 to m.numSubs do 
  383.             (
  384.                 if (m.materialList[i] != undefined) then
  385.                 (
  386.                     if (m.materialList[i] == vMaterialCurrent) do j = i
  387.                     local k = m.materialIDList[i] - vOffsetMaterialID
  388.                 
  389.                     vIdx = vIdx + 1
  390.                     v[vIdx] = ((k as string) + ": " + m.materialList[i].name)
  391.                     
  392.                 )
  393.             )
  394.             vListSubMaterials.items = v
  395.             if (j > 0) then vListSubMaterials.selection = j
  396.             else vListSubMaterials.selection = 1
  397.         ) else vListSubMaterials.items = #()
  398.  
  399.         fSetPosition vEditMultiMaterial state state
  400.         fSetPosition vListSubMaterials state state
  401.         fSetPosition vLabelSubMaterials state state
  402.     )
  403.  
  404.  
  405.     function fGetSelectedMaterial =
  406.     (
  407.         if (selection.count != 1) then
  408.             undefined
  409.         else
  410.         (    local m, surf = selection[1]
  411.             try m = surf.material
  412.             catch m = undefined
  413.             if (m == undefined) then undefined
  414.             else
  415.             (    local type = classof m
  416.                 
  417.                 if (type == StandardMaterial) then m    
  418.                             
  419.                 else if (type != MultiMaterial) then undefined
  420.                 else if (subObjectLevel == undefined or subObjectLevel == 0) then m
  421.                 else
  422.                 (    type = classof surf
  423.                     if (type != Editable_Mesh and type != Editable_Poly) then undefined
  424.                     else
  425.                     (    local i=undefined, face, k, f = surf.selectedFaces
  426.                         if (f.count == 0) then undefined
  427.                         else
  428.                         (    for face in f do
  429.                             (    if (type == Editable_Mesh) then k = getFaceMatID surf face.index
  430.                                 else k = polyOp.getFaceMatID surf face.index
  431.                                 if (i == undefined) then i = k
  432.                                 else if (k != i) do return undefined
  433.                             )
  434.                             #(m, (findItem m.materialIDList (i + vOffsetMaterialID)))
  435.                         )
  436.                     )
  437.                 )
  438.             )
  439.         )
  440.     )
  441.  
  442.     -- orb 08-06-01 fixing defect 304170
  443.     function fCountSelGeom =
  444.     (
  445.         local nCount = 0
  446.         for obj in selection do
  447.         (
  448.             if (isKindOf obj shape) then
  449.             (
  450.                    nCount = nCount + 1
  451.             )
  452.             else if (SuperClassOf obj == GeometryClass) then
  453.             (  
  454.                 if (obj.isTarget != true) then
  455.                 (
  456.                     nCount = nCount + 1
  457.                 )
  458.  
  459.             )
  460.         )
  461.         nCount
  462.     )
  463.  
  464.     -- orb 08-22-2001 Fixing Defect 304726
  465.     function fValidateShader m = 
  466.     (
  467.         local bIsValid = true
  468.         if (m != undefined) then
  469.         (
  470.             try
  471.             (
  472.                 local test 
  473.                 test = m.diffuseMap
  474.                 test = m.diffuseMapEnable
  475.                 test = m.diffuseMapAmount
  476.                 test = m.diffuse
  477.                 test = m.ambientMap
  478.                 test = m.ambientMapEnable
  479.                 test = m.ambientMapAmount
  480.                 test = m.adLock
  481.                 test = m.adTextureLock
  482.                 test = m.specularLevel
  483.                 test = m.glossiness
  484.                 test = m.soften
  485.                 test = m.specularMap
  486.                 test = m.specularMapEnable
  487.                 test = m.specularMapAmount
  488.                 test = m.dsLock
  489.                 test = m.specular
  490.                 test = m.specularLevelMap
  491.                 test = m.specularLevelMapEnable
  492.                 test = m.specularLevelMapAmount
  493.                 test = m.glossinessMap
  494.                 test = m.glossinessMapEnable
  495.                 test = m.glossinessMapAmount
  496.                 test = m.selfIllumMap
  497.                 test = m.selfIllumMapEnable
  498.                 test = m.selfIllumMapAmount
  499.                 test = m.useSelfIllumColor
  500.                 test = m.selfIllumAmount
  501.                 test = m.selfIllumColor
  502.                 test = m.opacityMap
  503.                 test = m.opacityMapEnable
  504.                 test = m.opacityMapAmount
  505.                 test = m.opacity
  506.                 test = m.bumpMapEnable
  507.                 test = m.bumpMapAmount
  508.             ) 
  509.             catch
  510.             (
  511.                 bIsValid = false
  512.             )
  513.         )
  514.         bIsValid
  515.     )
  516.  
  517.     function fUpdateTools =
  518.     (
  519.         if (vMaterialED.vFlagVisible) do
  520.         (    
  521.         -- orb 08-22-2001 Fixing Defect 304726
  522.             local f = ((vMaterialCurrent != undefined) and (vMaterialED.fValidateShader vMaterialCurrent))
  523.     
  524.             fEnable vButtonGet (fGetSelectedMaterial()!=undefined)
  525.             fEnable vButtonNew true
  526.             fEnable vButtonApply (f and vMaterialED.fCountSelGeom()>0)
  527.             fEnable vButtonCopy f
  528.             fEnable vButtonDelete f
  529.             fEnable vButtonMaterialShow f
  530.             fEnable vButtonSelect f
  531.     
  532.             local mtlOn = vMaterialED.fGetMaterialSMIVState(vMaterialCurrent)
  533.             vButtonMaterialShow.state = (f and mtlOn) 
  534.     
  535.             fUpdateSubMaterials (vMultiMaterial != undefined)
  536.     
  537.             if (f) then (
  538.                 vEditName.text = vMaterialCurrent.name
  539.                 if (vMultiMaterial != undefined) do vEditMultiMaterial.text = vMultiMaterial.name
  540.                 vCheckboxTwoSided.state = vMaterialCurrent.twoSided 
  541.             ) else (
  542.                 vEditName.text = ""
  543.                 vCheckboxTwoSided.state = false
  544.             )
  545.             fEnable vEditName f
  546.             fEnable vLabelOptions f
  547.             fEnable vCheckboxTwoSided f
  548.         )
  549.     )
  550.  
  551.     function fUpdatePanel tab:undefined =
  552.     (
  553.         if (tab != undefined) then (
  554.             vTabCurrent = tab
  555.             local label = tab
  556.             if (tab == vTabSpecularColor or tab == vTabSpecularLevel) do
  557.                 label = "Specular " + label
  558.             if (tab == vTabSpecularLevel or tab == vTabGlossiness) then
  559.                 label = label + " Map"
  560.             else label = label + " Factors"
  561.             vFlashTop.SetVariable "label.text" label
  562.             vGroupMap.text = tab + " Map"
  563.         ) else if (vTabCurrent == undefined) do return 0
  564.  
  565.         local m, f = (vMaterialCurrent != undefined)
  566.         if (f) then m = vMaterialCurrent
  567.         else m = vMaterialUndefined
  568.         fEnable vLabelComponents f
  569.         fEnable vFlashTabs f
  570.         fEnable vFlashTop f
  571.  
  572.         local map, mapEnable, mapAmount
  573.         local flagMatchDiffuse=false, flagColor=false
  574.  
  575.         -- orb 08-22-2001 Fixing Defect 304726
  576.         if (vMaterialED.fValidateShader m) then
  577.         (
  578.             case vTabCurrent of (
  579.                 vTabDiffuse: (
  580.                     map = m.diffuseMap
  581.                     mapEnable = m.diffuseMapEnable
  582.                     mapAmount = m.diffuseMapAmount
  583.                     vColor.color = m.diffuse
  584.                     flagColor = true
  585.                 )
  586.                 vTabAmbient: (
  587.                     map = m.ambientMap
  588.                     mapEnable = m.ambientMapEnable
  589.                     mapAmount = m.ambientMapAmount
  590.                     if (f) then vCheckboxMatchDiffuse.state = (m.adLock or m.adTextureLock)
  591.                     else vCheckboxMatchDiffuse.state = false
  592.                     vColor.color = m.ambient
  593.                     flagMatchDiffuse = true
  594.                     flagColor = true
  595.                 )
  596.                 vTabHighlight: (
  597.                     vSpinnerSpecularLevel.value = m.specularLevel
  598.                     vSpinnerGlossiness.value = m.glossiness
  599.                     vSpinnerSoften.value = m.soften
  600.                 )
  601.                 vTabSpecularColor: (
  602.                     map = m.specularMap
  603.                     mapEnable = m.specularMapEnable
  604.                     mapAmount = m.specularMapAmount
  605.                     if (f) then vCheckboxMatchDiffuse.state = m.dsLock
  606.                     else vCheckboxMatchDiffuse.state = false
  607.                     vColor.color = m.specular
  608.                     flagMatchDiffuse = true
  609.                     flagColor = true
  610.                 )
  611.                 vTabSpecularLevel: (
  612.                     map = m.specularLevelMap
  613.                     mapEnable = m.specularLevelMapEnable
  614.                     mapAmount = m.specularLevelMapAmount
  615.                 )
  616.                 vTabGlossiness: (
  617.                     map = m.glossinessMap
  618.                     mapEnable = m.glossinessMapEnable
  619.                     mapAmount = m.glossinessMapAmount
  620.                 )
  621.                 vTabSelfIllum: (
  622.                     map = m.selfIllumMap
  623.                     mapEnable = m.selfIllumMapEnable
  624.                     mapAmount = m.selfIllumMapAmount
  625.                     vCheckboxSelfIllumAmount.state = (not m.useSelfIllumColor)
  626.                     vCheckboxSelfIllumColor.state = m.useSelfIllumColor
  627.                     vSpinnerSelfIllum.value = m.selfIllumAmount
  628.                     vColorSelfIllum.color = m.selfIllumColor
  629.                 )
  630.                 vTabOpacity: (
  631.                     map = m.opacityMap
  632.                     mapEnable = m.opacityMapEnable
  633.                     mapAmount = m.opacityMapAmount
  634.                     vSpinnerOpacity.value = m.opacity
  635.                 )
  636.                 vTabBump: (
  637.                     map = m.bumpMap
  638.                     mapEnable = m.bumpMapEnable
  639.                     mapAmount = m.bumpMapAmount
  640.                 )
  641.                 default: return 0
  642.             )
  643.         )
  644.  
  645.         fSetPositionHighlight (vTabCurrent == vTabHighlight) f 
  646.         if (flagMatchDiffuse) then (
  647.             fSetPositionMatchDiffuse true f
  648.             f = (f and (not vCheckboxMatchDiffuse.state))
  649.         ) else fSetPositionMatchDiffuse false false
  650.         if (flagColor) then fSetPosition vColor true f
  651.         else fSetPosition vColor false false
  652.         if (vTabCurrent == vTabSelfIllum) then fSetPositionSelfIllum true f m.useSelfIllumColor
  653.         else fSetPositionSelfIllum false false false
  654.         if (vTabCurrent == vTabOpacity) then fSetPosition vSpinnerOpacity true f
  655.         else fSetPosition vSpinnerOpacity false false
  656.  
  657.         if (vTabCurrent == vTabHighlight) then fSetPositionMap false false false false
  658.         else (
  659.             fSetPositionMap true f (map != undefined) mapEnable
  660.             if (map == undefined) then (
  661.                 vCheckboxMap.state = false
  662.                 vSpinnerMap.value = 0
  663.                 vImageMap.bitmap = vMapUndefined
  664.                 vButtonMapShow.state = false
  665.             ) else (
  666.                 vCheckboxMap.state = mapEnable
  667.                 vSpinnerMap.value = mapAmount
  668.                 vImageMap.bitmap = fGetResizedImage map
  669.                 vButtonMapShow.state = vMaterialED.fGetMapSMIVState(map)
  670.             )
  671.         )
  672.  
  673.         vTabPrevious = vTabCurrent
  674.     )
  675.  
  676.     function fSetTab type =
  677.     (
  678.         -- orb 07-19-2001 Fixing defect 301851
  679.         if (type == undefined) do type = vSymbolDiffuse
  680.         
  681.         vFlashTabs.SetVariable "tabSelect" type
  682.         vFlashTabs.TCallLabel "/" "fUpdate"
  683.     )
  684.  
  685.     function fSetTabColor type color =
  686.     (
  687.         vFlashTabs.SetVariable ("color" + type) (fFlashColor color)
  688.         vFlashTabs.TCallLabel "/" "fUpdate"
  689.     )
  690.  
  691.     function fSetTabAmount type value =
  692.     (
  693.         vFlashTabs.SetVariable ("amount" + type) (value as string)
  694.         vFlashTabs.TCallLabel "/" "fUpdate"
  695.     )
  696.  
  697.     function fSetTabValue type =
  698.     (
  699.         local m = vMaterialCurrent
  700.         case type of (
  701.             vSymbolSpecularLevel: (
  702.                 if (m.specularLevel > 0) then fSetTabAmount type m.specularLevel
  703.                 else fSetTabAmount type false
  704.             )
  705.             vSymbolGlossiness: (
  706.                 if (m.specularLevel > 0) then fSetTabAmount type m.glossiness
  707.                 else fSetTabAmount type false
  708.             )
  709.             vSymbolSelfIllum: (
  710.                 if (m.useSelfIllumColor) then (
  711.                     local c = m.selfIllumColor
  712.                     if (c.red > 0 or c.green > 0 or c.blue > 0) then
  713.                         fSetTabColor type c
  714.                     else fSetTabAmount type false
  715.                 ) else if (m.selfIllumAmount > 0) then
  716.                     fSetTabAmount type m.selfIllumAmount
  717.                 else fSetTabAmount type false
  718.             )
  719.             vSymbolOpacity: (
  720.                 if (m.opacity < 100) then fSetTabAmount type m.opacity
  721.                 else fSetTabAmount type false
  722.             )
  723.             default: ()
  724.         )
  725.     )
  726.  
  727.     function fSetTabMap type state =
  728.     (
  729.         vFlashTabs.SetVariable ("map" + type) (state as string)
  730.         vFlashTabs.TCallLabel "/" "fUpdate"
  731.     )
  732.  
  733.     function fSetTabDiffuseRelative type =
  734.     (
  735.         local lock, color, map, mtl = vMaterialCurrent
  736.         if (type == vSymbolAmbient) then (
  737.             lock = (mtl.adLock or mtl.adTextureLock)
  738.             color = mtl.ambient
  739.             map = mtl.ambientMapEnable
  740.         ) else (
  741.             lock = mtl.dsLock
  742.             color = mtl.specular
  743.             map = mtl.specularMapEnable
  744.         )
  745.         vFlashTabs.SetVariable ("lock" + type) (lock as string)
  746.         vFlashTabs.TCallLabel "/" "fUpdate"
  747.         if (not lock) do (
  748.             fSetTabColor type color
  749.             fSetTabMap type map
  750.         )
  751.     )
  752.  
  753.     function fDrawHighlight =
  754.     (
  755.         local level=0, gloss=0
  756.         if (vMaterialCurrent != undefined) do (
  757.             level = vMaterialCurrent.specularLevel
  758.             gloss = vMaterialCurrent.glossiness
  759.         )
  760.         vFlashHighlight.SetVariable "vSpecularLevel" (level as string)
  761.         vFlashHighlight.SetVariable "vGlossiness" (gloss as string)
  762.         vFlashHighlight.TCallLabel "/" "fUpdate"
  763.     )
  764.  
  765.     function fUpdateFlashValues =
  766.     (
  767.         local m = vMaterialCurrent
  768.         
  769.         -- orb 08-22-2001 Fixing Defect 304726
  770.         if (vMaterialED.fValidateShader m) then
  771.         (
  772.             fSetTabColor vSymbolDiffuse m.diffuse
  773.             fSetTabMap vSymbolDiffuse m.diffuseMapEnable
  774.             fSetTabDiffuseRelative vSymbolAmbient
  775.             fSetTabDiffuseRelative vSymbolSpecularColor
  776.             fSetTabValue vSymbolSpecularLevel
  777.             fSetTabMap vSymbolSpecularLevel m.specularLevelMapEnable
  778.             fSetTabValue vSymbolGlossiness
  779.             fSetTabMap vSymbolGlossiness m.glossinessMapEnable
  780.             fSetTabValue vSymbolSelfIllum
  781.             fSetTabMap vSymbolSelfIllum m.selfIllumMapEnable
  782.             fSetTabValue vSymbolOpacity
  783.             fSetTabMap vSymbolOpacity m.opacityMapEnable
  784.             fSetTabMap vSymbolBump m.bumpMapEnable
  785.             fDrawHighlight()
  786.         )
  787.         else
  788.         (
  789.             vMaterialED.fSetCurrentMaterial undefined    
  790.             vMaterialED.fResetGUI()
  791.  
  792.         )
  793.     )
  794.  
  795.     function fMessageUnsupported mat = 
  796.     (
  797.         messageBox ("Warning: unsupported shader on material " + mat.name + ".")
  798.     )
  799.  
  800.     function fUpdatePropertyDisplay =
  801.     (    
  802.         if (not vUIParamChange and vMaterialED.vFlagVisible and vMaterialED.vMaterialCurrent != undefined) then (
  803.             vUIParamChange = false -- LAM - 8/28/01
  804.             vMaterialED.fUpdatePanel()
  805.             vMaterialED.fUpdateFlashValues()
  806.         )
  807.         else
  808.             vUIParamChange = false -- LAM - 8/28/01
  809.     )
  810.  
  811.     function fSetCurrentMaterial material =
  812.     (
  813.         try deleteAllChangeHandlers id:#gMaterialEdTransient
  814.         catch ()
  815.         vMaterialCurrent = material
  816.         if (material != undefined) then
  817.         (
  818.             when parameters material change id:#gMaterialEdTransient handleAt:#redrawViews do vMaterialED.fUpdatePropertyDisplay()
  819.         )
  820.  
  821.  
  822.     )
  823.  
  824.     function fResetGUI tab:undefined =
  825.     (
  826.         -- orb 07-20-2001: don't do anything unles the window is visible
  827.         if (vMaterialED.vFlagVisible) do
  828.         (
  829.             if (tab == undefined) do tab = vSymbolDiffuse
  830.     
  831.  
  832.             -- orb 08-22-2001 Fixing Defect 304726
  833.             if (vMaterialED_SetMaterial[1] != undefined) then 
  834.             (
  835.                 if (vMaterialED.fValidateShader vMaterialED_SetMaterial[1]) then
  836.                 (    
  837.                     fSetCurrentMaterial vMaterialED_SetMaterial[1]
  838.                     vMultiMaterial = vMaterialED_SetMaterial[2]
  839.                     tab = vMaterialED_SetMaterial[3]
  840.                     vMaterialED_SetMaterial[1] = undefined
  841.                     vMaterialED_SetMaterial[2] = undefined
  842.                     vMaterialED_SetMaterial[3] = undefined
  843.                 )
  844.                 else
  845.                 (
  846.                     vMaterialED.fMessageUnsupported vMaterialED_SetMaterial[1]
  847.                 )
  848.             )
  849.     
  850.             fUpdateMaterials()
  851.             fUpdateTools()
  852.             vFlashTabs.TCallLabel "/" "fInitialize"
  853.             if (vMaterialCurrent != undefined) do fUpdateFlashValues()
  854.             fSetTab tab
  855.         )
  856.     )
  857.  
  858.     -- orb 07-19-2001 Fixing defect 301872
  859.     --     Also call this in callbacks at the bottom of file
  860.     function fResetDefaultGUI = 
  861.     (
  862.         vMaterialED_SetMaterial[1] = undefined
  863.          vMaterialED_SetMaterial[2] = undefined
  864.          vMaterialED_SetMaterial[3] = undefined
  865.             fSetCurrentMaterial undefined
  866.         vMultiMaterial = undefined
  867.         vTabCurrent = undefined
  868.         fResetGUI()
  869.     )
  870.  
  871.     function fCheckMaterials =
  872.     (
  873.         if (vMaterialED.vFlagVisible \
  874.         and vMaterialED.vCountMaterials != sceneMaterials.count) do    
  875.             vMaterialED.fResetDefaultGUI()
  876.     )
  877.  
  878.     function fOpen =
  879.     (
  880.         
  881.         if (vMaterialED_Flash5Installed != 1) then
  882.         (
  883.             -- This will be true if the first time we tried to open it it failed
  884.             -- This way the message box will pop up every time the user hits
  885.             -- the mtl editor button
  886.             MessageBox "Error: Macromedia Flash 5 Player is required to run the gmax Material Editor" title:"gmax Material Editor"
  887.         )
  888.         else
  889.         (
  890.             try (
  891.                 createDialog vMaterialED \
  892.                     pos: vMaterialED_Position \
  893.                     style:#(#style_titlebar, #style_toolwindow, #style_sysmenu) 
  894.                 -- orb 08-06-01 Fixing defect 304842
  895.                 setFocus vMaterialED
  896.             )
  897.             catch
  898.             (
  899.                 vMaterialED_Flash5Installed = 0
  900.                 vFlagVisible = false
  901.                 callbacks.removeScripts id:#gMaterialED
  902.                 callbacks.removeScripts id:#gMaterialEdPersistent
  903.                 unregisterTimeCallback fUpdatePropertyDisplay
  904.                 deleteAllChangeHandlers id:#gMaterialEdTransient
  905.                 MessageBox "Error: Macromedia Flash 5 Player is required to run the gmax Material Editor" title:"gmax Material Editor"
  906.             )
  907.         )
  908.     )
  909.  
  910.     function fGetMaterialByName name =
  911.     (
  912.         local mtl
  913.         for mtl in sceneMaterials do
  914.             if (mtl.name == name) do return mtl
  915.         undefined
  916.     )
  917.  
  918.     function fGetCopyName name =
  919.     (
  920.         local i=0, s1="Copy", s2=" of "+name
  921.         name = s1 + s2
  922.         while ((fGetMaterialByName name) != undefined) do (
  923.             i = i + 1
  924.             name = s1 + (i as string) + s2
  925.         )
  926.         name
  927.     )
  928.  
  929.     function fGetMaterial new:false fromCopy:false index:undefined =
  930.     (
  931.         local m = vMaterialCurrent
  932.         if (new) then (
  933.             m = standardMaterial()
  934.             assignNewName m
  935.             append sceneMaterials m
  936.             -- orb 08-01-01 have to update SMIV for vMaterialCurrent!!!
  937.             vMaterialCurrent = m
  938.             vMaterialED.fShowMaterial true
  939.  
  940.         ) else if (fromCopy) then (
  941.             if (vMultiMaterial != undefined) do m = vMultiMaterial
  942.             local n = copy m
  943.             n.name = fGetCopyName m.name
  944.             if (vMultiMaterial != undefined) do (
  945.                 local i=0, s, t
  946.                 for s in m.materialList do (
  947.                     t = copy s
  948.                     t.name = fGetCopyName s.name
  949.                     i = i + 1
  950.                     n.materialList[i] = t
  951.                 ) 
  952.             )
  953.             append sceneMaterials n
  954.             m = n
  955.         ) else if (index != undefined) do
  956.             m = sceneMaterials[index]
  957.         m
  958.     )
  959.  
  960.     function fGetMaterialFromSlot index =
  961.     (
  962.         /* get material from core Material Editor slot */
  963.         local m = getMeditMaterial index
  964.  
  965.         /* determine if material is already in scene */
  966.         local mtl
  967.         for mtl in sceneMaterials do
  968.             if (mtl == m) do return m
  969.  
  970.         /* not in scene -> add to scene with unique name */
  971.         if ((fGetMaterialByName m.name) != undefined) do m.name = fGetCopyName m.name
  972.         append sceneMaterials m
  973.         m
  974.     )
  975.  
  976.     function fSetMaterial material subIndex:undefined tab:undefined =
  977.     (
  978.         local type = classof material
  979.         if (type == MultiMaterial) then (
  980.             vMultiMaterial = material
  981.             if (subIndex == undefined) do subIndex = 1
  982.             if (subIndex > 0 and subIndex <= material.numSubs) then
  983.                 material = material.materialList[subIndex]
  984.             else material = undefined
  985.         ) else (
  986.             vMultiMaterial = undefined
  987.  
  988.             if (type != StandardMaterial) then
  989.             (
  990.                 -- orb 08-22-2001 Fixing Defect 304726
  991.                 local msg = "Warning: Material " + material.name + " is an unsupported material type."
  992.                 messageBox (msg)
  993.                 material = undefined
  994.             )
  995.             else if (not (vMaterialED.fValidateShader material)) then
  996.             (
  997.             -- orb 08-22-2001 Fixing Defect 304726
  998.                 vMaterialED.fMessageUnsupported material
  999.             )
  1000.         )
  1001.         fSetCurrentMaterial material
  1002.         if (vFlagVisible) then fResetGUI tab:tab
  1003.         else (
  1004.             vMaterialED_SetMaterial = #(vMaterialCurrent,vMultiMaterial,tab)
  1005.             fOpen()
  1006.         )
  1007.     )
  1008.  
  1009.     function fSetSubMaterial index =
  1010.     (
  1011.         fSetCurrentMaterial vMultiMaterial.materialList[index]
  1012.         fResetGUI tab:(fTabSymbol vTabCurrent)
  1013.     )
  1014.  
  1015.     function fSelectMaterial =
  1016.     (
  1017.         local m = fGetSelectedMaterial()
  1018.         if (m != undefined) do (
  1019.             if ((classof m) == Array) then fSetMaterial m[1] subIndex:m[2]
  1020.             else fSetMaterial m
  1021.         )
  1022.     )
  1023.  
  1024.     function fSetMap map =
  1025.     (
  1026.         try
  1027.         (    vUIParamChange = true
  1028.             local m = vMaterialCurrent
  1029.             if (map == undefined) do (
  1030.                 local map0
  1031.                 case vTabCurrent of (
  1032.                     vTabDiffuse: map0 = m.diffuseMap
  1033.                     vTabAmbient: map0 = m.ambientMap
  1034.                     vTabSpecularColor: map0 = m.specularMap
  1035.                     vTabSpecularLevel: map0 = m.specularLevelMap
  1036.                     vTabGlossiness: map0 = m.glossinessMap
  1037.                     vTabSelfIllum: map0 = m.selfIllumMap
  1038.                     vTabOpacity: map0 = m.opacityMap
  1039.                     vTabBump: map0 = m.bumpMap
  1040.                     default: (vUIParamChange = false;return 0) -- LAM - 8/28/01
  1041.                 )
  1042.                 if (map0 != undefined) do (
  1043.                     vMaterialED.fShowMap false
  1044.                     vCheckboxMap.state = false
  1045.                     fEnable vCheckboxMap false
  1046.                     vSpinnerMap.value = 0
  1047.                     fEnable vSpinnerMap false
  1048.                     fEnable vButtonMapClear false
  1049.                     vImageMap.bitmap = vMapUndefined
  1050.                 )
  1051.             )
  1052.             local f = (map != undefined)
  1053.             case vTabCurrent of (
  1054.                 vTabDiffuse: (
  1055.                     m.diffuseMap = map
  1056.                     fSetTabMap vSymbolDiffuse f
  1057.                 )
  1058.                 vTabAmbient: (
  1059.                     m.ambientMap = map
  1060.                     fSetTabMap vSymbolAmbient f
  1061.                 )
  1062.                 vTabSpecularColor: (
  1063.                     m.specularMap = map
  1064.                     fSetTabMap vSymbolSpecularColor f
  1065.                 )
  1066.                 vTabSpecularLevel: (
  1067.                     m.specularLevelMap = map
  1068.                     fSetTabMap vSymbolSpecularLevel f
  1069.                 )
  1070.                 vTabGlossiness: (
  1071.                     m.glossinessMap = map
  1072.                     fSetTabMap vSymbolGlossiness f
  1073.                 )
  1074.                 vTabSelfIllum: (
  1075.                     m.selfIllumMap = map
  1076.                     fSetTabMap vSymbolSelfIllum f
  1077.                 )
  1078.                 vTabOpacity: (
  1079.                     m.opacityMap = map
  1080.                     fSetTabMap vSymbolOpacity f
  1081.                 )
  1082.                 vTabBump: (
  1083.                     m.bumpMap = map
  1084.                     fSetTabMap vSymbolBump f
  1085.                 )
  1086.                 default: (
  1087.                     vUIParamChange = false
  1088.                     return 0
  1089.                 )
  1090.             )
  1091.             if (map != undefined) then (
  1092.                 -- orb 08-01-01 removed this to fix defect 
  1093.                 -- showTextureMap m map true
  1094.  
  1095.                 vCheckboxMap.state = true
  1096.                 fEnable vCheckboxMap true
  1097.                 vSpinnerMap.value = 100
  1098.                 fEnable vSpinnerMap true
  1099.                 fEnable vButtonMapClear true
  1100.                 fEnable vButtonMapShow true
  1101.                 vImageMap.bitmap = fGetResizedImage map
  1102.             )
  1103.         )
  1104.         catch ()
  1105. --        vUIParamChange = false -- LAM - 8/28/01
  1106.     )
  1107.  
  1108.     function fChangeMap mode =
  1109.     (
  1110.         if (mode == #clear) then fSetMap undefined
  1111.         else if (mode == #open) do (
  1112.             local s = "Locate bitmap file for " + vTabCurrent + " component ..."
  1113.             local i = selectBitMap caption:s
  1114.             if (i != undefined) then
  1115.             (
  1116.                 bmTex = bitmapTexture bitmap:i
  1117.  
  1118.                 -- orb 08-07-01 Fixing defect 305535
  1119.                 bmTex.Reload()
  1120.                 fSetMap (bmTex)
  1121.             )
  1122.         )
  1123.     )
  1124.  
  1125.     function fGetMapSMIVState map =
  1126.     (
  1127.         local mapIsOn = false
  1128.         if (map != undefined) then
  1129.         (
  1130.             bits = getMTLMEditFlags map
  1131.             if bits[6] then (mapIsOn = true)
  1132.             else (mapIsOn = false)
  1133.         )
  1134.         mapIsOn
  1135.     )
  1136.  
  1137.     function fGetMaterialSMIVState mtl = 
  1138.     (
  1139.         local mtlIsOn = false
  1140.  
  1141.         if (mtl!=undefined) then
  1142.         (
  1143.             local bits
  1144.             bits = getMTLMEditFlags mtl
  1145.             if bits[6] then 
  1146.             (
  1147.                 mtlIsOn = true
  1148.             )
  1149.             else 
  1150.             (
  1151.                 mtlIsOn = false
  1152.             )
  1153.         )
  1154.         mtlIsOn
  1155.     )
  1156.  
  1157.     -- orb 07-25-01
  1158.     -- fShowMap turns on the "map level" show map in viewport (SMIV) for the current map
  1159.     -- if state is true, then it also turns off the "material level" SMIV for the current material
  1160.     function fShowMap state =
  1161.     (
  1162.         local m = vMaterialCurrent
  1163.         if (m != undefined) do (
  1164.             local map0
  1165.             case vTabCurrent of (
  1166.                 vTabDiffuse: map0 = m.diffuseMap
  1167.                 vTabAmbient: map0 = m.ambientMap
  1168.                 vTabSpecularColor: map0 = m.specularMap
  1169.                 vTabSpecularLevel: map0 = m.specularLevelMap
  1170.                 vTabGlossiness: map0 = m.glossinessMap
  1171.                 vTabSelfIllum: map0 = m.selfIllumMap
  1172.                 vTabOpacity: map0 = m.opacityMap
  1173.                 vTabBump: map0 = m.bumpMap
  1174.                 default: return 0
  1175.             )
  1176.             if (map0 != undefined) then
  1177.             (
  1178.                 local mapOn = false
  1179.                 mapOn = fGetMapSMIVState(map0)
  1180.                 if (mapOn != state) then
  1181.                 (
  1182.                     showTextureMap m map0 state
  1183.                     if (state == true) then
  1184.                     ( 
  1185.                         -- We've turned on the "map SMIV", so turn off the "material" SMIV
  1186.                         showTextureMap m false
  1187.                     )
  1188.                 )
  1189.                 vMaterialED.fResetGUI tab:(fTabSymbol vTabCurrent) -- update the SMIV buttons for "material" and "map"
  1190.  
  1191.             )
  1192.     )
  1193.  
  1194.     )
  1195.  
  1196.     -- orb 07-25-01
  1197.     -- fShowMaterial turns on the "material level" show map in viewport (SMIV) for the current material
  1198.     -- if state is true, then it also turns off all submaps "map level" SMIV
  1199.     function fShowMaterial state =
  1200.     (
  1201.         local m = vMaterialCurrent
  1202.         if (m != undefined) then 
  1203.         (
  1204.             local mtlOn = false
  1205.             mtlOn = fGetMaterialSMIVState(m)
  1206.             if (mtlOn != state) then
  1207.             (
  1208.                 showTextureMap m state
  1209.                 if (state == true) then
  1210.                 ( 
  1211.                     -- We've turned on the "material SMIV", so turn off all the submaps SMIV
  1212.                     if (m.diffuseMap       != undefined) do showTextureMap m m.diffuseMap       false
  1213.                     if (m.ambientMap       != undefined) do showTextureMap m m.ambientMap       false
  1214.                     if (m.specularMap      != undefined) do showTextureMap m m.specularMap      false
  1215.                     if (m.specularLevelMap != undefined) do showTextureMap m m.specularLevelMap false
  1216.                     if (m.glossinessMap    != undefined) do showTextureMap m m.glossinessMap    false
  1217.                     if (m.selfIllumMap     != undefined) do showTextureMap m m.selfIllumMap     false
  1218.                     if (m.opacityMap       != undefined) do showTextureMap m m.opacityMap       false
  1219.                     if (m.bumpMap          != undefined) do showTextureMap m m.bumpMap          false
  1220.                 )
  1221.                 vMaterialED.fResetGUI tab:(fTabSymbol vTabCurrent) -- update the SMIV buttons for "material" and "map"
  1222.             )
  1223.         )
  1224.     )
  1225.  
  1226.     function fProcessNameChange material field =
  1227.     (
  1228.         local mtl, name = field.text
  1229.         if (name == material.name) then
  1230.             false
  1231.         else
  1232.         (
  1233.             if (name == "") then (
  1234.                 field.text = material.name
  1235.                 messageBox "Materials cannot have blank names." title:"gmax Material Editor: Error"
  1236.                 false
  1237.             )
  1238.             else
  1239.             (    for mtl in sceneMaterials do
  1240.                     if (name == mtl.name and mtl != vMaterialCurrent) do (
  1241.                         field.text = material.name 
  1242.                         messageBox ("Name \"" + name + "\" is used by another material." \
  1243.                                 + " Material names must be unique.") \
  1244.                             title:"MaterialED: Error"
  1245.                         return false
  1246.                     )
  1247.         
  1248.                 vUIParamChange = true
  1249.                 material.name = name
  1250. --                vUIParamChange = false  -- LAM - 8/28/01
  1251.                 fUpdateMaterials()
  1252.                 true
  1253.             )
  1254.         )
  1255.     )
  1256.  
  1257.     function fEditMaterial field value =
  1258.     (
  1259.         try
  1260.         (    vUIParamChange = true
  1261.             if ((vMaterialCurrent != undefined and field != #nameMulti)\
  1262.                 or (vMultiMaterial != undefined and field == #nameMulti)) do
  1263.     
  1264.             (    local m=vMaterialCurrent, x=value
  1265.                 case field of (
  1266.                     #name: if ((fProcessNameChange vMaterialCurrent vEditName) \
  1267.                                 and vMultiMaterial != undefined) do fUpdateSubMaterials true
  1268.                     #nameMulti: fProcessNameChange vMultiMaterial vEditMultiMaterial
  1269.                     #twoSided: m.twoSided = vCheckboxTwoSided.state
  1270.                     #matchDiffuse: (
  1271.                         if (vTabCurrent == vTabAmbient) then (
  1272.                             if (x == undefined) do x = not (m.adLock or m.adTextureLock)
  1273.                             m.adLock = x
  1274.                             m.adTextureLock = x
  1275.                             fSetTabDiffuseRelative vSymbolAmbient
  1276.                         ) else (
  1277.                             if (x == undefined) do x = not m.dsLock
  1278.                             m.dsLock = x
  1279.                             fSetTabDiffuseRelative vSymbolSpecularColor
  1280.                         )
  1281.                         fUpdatePanel() -- LAM - 8/28/01 - shouldn't need this. change handler will call
  1282.                     )
  1283.                     #color: (
  1284.                         if (vTabCurrent == vTabDiffuse) then (
  1285.                             m.diffuse = x
  1286.                             fSetTabColor vSymbolDiffuse x
  1287.                         ) else if (vTabCurrent == vTabAmbient) then (
  1288.                             m.ambient = x
  1289.                             fSetTabColor vSymbolAmbient x
  1290.                         ) else ( /* vTabCurrent == vTabSpecularColor */
  1291.                             m.specular = x
  1292.                             fSetTabColor vSymbolSpecularColor x
  1293.                         )
  1294.                     )
  1295.                     #specularLevel: (
  1296.                         m.specularLevel = x
  1297.                         fSetTabValue vSymbolSpecularLevel
  1298.                         fSetTabValue vSymbolGlossiness
  1299.                         fDrawHighlight()
  1300.                     )
  1301.                     #glossiness: (
  1302.                         m.glossiness = x
  1303.                         fSetTabValue vSymbolSpecularLevel
  1304.                         fSetTabValue vSymbolGlossiness
  1305.                         fDrawHighlight()
  1306.                     )
  1307.                     #soften: m.soften = x
  1308.                     #selfIllumType: (
  1309.                         m.useSelfIllumColor = not x
  1310.                         vCheckboxSelfIllumAmount.state = x
  1311.                         vCheckboxSelfIllumColor.state = not x
  1312.                         fEnable vSpinnerSelfIllum x
  1313.                         fEnable vColorSelfIllum (not x)
  1314.                         fSetTabValue vSymbolSelfIllum
  1315.                     )
  1316.                     #selfIllumAmount: (
  1317.                         m.selfIllumAmount = x
  1318.                         fSetTabValue vSymbolSelfIllum
  1319.                     )
  1320.                     #selfIllumColor: (
  1321.                         m.selfIllumColor = x
  1322.                         fSetTabValue vSymbolSelfIllum
  1323.                     )
  1324.                     #opacity: (
  1325.                         m.opacity = x
  1326.                         fSetTabValue vSymbolOpacity
  1327.                     )
  1328.                     #map: (
  1329.                         case vTabCurrent of (
  1330.                             vTabDiffuse: (
  1331.                                 m.diffuseMapEnable = x
  1332.                                 fSetTabMap vSymbolDiffuse x
  1333.                             )
  1334.                             vTabAmbient: (
  1335.                                 m.ambientMapEnable = x
  1336.                                 fSetTabMap vSymbolAmbient x
  1337.                             )
  1338.                             vTabSpecularColor: (
  1339.                                 m.specularMapEnable = x
  1340.                                 fSetTabMap vSymbolSpecularColor x
  1341.                             )
  1342.                             vTabSpecularLevel: (
  1343.                                 m.specularLevelMapEnable = x
  1344.                                 fSetTabMap vSymbolSpecularLevel x
  1345.                             )
  1346.                             vTabGlossiness: (
  1347.                                 m.glossinessMapEnable = x
  1348.                                 fSetTabMap vSymbolGlossiness x
  1349.                             )
  1350.                             vTabSelfIllum: (
  1351.                                 m.selfIllumMapEnable = x
  1352.                                 fSetTabMap vSymbolSelfIllum x
  1353.                             )
  1354.                             vTabOpacity: (
  1355.                                 m.opacityMapEnable = x
  1356.                                 fSetTabMap vSymbolOpacity x
  1357.                             )
  1358.                             vTabBump: (
  1359.                                 m.bumpMapEnable = x
  1360.                                 fSetTabMap vSymbolBump x
  1361.                             )
  1362.                             default: (
  1363.                                 vUIParamChange = false
  1364.                                 return 0
  1365.                             )
  1366.                         )
  1367.                         fEnable vSpinnerMap x
  1368.                     )
  1369.                     #mapAmount: (
  1370.                         case vTabCurrent of (
  1371.                             vTabDiffuse: m.diffuseMapAmount = x
  1372.                             vTabAmbient: m.ambientMapAmount = x
  1373.                             vTabSpecularColor: m.specularMapAmount = x
  1374.                             vTabSpecularLevel: m.specularLevelMapAmount = x
  1375.                             vTabGlossiness: m.glossinessMapAmount = x
  1376.                             vTabSelfIllum: m.selfIllumMapAmount = x
  1377.                             vTabOpacity: m.opacityMapAmount = x
  1378.                             vTabBump: m.bumpMapAmount = x
  1379.                             default: (vUIParamChange = false) -- LAM - 8/28/01
  1380.                         )
  1381.                     )
  1382.                     default: (vUIParamChange = false) -- LAM - 8/28/01
  1383.                 )
  1384.             )
  1385.         )
  1386.         catch ()
  1387. --        vUIParamChange = false -- LAM - 8/28/01
  1388.  
  1389.     )
  1390.  
  1391.     function fApplyMaterial =
  1392.     (
  1393.         local mtl=vMaterialCurrent, mtlNew=undefined, idxNew=undefined, obj
  1394.         if (vMultiMaterial != undefined \
  1395.         and (subObjectLevel == undefined or subObjectLevel == 0)) do mtl = vMultiMaterial
  1396.         for obj in selection do
  1397.             try (
  1398.                 obj.material = mtl
  1399.                 if (obj.material != mtl) do (
  1400.                     mtlNew = obj.material
  1401.                     if ((classof mtlNew) == MultiMaterial) do (
  1402.                         local j = findItem mtlNew.materialList vMaterialCurrent
  1403.                         if (j > 0) do idxNew = j
  1404.                     )
  1405.                 )
  1406.             )
  1407.             catch ()
  1408.         if (mtlNew != undefined) do fSetMaterial mtlNew subIndex:idxNew 
  1409.         
  1410.         -- orb 08-06-01 Fixing defect 303795
  1411.         vMaterialED.fResetGUI()
  1412.     )
  1413.  
  1414.     function fDeleteMaterial =
  1415.     (
  1416.         local i, m = vMaterialCurrent
  1417.         if (vMultiMaterial != undefined) do m = vMultiMaterial
  1418.         for i in rootNode.children do
  1419.             try if (i.material == m) do i.material = undefined
  1420.             catch ()
  1421.         i = findItem sceneMaterials m
  1422.         if (i > 0) do deleteItem sceneMaterials i
  1423.         fSetCurrentMaterial undefined
  1424.         vMaterialED.fResetGUI()
  1425.  
  1426.     )
  1427.  
  1428.     function fUpdateColors =
  1429.     (
  1430.         if (vMaterialED.vFlagVisible) do
  1431.  
  1432.         (    vColorText = (colorMan.getColor #text) * 255
  1433.             vColorBackground = (colorMan.getColor #background) * 255
  1434.             vColorViewport = (getUIColor 41) * 255
  1435.     
  1436.             local c1 = fFlashColor vColorText
  1437.             local c2 = fFlashColor vColorBackground
  1438.             local c3 = fFlashColor (vColorBackground * vDimTabs)
  1439.             local f, v = #( vFlashTabs, vFlashRight, vFlashTop, vFlashBottom, vFlashArrow )
  1440.             for f in v do (
  1441.                 f.SetVariable "colorText" c1
  1442.                 f.SetVariable "colorBackground" c2
  1443.                 f.SetVariable "colorSelected" c2
  1444.                 f.SetVariable "colorUnselected" c3
  1445.                 f.TCallLabel "/" "fUpdate"
  1446.             )
  1447.             vFlashHighlight.SetVariable "rgbBackground" (fFlashColor vColorViewport)
  1448.             vFlashHighlight.SetVariable "rgbDisabled" c2
  1449.             vFlashHighlight.TCallLabel "/" "fApplyColors"
  1450.     
  1451.             vMapUndefined = bitmap 1 1 color:vColorBackground
  1452.         )
  1453.     )
  1454.  
  1455.     function fLoadGraphics control graphics =
  1456.     (
  1457.         if ((classof control) == activeXControl) then (
  1458.             control.movie = vFlashPath + graphics + ".swf"
  1459.             control.menu = false
  1460.         ) else (
  1461.             local file1 = vIconPath + "_i.bmp"
  1462.             local file2 = vIconPath + "_a.bmp"
  1463.             local count = graphics[1]
  1464.             local i1 = graphics[2]
  1465.             local i2 = graphics[2]
  1466.             if (count > 1) do i2 = i2 + 1
  1467.             control.images = #(file1, file2, vIconCount, i1, i1, i2, i2)
  1468.         )
  1469.     )
  1470.  
  1471.     function fInitializeWindow =
  1472.     (
  1473.         vFlagVisible = true
  1474.         if ((maxversion())[1] < 4200) do vOffsetMaterialID = -1
  1475.         fLoadGraphics vFlashTabs vMovieTabs
  1476.         fLoadGraphics vFlashTop vMovieTop
  1477.         fLoadGraphics vFlashBottom vMovieBottom
  1478.         fLoadGraphics vFlashRight vMovieRight
  1479.         fLoadGraphics vFlashArrow vMovieArrow
  1480.         fLoadGraphics vFlashHighlight vMovieHighlight
  1481.         fLoadGraphics vButtonNavigator vIconsNavigator
  1482.         fLoadGraphics vButtonSelect vIconsSelect
  1483.         fLoadGraphics vButtonMapOpen vIconsOpen
  1484.         fLoadGraphics vButtonMapClear vIconsDelete
  1485.         fLoadGraphics vButtonMaterialShow vIconsShow
  1486.         fLoadGraphics vButtonMapShow vIconsShow
  1487.         fUpdateColors()
  1488.         fSetPositionMatchDiffuse false false
  1489.         fSetPositionHighlight false false
  1490.         fSetPositionSelfIllum false false false
  1491.         fSetPosition vSpinnerOpacity false false
  1492.         fResetGUI()
  1493.     )
  1494.  
  1495.     function fTabsCallback command args =
  1496.     (
  1497.         local arg = filterString args ","
  1498.         if (command == "tab") then fUpdatePanel tab:args
  1499.         else if (command == "map" or command == "color") then (
  1500.             local type = #((fTabSymbol arg[1]), (fTabSymbol arg[2]))
  1501.             local base = "vMaterialED.vMaterialCurrent.", assign="="
  1502.             local source = base + type[1]
  1503.             local target = base + type[2]
  1504.             if command == "map" then (
  1505.                 local map="Map", amount="Amount", enable="Enable"
  1506.                 try (
  1507.                     execute(target+map + assign + "copy " + source+map)
  1508.                     execute(target+map+amount + assign + source+map+amount)
  1509.                     execute(target+map+enable + assign + source+map+enable)
  1510.                 )
  1511.                 catch ()
  1512.                 fSetTabMap type[2] (execute (target+map + "!= undefined"))
  1513.             ) else (
  1514.                 local suffix = "Color"
  1515.                 if (type[1] == vSymbolSelfIllum) do source = source + suffix
  1516.                 if (type[2] == vSymbolSelfIllum) do (
  1517.                     target = target + suffix
  1518.                     vMaterialED.vMaterialCurrent.useSelfIllumColor = true
  1519.                 )
  1520.                 try execute(target + assign + source)
  1521.                 catch ()
  1522.                 fSetTabColor type[2] (execute target)
  1523.             )
  1524.             fSetTab type[2]
  1525.         ) /* else messageBox (command + args) *//* debug aid */
  1526.     )
  1527.  
  1528.     function fSelectByMaterialFilter object =
  1529.     (
  1530.         local m
  1531.         try m = object.material
  1532.         catch ()
  1533.         if m != undefined then
  1534.         (    local c = classof m
  1535.             if (c == StandardMaterial) then
  1536.                 (m == vMaterialCurrent)
  1537.             else if (c == MultiMaterial) do (
  1538.                 local v = m.materialList
  1539.                 local sMtl
  1540.                 for sMtl in v do
  1541.                     if (sMtl == vMaterialCurrent) do return true
  1542.                 false
  1543.             )
  1544.         )
  1545.         else
  1546.             false
  1547.     )
  1548.  
  1549.     function fSelectByMaterial =
  1550.     (
  1551.         
  1552.         local obj, v = selectByName filter:fSelectByMaterialFilter showHidden:true \
  1553.             title:("Select from Objects with Material \"" + vMaterialCurrent.name + "\"")
  1554.         if (v != undefined) do 
  1555.             select v
  1556.     )
  1557.  
  1558.     /* fSet-BySlot functions are interface for external code to tell */
  1559.     /*    scripted editor to load a particular material and/or to pick */
  1560.     /*    a particular tabbed panel. Arguments include a core Material */
  1561.     /*    Editor slot number which indicates the location of the material */
  1562.       /*    object to be loaded. Other arguments may specify a submaterial */
  1563.       /*    (by index) or tab (by channel name). The Material/Map Navigator */
  1564.       /*    calls these functions when it executes "open" operations. */
  1565.     /**/
  1566.     /* fSetMaterialBySlot slot: Directs the scripted editor */
  1567.     /*    to the material in slot number "slot" (int>=1) */
  1568.     /*    with the Diffuse panel showing. 
  1569.     /*    Opens a top-level StandardMaterial or MultiMaterial. */
  1570.     /**/
  1571.     /* fSetMaterialTabBySlot slot tab: Directs the scripted editor */
  1572.     /*    to the material in slot number "slot" (int>=1) at the "tab" */
  1573.     /*    panel (string = "Diffuse Color", "Ambient Color", ...). */
  1574.     /*     Opens a map channel within a top-level StandardMaterial. */
  1575.     /**/
  1576.     /* fSetMultiMaterialBySlot slot index: Directs the scripted editor to */
  1577.     /*     submaterial number "index" (int>=1) of the MultiMaterial in slot */
  1578.     /*     number "slot" (int>=1) with the Diffuse panel showing. Opens a */
  1579.     /*     submaterial (i.e., StandardMaterial nested within a MultiMaterial). */
  1580.     /**/
  1581.     /* fSetMultiMaterialTabBySlot slot index tab: Directs the scripted editor */
  1582.     /*     to the submaterial number "index" (int>=1) of the MultiMaterial in */
  1583.     /*     slot number "slot" (int) with the panel specified by "tab" (string) */
  1584.     /*     showing. Opens a map channel within a submaterial. */
  1585.  
  1586.     function fSetMaterialBySlot slot =
  1587.     (
  1588.         fSetMaterial (fGetMaterialFromSlot slot)
  1589.     )
  1590.  
  1591.     function fSetMaterialTabBySlot slot tab =
  1592.     (
  1593.         fSetMaterial (fGetMaterialFromSlot slot) tab:(fTabSymbol tab)
  1594.     )
  1595.  
  1596.     function fSetMultiMaterialBySlot slot index =
  1597.     (
  1598.         fSetMaterial (fGetMaterialFromSlot slot) subIndex:index 
  1599.     )
  1600.  
  1601.     function fSetMultiMaterialTabBySlot slot index tab =
  1602.     (
  1603.         fSetMaterial (fGetMaterialFromSlot slot) subIndex:index tab:(fTabSymbol tab)
  1604.     )
  1605.  
  1606.     function fTerminateWindow =
  1607.     (
  1608.         
  1609.  
  1610.         vMaterialED_Position = GetDialogPos(vMaterialEd)
  1611.  
  1612.         try deleteAllChangeHandlers id:#gMaterialEdTransient
  1613.         catch ()
  1614.         vFlagVisible = false
  1615.     )
  1616.  
  1617.     -- orb 08-07-01 added this function & calls below to fix 304061
  1618.     function fUpdateListText text multi = 
  1619.     (
  1620.         if (multi) then
  1621.         (
  1622.             -- user is typing in vEditMultiMaterial
  1623.             -- update the multi-material name in the materials list
  1624.             if vListMaterials.selection != 0 do vListMaterials.selected = text
  1625.         )
  1626.         else
  1627.         (
  1628.             -- user is typing in vEditName
  1629.             if (vMultiMaterial != undefined) then
  1630.             (
  1631.                 -- update the subMaterial name in the submaterials list
  1632.                 if vListSubMaterials.selection != 0 do vListSubMaterials.selected = text
  1633.             )
  1634.             else 
  1635.             (
  1636.                 -- update the material name in the materials list
  1637.                 if vListMaterials.selection != 0 do vListMaterials.selected = text
  1638.             )
  1639.         )
  1640.     )
  1641.  
  1642.     on vMaterialED open do fInitializeWindow()
  1643.     on vMaterialED close do fTerminateWindow()
  1644.  
  1645.     on vListMaterials selected arg do fSetMaterial (fGetMaterial index:arg)
  1646.     on vButtonGet pressed do fSelectMaterial()
  1647.     on vButtonNew pressed do undo "New Material" on fSetMaterial (fGetMaterial new:true)
  1648.  
  1649.     on vButtonApply pressed do undo "Apply Material" on fApplyMaterial()
  1650.     on vButtonCopy pressed do undo "Copy Material" on fSetMaterial (fGetMaterial fromCopy:true)
  1651.     on vButtonDelete pressed do undo "Delete Material" on fDeleteMaterial()
  1652.     on vButtonMaterialShow changed arg do fShowMaterial arg
  1653.  
  1654.     on vEditMultiMaterial entered arg do fEditMaterial #nameMulti arg
  1655.     on vEditMultiMaterial changed arg do (vMaterialED.fUpdateListText arg true)
  1656.  
  1657.     on vListSubMaterials selected arg do fSetSubMaterial arg
  1658.  
  1659.     on vEditName entered arg do undo "Material Name" on fEditMaterial #name arg
  1660.     on vEditName changed arg do (vMaterialED.fUpdateListText arg false)
  1661.  
  1662.     on vCheckboxTwoSided changed arg do undo "Material 2-sided" on fEditMaterial #twoSided arg
  1663.     on vFlashTabs FSCommand arg1 arg2 do vMaterialED.fTabsCallback arg1 arg2
  1664.  
  1665.     on vFlashArrow FSCommand arg1 arg2 do undo on fEditMaterial #matchDiffuse undefined
  1666.     on vCheckboxMatchDiffuse changed arg do undo "Mtl Match Diffuse" on fEditMaterial #matchDiffuse arg
  1667.     on vColor changed arg do undo "Mtl Param Change" on fEditMaterial #color arg
  1668.  
  1669.     on vCheckboxSelfIllumAmount changed arg do undo "Mtl Param Change" on fEditMaterial #selfIllumType arg
  1670.     on vCheckboxSelfIllumColor changed arg do undo "Mtl Param Change" on fEditMaterial #selfIllumType (not arg)
  1671.     on vSpinnerSelfIllum changed arg do undo "Mtl Param Change" on fEditMaterial #selfIllumAmount arg
  1672.     on vColorSelfIllum changed arg do undo "Mtl Param Change" on fEditMaterial #selfIllumColor arg
  1673.  
  1674.     on vSpinnerOpacity changed arg do undo "Mtl Param Change" on fEditMaterial #opacity arg
  1675.  
  1676.     on vSpinnerSpecularLevel changed arg do undo "Mtl Param Change" on fEditMaterial #specularLevel arg
  1677.     on vSpinnerGlossiness changed arg do undo "Mtl Param Change" on fEditMaterial #glossiness arg
  1678.     on vSpinnerSoften changed arg do undo "Mtl Param Change" on fEditMaterial #soften arg
  1679.  
  1680.     on vCheckboxMap changed arg do undo "Mtl Param Change" on fEditMaterial #map arg
  1681.     on vSpinnerMap changed arg do undo "Mtl Param Change" on fEditMaterial #mapAmount arg
  1682.     on vButtonMapOpen pressed do undo "Mtl Assign Map" on fChangeMap #open
  1683.     on vButtonMapClear pressed do undo "Mtl Clear Map" on fChangeMap #clear
  1684.     on vButtonMapShow changed arg do fShowMap arg
  1685.  
  1686.     on vButtonSelect pressed do undo "Select by Mtl" on fSelectByMaterial()
  1687.     on vButtonNavigator pressed do max material browser
  1688. )
  1689.  
  1690. /* note: all of these functions should do nothing if window is not open */
  1691. callbacks.addScript #selectionSetChanged "vMaterialED.fUpdateTools()" id:#gMaterialED
  1692. callbacks.addScript #filePostOpen "vMaterialED.fResetDefaultGUI()" id:#gMaterialED
  1693. callbacks.addScript #filePostMerge "vMaterialED.fUpdateMaterials()" id:#gMaterialED
  1694. callbacks.addScript #systemPostReset "vMaterialED.fResetDefaultGUI()" id:#gMaterialED
  1695. callbacks.addScript #systemPostNew "vMaterialED.fResetDefaultGUI()" id:#gMaterialED
  1696. callbacks.addScript #colorChanged "vMaterialED.fUpdateColors()" id:#gMaterialED
  1697. registerTimeCallback vMaterialED.fUpdatePropertyDisplay
  1698. when subAnimStructure sceneMaterials change handleAt:#redrawViews id:#gMaterialEdPersistent do vMaterialED.fCheckMaterials()
  1699.  
  1700. /* eof */
  1701.