[Closed] 100 polaroids > 100 materials AUTOMATION?
Hy CGTalk community,
I´m facing a task where i have to create a multi/sub material out of lets say 100 polaroids/fotos. is there a way to automate this precedure
i imagine a script that points to a certain directory, counts the images, creates a multi/sub with as much materials as there were images.
(i know there is a limitation to multi/sub with 256 materials but i seriously doubt i hit that high amount of images!)
any help is highly apprechiated and welcome!
thanks in advance and geetings
anselm
fn makeMultiMatFromBitmapFilenames bmpArray = (
local multiMat = multiMaterial materialList:#()
for i = 1 to bmpArray.count do (
multiMat.materialList[i] = Standard diffusemap:(bitmapTexture filename:bmpArray[i])
)
meditmaterials[activeMeditSlot] = multiMat
)
folder = getSavePath caption:"Specify folder with images..."
bitmapFiles = getFiles (folder + "\\*.jpg")
if (bitmapFiles.count > 256) then (
if (querybox "There are more than 256 bitmaps in this folder.
Continue anyway?") then (
makeMultiMatFromBitmapFilenames bitmapFiles
)
)
else ( makeMultiMatFromBitmapFilenames bitmapFiles )
Note that this assumes JPG files. If they’re not JPGs, change the appropriate code.
If they’re mixed file formats, you can add to the bitmapFiles array if you know their extensions. If you don’t, you’d have to loop over all possible files and try to open them – and put them in the array if they opened ok (this is very slow, obviously… so hopefully you do know what files types they are).
Take this:
MSlot = 1
RastrMap = getBitmapOpenFileName caption:"Open Map:" filename:("C:\\")
aImg = getFiles ((getFilenamePath RastrMap)+"*"+(getFilenameType RastrMap))
MultMat = multimaterial numsubs:aImg.count
For i = 1 to aImg.count do MultMat[i].diffuseMap = Bitmaptexture fileName:aImg[i]
meditMaterials[MSlot] = MultMat
MSlot – Material Editor slot with created MultiSub Material
Choose first file and open it.
oh thank you guys for the quick reply!!! i´m overwhelmed really! i started that thread 30min ago
u sooo rock :buttrock::bowdown::buttrock:
cheers,
anselm