View Full Version : 100 polaroids > 100 materials AUTOMATION?
05-07-2008, 05:46 PM
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
05-07-2008, 06:07 PM
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.\n\nContinue anyway?") then (
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).
05-07-2008, 06:08 PM
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.
05-07-2008, 07:03 PM
oh thank you guys for the quick reply!!! i´m overwhelmed really! i started that thread 30min ago :)
u sooo rock :buttrock::bowdown::buttrock:
05-07-2008, 07:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.