Can you Condense Materials

I've imported some Collada files from xsi into max 2009, all looks good except that it has assigned a separate material to every object even though there are only about 10 materials in the scene. So I have 350 materials instead of 10.

Is there a way to condense materials by there properties rather than by name?

ie Materials Piston 01, Piston 02, Piston 03 etc are all the physically the same material but are all named differently, so have each got their own material.

I have no knowledge of scripting. Is this even possible?
Any help would be great

Thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Total Anarchy's picture
Graph's picture

sure you can, dont have the

sure you can, dont have the time atm but heres a function to compare 2 materials you can do what your looking for with that quite easily.

(
 
 
 
	fn isSameMat mat1 mat2 =	--checks if the 2 supplied materials have the same settings
	(
		local equal = true
 
		if equal AND classOf mat1 != classOf mat2 do equal = false
		if equal do
		(
			local mat1PropNames = getPropNames mat1 ; local mat2PropNames = getPropNames mat2
 
			if mat1PropNames.count != mat2PropNames.count do equal = false
			if equal do
			(
				for i = 1 to mat1PropNames.count while equal do
				(
					if (getProperty mat1 mat1PropNames[i]) as string != (getProperty mat2 mat2PropNames[i]) as string do
					(
						equal = false
					)
				)
			)
		)
		return equal
	)--END isSameMatFN
 
 
	local mat	= meditMaterials[1]
	local mat2	= meditMaterials[2]
	local mat3	= meditMaterials[3]
 
	isSameMat mat mat3
)

if you got multiple mats with same settings but different bitmap texture files you simply dont compare as strings

Raphael Steves

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.