[Closed] Robust texture pathing
Max seems horrible at using relative texture paths.
our max files are moving to new work spaces as we sort out our P4 workflow and texture refs are being lost.
our asset directories look like
../source_art/characters/myGuy/mesh/myguy.max
../source_art/characters/myGuy/textures/myguy_diffuse.tif ...ect
but when the path to …/source_art changes (i.e., a new workspace is created in P4) max looses track of all the textures.
It’s a headache I’ve faced before and not found a robust solution for.
google yields a variety of responses, mostly one-file-at-a-time band aid solutions.
I’d like something bulletproof , reliable, and script-able.
I am thinking of dropping the mesh vs texture folder arrangement and just keeping the textures in the maxfilepath folder so Max can see them.
but I have noticed that when you do this, the mxs reference (obj.material.diffuseMap.filename) still points to the old location.
Thus is important because I need a reliable reference to the source textures file locations.
nice tool, even scriptable, but I need to know how to do it myself.
where can I find the mxs equivalent of the buttons in the bitmap / photometric path editor ?
My searches yielded a bewildering array of ways to mangle and obfuscate max texture file paths.
I settled on asset Tracker’s AtsOps Interface to manage my texture paths, because this seemed to give direct access to the filepath values that cause the “missing File” prompt. Everything else was more of a band aid that didn’t cure the cause.
/*
newDir replaces the "mesh" maxfilepath with "texture"
so "C:/project/art/characters/myCharacter/mesh/ " becomes "C:/project/art/characters/myCharacter/textures/"
if not found in /textures/ then the global /art/ directory is searched.
this covers expected locations of the textures in anyone's local workspace
*/
fn repathBitmaps newDir:(substitutestring maxfilepath "mesh" "texture") =
(
local arr=#()
ATSOps.GetFilesByFileSystemStatus #Missing &arr--gather missing filpaths into the array arr
if arr.count>0 then(
format " repathMissingBitmaps to: %
" newDir
--use maxfilepath to find the local path to /art/
slices=filterstring maxfilepath "\\"
str = ""
artPath=""
index=finditem slices "art"
for i = 1 to index do
(
artPath+=slices[i]
artPath+="\\"
)
for asset in arr do
(
format " missing:%
" asset
AtsOps.clearSelection()
AtsOps.selectFiles #(asset)
local filenameOfAsset = (DotNetClass "System.IO.Path").GetFileName asset
local di = DotNetObject "System.IO.DirectoryInfo" newDir --look in ../textures/
local files = di.GetFiles filenameOfAsset (DotNetClass "System.IO.SearchOption").AllDirectories
if files[1] !=undefined then (
--if found , replace the path in the Asset Tracker
local newFileName = files[1].directoryName
AtsOps.SetPathOnSelection newFileName
format " FOUND:%
" newFileName
)else(
--not in ../textures/ so look globally in .../art/
di = DotNetObject "System.IO.DirectoryInfo" artPath
artfiles = di.GetFiles filenameOfAsset (DotNetClass "System.IO.SearchOption").AllDirectories
for each in artfiles do
if artfiles[1] !=undefined then (
newFileName = artfiles[1].directoryName
AtsOps.SetPathOnSelection newFileName
format " FOUND:%
" newFileName
)else(
format " NOT FOUND:%
"asset
)
)
ATSOps.refresh()
)
)
)