PDA

View Full Version : Maxscript creating random morpher setting's?


Tris3d
02-18-2010, 09:19 AM
Heya.

I need to come up with a system for creating very individual looking soldiers for a crowd system. I thought the way to go with this would be to create lots of combination's of morph targets that would alter height, build and facial features etc.

I figured for each copied soldier I would manually alter the morph targets but I was wondering how hard it would be to set up a script that would randomly alter the setting's, giving me fairly unique combination's?

I've never used maxscript properly before so my knowledge is very limited. Its something I'm really interested in learning to help with my pipeline. I guess what I'm saying is, if it's really too hard then don't worry :)

Many thanks in advance

Tris

krestenandersen
02-18-2010, 08:01 PM
it's pretty easy:

for i = 1 to 100 do if $.morpher[i].controller != undefined then $.morpher[i].controller.value = random 0.0 100.0

Tris3d
02-18-2010, 08:10 PM
it's pretty easy:

for i = 1 to 100 do if $.morpher[i].controller != undefined then $.morpher[i].controller.value = random 0.0 100.0

Hey, really appreciate the reply. I don't suppose you mind breaking the code down for me slightly? I'm so new to this :(

So "i" would represent 1 morph target. So I would have to copy this code say 20 times if I had 20 different morph targets and rename to "J", "K" etc? Or would it controller the entire modifier? Would be great if I could link it to a custom made button so that it all triggers off! I can look into that though..

Really appreciate this buddy! Could make my life a lot easier!

krestenandersen
02-18-2010, 08:44 PM
Sure thing :) I'll go through it.

This is the code you need to generate unique combinations. Just copy the code to a blank script, select the node that holds your morphermodifier and evaluate the code.

Dollarsign $ means your current selection

for i = 1 to 100 do --for loop going through all targetslots. i is the slot index
(
if $.morpher[i].controller != undefined then --if the slot is empty then continue
(
$.morpher[i].controller.value = random 0.0 100.0 -- sets the percentage to a random vaule between 0 and 100
)
)

Tris3d
02-19-2010, 07:44 AM
Hey there! Many thanks for that! I'll be sure to test it asap!! Really appreciate it, like I said before, its going to make my life a lot easier!

krestenandersen
02-19-2010, 08:10 AM
No problem!

In addition, it's easy to assign random materials to get more difference in the characters. Just tjeck out the maxscript helpfile, and search on topics on how to assign materials and/or change material ID. Just use the same for loop + random function to choose random materials from your material editor or a library.

Once you complete your script, just mark the text and drag it to the toolbar, rightclick to customize your button and save you custom UI toolbar. Now it's made into a macroscript and has become a part of the UI.

Good luck scripting, It's not really complicated once you learn the basics.

Tris3d
02-19-2010, 08:22 AM
Wow, that would be really handy! Like you said, that will give it even more variety! I'll definitely look into. Thanks for the advice on scripting... I've always been scared to try it but I can really see the benefits! I've ordered my first maxscript book so hopefully in a year or so I will be able to come up with a few things of my own :)

krestenandersen
02-19-2010, 10:45 AM
I can really recommend these two dvd's from Boboland:

http://www.scriptspot.com/bobo/dvds.html

Start with "Maxscript for the masses"

Also the maxscript helpfile has a really good introduction and how-to's

Tris3d
02-19-2010, 02:05 PM
Hey great! I'll check those out! Been such a great help! Thanks again.

CGTalk Moderation
02-19-2010, 02:05 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.