[Closed] Change texture based on location
Hi.
I have a few image planes which textures I would like to react to their position in x-space, i.e. at 5 units on X-axis MAX should apply bitmap 5, at 9 units on X-axis MAX should apply bitmap 9 and so on. The bitmaps are just images on a IFL.
I keep banging against the problem that i cannot wire parameters to attributes in the “time”-rollout in the bitmap node. I also don’t know how to control the loaded texture name, so i cannot manipulate that directly either.
My two workarounds (none of them is very fun) are:
1: making a multi/sub object with materials equal to the number of frames, giving my planes a material modifier and linking the materialID to position. This sucks as i need 10 multi/subs with 100 materials each…
2: print out the value of the planes one by one for each frame, doing a lot of reformatting (excel and notepad can help here) to come out with an ifl and using that. It can work, but is a lot of manual labour, and it really sucks if the animation changes.
I’m not a scripter (nothing beyond copying the MAXScript Listener and changing values), so any guidiance is much appreciated
It’s not too complicated, all you need to is wire parameter the x-pos of your objects transformation to the materialID of the Material Modifier. The connection is simply… “X_Position as integer” with the connection direction being from xpos -> modifier.
Then to create your Multi-sub material use a bit of code to do the work for you… something like this:
themat = Multimaterial()
themat.count = 100
for i = 1 to 100 do
(
themat[i].diffusemap = Bitmaptexture filename:("c:\ est\\image_" + (formattedprint i format:"04d") + ".jpg")
)
meditmaterials[1] = themat
Hi Dave.
That script worked super! It would have been a pain to that by hand
(For anybody else reading this thread, the material is created in a sample slot).
Also, I just found that John Wainwrights MAXScript 101 has been released for free:
http://vimeo.com/album/1514565
Seems like my excuses for not learning MAXScript is running out…
Thanks again!