macroScript pb_BumpReplace category:"Piranha-Bytes" buttonText:"BumpReplace" toolTip:"BumpReplace" ( rollout ro_BumpReplace "pb BumpReplace" ( checkbutton ui_AllMats "All Materials" pos:[5,5] width:70 height:20 checked:true checkbutton ui_SelMats "Selected Material" pos:[75,5] width:100 height:20 checked:false button ui_ReplaceBM "Bitmap -> NormalBump" pos:[5,25] width:170 height:20 tooltip:"Replace all Bitmap-Bumpmaps with NormalBump-Bumpmap" button ui_ReplaceNB "NormalBump -> Bitmap" pos:[5,45] width:170 height:20 tooltip:"Replace all NormalBump-Bumpmaps with Bitmap-Bumpmap" groupBox grp_Normals "Normalmap Options: " pos:[5,70] width:170 height:90 checkBox ui_FlipRed "Flip Red (X)" pos:[10,90] checkBox ui_FlipGreen "Flip Green (Y)" pos:[10,105] checkBox ui_SwapRG "Swap R / G" pos:[10,120] radioButtons ui_Method pos:[110,90] labels:#("Tangent", "Local", "Screen", "World") listbox ui_InvalidMats "Invalid Materials:" pos:[5,170] width:170 height:10 local invalMats = #() on ui_AllMats changed state do ( ui_AllMats.state = true ui_SelMats.state = false ) on ui_SelMats changed state do ( ui_AllMats.state = false ui_SelMats.state = true ) function replaceBump theMap = ( isValid = 1 theBumpMap = theMap.bumpMap if theBumpMap != undefined do ( bumpClass = (classOf theBumpMap) if bumpClass == BitmapTexture then ( bFile = theBumpMap.filename theMap.bumpMap = Normal_Bump() theMap.bumpMap.normal_map = theBumpMap theMap.bumpMap.flipGreen = ui_FlipGreen.state theMap.bumpMap.flipRed = ui_FlipRed.state theMap.bumpMap.swap_rg = ui_SwapRG.state theMap.bumpMap.method = ui_Method.state - 1 ) else if bumpClass == Normal_Bump then ( theMap.bumpMap.flipGreen = ui_FlipGreen.state theMap.bumpMap.flipRed = ui_FlipRed.state theMap.bumpMap.swap_rg = ui_SwapRG.state theMap.bumpMap.method = ui_Method.state - 1 ) else isValid = 0 ) return isValid ) function replaceNormal theMap = ( isValid = 1 theBumpMap = theMap.bumpMap if theBumpMap != undefined do ( bumpClass = (classOf theBumpMap) if bumpClass == Normal_Bump then theMap.bumpMap = theMap.bumpMap.normal_map ) ) on ui_InvalidMats selected sel do ( cs = mEdit.getActiveMtlSlot() setMEditMaterial cs invalMats[sel] ) on ui_ReplaceBM pressed do ( ui_invalidMats.items = #() theMats = #() if ui_AllMats.state == true then theMats = sceneMaterials if ui_SelMats.state == true then theMats[1] = mEdit.getCurMtl() invalMats = #() for m=1 to theMats.count do ( matClass = classOf theMats[m] if matClass == standardMaterial then ( v = replaceBump theMats[m] if v == 0 then append invalMats theMats[m] ) if matClass == multiMaterial then ( for s=1 to theMats[m].count do ( v = replaceBump theMats[m][s] if v == 0 then append invalMats theMats[m][s] ) ) ) invalNames = #() for i=1 to invalMats.count do append invalNames invalMats[i].name ui_invalidMats.items = invalNames ) on ui_ReplaceNB pressed do ( theMats = #() if ui_AllMats.state == true then theMats = sceneMaterials if ui_SelMats.state == true then theMats[1] = mEdit.getCurMtl() for m=1 to theMats.count do ( matClass = classOf theMats[m] if matClass == standardMaterial then ( v = replaceNormal theMats[m] ) if matClass == multiMaterial then ( for s=1 to theMats[m].count do ( v = replaceNormal theMats[m][s] ) ) ) ) ) createDialog ro_BumpReplace width:180 )