[Closed] newbie requests maxscript help
Hi all, I am new to 3ds max and maxscript and am attempting to write a script to load transparency maps , and later bump and reflection maps to an imported object. The object will be the only thing in the scene at this stage.
I cant find how to create the map in the material. I have looked through the forums but disnt find, or didnt understand how to do it.
this is the code I have – possibly done the wrong way
(
global mymatlist
global q,n
myinf = “c:/temp/max_import/ztest.txt”
mats= for m in sceneMaterials collect m
for m in mats do – test for multimaterial , only 1 in scene
(
a = getNumSubMtls(m)
if a >0 do
(
mymatlist = m.materialList – get the materials
)
)
fi = openFile myinf mode:“r”
while not eof fi do – read the file of image maps to apply
(
r = readLine fi
q = filterString r “,” – split to mat name, type, file name of image
for b in mymatlist do –for each material in sublist
(
n = b.name
if n == q[1] do – test if name matches
(
if q[2] == ” t ” do – test if transparency file
(
map = b.opacityMap – get map from material
if map == undefined do – if not exist create it
(
myBmp = bitmaptexture filename:q[3] – ??
meditmaterials[1].opacityMap = myBmp – ??
b.opacityMapEnable = true – enable map in material
b.opacityMapAmount = 0 – set opacity
print “Done” – print to show progress
)
)
)
)
)
close fi
)
I hope that is clear. The section after if map == undefined is where that map is created n the image file loaded and any values for it set.
Any help greatly appreciated
Quick questions…
- what does a line of your text file look like?
- what does q = filterString r “,” return?
one thing I noticed:
meditmaterials[1].opacityMap = myBmp – ?? should probably be
b.opacityMap = myBmp – ??
the file I read contains a line like
“skin_torso”,“d”,“c:\my pics\skin_torso.png”
which is split for values q[1] etc
this was to allow for diffuse, reflection, bumb and transparency maps to be done at a later time .
I will try your suggestion and see what happens , thanks
made the change and its now working
I was trying to put just the filename in and then got confused on the bitmap
thanks very much.