View Full Version : How to randomly assign material on a specific count of objects ?
BebeteLANUITE 02-22-2006, 09:02 AM Hello everybody.
I search a way to randomly apply some material on some objects.
I have 54 objects and 6 materials (6x9 = 54. I guess you understand ;) )
I want to randomly select object 9 by 9 and apply a material in each time. Of course the objects that already be select and get a material can't be select again.
All of the objects already have a material on it. I think to freeze the objects i select and test the freeze to avoïd this object be selected again. And when all objects has changed material, unfreeze all.
Someone has an idea to make it ?
Thank you for your help guys :thumbsup:
|
|
Light
02-22-2006, 11:26 AM
Hi Bruno,
You can use something like this:
for i = 1 to selection.count do selection[i].material = meditMaterials[((i - 1) / 9) + 1]
Light
BebeteLANUITE
02-22-2006, 12:14 PM
Oh god. :D
I think i always learn something in maxscript.
I don't know the selection[i].
Thanks a lot Light. :thumbsup:
Your help is very useful. I tell you if i success ;)
BebeteLANUITE
02-22-2006, 12:25 PM
That's works, that's works :D :D :D
Thank a lot Light.
Could explain me your line of code. I don't understand it a lot.
Thank you again :thumbsup:
loran
02-22-2006, 01:18 PM
cool!
and what if I want to assign randomly to any count of object ??(imagine a crowd clothes colors)
Light
02-22-2006, 01:53 PM
It basically loops through your current selection and assigns materials from 1 to 6. You can see that "((i - 1) / 9) + 1" creates values from 1 to 6 throughout the loop.
for i in selection do i.material = meditMaterials[random 1 24] would do what you need Laurent.
Light
loran
02-22-2006, 02:02 PM
ok I got it by myself, thx!
But how can I specify the material range with a spinner or something?
rollout forege "random material"
(
label label0d "this tool apply random materials"
label label1d " from MaterialEditor to selection."
button un " RANDOMIZER - 6 materials "
on un pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 6.0]
)
button deux " RANDOMIZER - 10 materials "
on deux pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 10.0]
)
button trois " RANDOMIZER - 15 materials "
on trois pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 15.0]
)
)
createDialog forege width:220 height:130
soulburn3d
02-22-2006, 05:11 PM
Or check the RandomMat script available here:
http://www.neilblevins.com/blurscripts/blurscripts.htm
- Neil
Light
02-22-2006, 06:06 PM
Laurent,
Just add a spinner control like: spinner toVal range:[1,24,6] and then use toVal.value instead of max values like random 1 toVal.value
Light
loran
02-23-2006, 08:12 AM
thx Light.!!
CGTalk Moderation
02-23-2006, 08:12 AM
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.