Robust texture pathing

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
Old 04 April 2014   #1
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.
 
Old 04 April 2014   #2
try relink bitmap from colin seener.
 
Old 04 April 2014   #3
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 ?

Last edited by Mambo4 : 04 April 2014 at 05:53 PM.
 
Old 04 April 2014   #4
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: %\n" 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 "\t\tmissing:%\n" 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 "\t\tFOUND:%\n" 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 "\t\tFOUND:%\n" newFileName 	
				)else(
					format "\t\tNOT FOUND:%\n"asset	
				)
			)
			ATSOps.refresh()
		)
	)	
)

 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:27 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.