detect scene texture -- please answer!!!
I've found some ideas here:
http://forums.cgsociety.org/archive/index.php/t-1028393.html :
gc() -- just for this example, to make sure everything is nice and clean -- find the scene root. The rootnode, medit, etc are references off this scene root sceneroot = (for r in (refs.dependents rootnode) where (classof r == Scene) collect r)[1] -- collect all the assets origAssets = for i = 1 to AssetManager.GetNumAssets() collect (AssetManager.GetAssetByIndex i) -- for each of the assets... for AUIO in origAssets do ( -- dump info on the asset local AID = AUIO.GetAssetId() --get the Asset�s ID local AType = AUIO.getType() --get the Asset�s Type local AFile = AUIO.getfilename() --get the Asset�s File Name format "ID:% Type:% File:%\n" AID AType AFile --format the info -- generate new filename, prepend "XXXX_" local lFile = filenameFromPath AFile local lPath = getFileNamePath AFile local lNewName = lPath + "\\" + "XXXX_" + lFile -- do the retargetting atsops.RetargetAssets sceneroot AFile lNewName CreateOutputFolder:false )
and here:
http://www.scriptspot.com/forums/3ds-max/general-scripting/resource-get-...
fn GetBitmapTextures theObjects = ( -- Because some submaps can also contain submaps we have to collect materials first, and then still append subMapContainers in the loop bitmapTextureMaps loop subMapContainers = #() for obj in theObjects do ( if obj.material != undefined then ( submatcount = getNumSubMtls obj.material for i in 1 to submatcount do ( append subMapContainers (getSubMtl obj.material i) ) append subMapContainers (obj.material) ) ) bitmapTextureMaps = #() for subMapContainer in subMapContainers do ( subtexcount = getNumSubTexmaps subMapContainer for i in 1 to subtexcount do ( theSubTexMap = (getSubTexMap subMapContainer i) if theSubTexMap != undefined then ( if (getNumSubTexmaps theSubTexMap) > 0 then ( append subMapContainers theSubTexMap ) else if classof theSubTexMap == bitmapTexture then ( append bitmapTextureMaps theSubTexMap ) ) ) ) makeUniqueArray bitmapTextureMaps ) texmaps = (GetBitmapTextures selection) for texmap in texmaps do print (texmap.filename)
Here is how I detect textures inside materials for the selected objects:
for s in selection do ( --textID = 0 if s.material!=undefined then ( if (finditem uniquematerials s.material==0) do ( append uniquematerials s.material newbitmaps=getclassinstances Bitmaptexture target:s.material ) ) )
I don't use this code:
fn getmapsfromselection = ( for s in selection do ( if s.material!=undefined then ( newbitmaps=getclassinstances Bitmaptexture target:s.material for b in newbitmaps do if (finditem bitmaps_for_selection b==0) then append bitmaps_for_selection b ) ) )
because I need to investigate the materials for map tree, id and so on.
Now the question is:
1. Is the code I have enough and correct for detecting textures inside material?
2. How to detect the textures inside modifiers for the selected objects?
3. How to detect textures used in any other places(sky, hdr etc)
4. How to detect all scene textures
5. How to detect unused textures!
Please answer!!!
Comments
Ok! Thanks! Is this code for detecting all material textures?
does it always work?
:) WOW HOLD ON
I recently start to write my repath tool for all maxobjects (material,modifier,light,environment etc.) that contains bitmaptexture.
Asset Tracking is not the right choise for that. I can not share my unfinished code but maybe this snippet of RECURSIVE function can helps.
maybe this can be also useful
http://www.scriptspot.com/3ds-max/scripts/zoa-path-editor
http://www.scriptspot.com/3ds-max/scripts/relink-vraybmpfilter-maps
barigazy