/*=======================================\ | ozDXStgl v1.0 |----------------------------------------| | by: Jason Barnidge | http://www.OmniZed.com |----------------------------------------| | Created: 2009.05.04 | Modified: 2010.03.26 \========================================/ Discription: Creates a standard software shader using the base texture from the assigned DirectX shader and sets Max's viewport to display the assigned DirectX shader as software render, and toggles between the two. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Known issues: - If you drag copy a material, the diffuse of Max's Standard shader will not refresh. The old, or copied texture, will show up instead. \======================================/*/ macroScript oz_DXStgl category:"ozTools" tooltip:"oz_DXStgl" icon:#("OZtoolz",1) ( clearlistener() -- create software shader from directX theMats=#() function SWSfromDXS = ( for obj in selection where ((classof obj) == Editable_Poly) or ((classof obj)== PolyMeshObject) or ((classof obj) == Editable_Mesh) do ( baseTxtr = try (obj.material.baseTexture.filename) catch() print baseTxtr if (obj != undefined) AND (getClassName obj.material == "DirectX Shader") AND (baseTxtr != undefined) then ( theMat = obj.material theMap = obj.material.BaseTexture.filename theItem = findItem theMats theMat if theItem == 0 then (append theMats theMat) ) -- end if else print "some objects selected did not meet the criteria for the oz shader display toggle." ) -- end for loop for m in theMats do ( theMat = m theMap = m.BaseTexture.filename m.renderMaterial = standardMaterial () m.renderMaterial.diffuseMap = Bitmaptexture fileName:theMap m.renderMaterial.diffuseMapEnable = true swMap = m.renderMaterial.diffuseMap showTextureMap theMat swMap on theMat.renderEnabled = true ) ) -- end function --SWSfromDXS(); --print theMats.count --theMats = #() function tglDXrnd = ( --open fn for obj in selection where ((classof obj) == Editable_Poly) or ((classof obj)== PolyMeshObject) or ((classof obj) == Editable_Mesh) do ( baseTxtr = try (obj.material.baseTexture.filename) catch() if (obj != undefined) AND (getClassName obj.material == "DirectX Shader") AND (baseTxtr != undefined) then ( theMat = obj.material if (obj.material.BaseTexture.filename != undefined) then ( theMap = obj.material.BaseTexture.filename theItem = findItem theMats theMat if theItem == 0 then (append theMats theMat) ) --end if filename else print "there is no baseTexture assigned to this DirectX Shader." ) -- end if else if (getClassName obj.material == "Multi/Sub-Object") then ( if queryBox "A 'Multi/Sub-Object' material was founed in the current selection. This task requires the selection to have DirectX Shader(s) assigned. \n\n Would you like to propogate these Materials?" title:"Propogate Multi/Sub-Object Materials?" beep:true == true then ( messagebox "PSYCHE!!! ...sorry this is just placeholder function. WIP..." ) else print "some objects selected did not meet the criteria for the oz shader display toggle." ) ) -- end for loop for m in theMats do ( if (m.renderMaterial.diffuseMap != undefined) AND (m.renderMaterial.diffuseMap.filename == m.BaseTexture.filename) then ( print m.renderMaterial.diffuseMap.filename print m.BaseTexture.filename theMat = m theMap = m.renderMaterial.diffuseMap if (theMat.renderEnabled == true) then ( theMat.renderEnabled = false ) else ( theMat.renderEnabled = true ) redrawViews() ) -- end if diffusemap else if (m.renderMaterial.diffuseMap == undefined) OR (m.renderMaterial.diffuseMap.filename != m.BaseTexture.filename) then ( print "Creating Standard shader" SWSfromDXS(); ) else print "m.renderMaterial.diffuseMap is neither defined nor undefined." ) ) --close fn tglDXrnd(); print theMats.count ) -- end script/macro