PDA

View Full Version : multiple objects randomly along spline


MFreywald
03-14-2003, 09:00 AM
OK after reading nadeemmar's post, I thought 'Hey! that's a pretty cool little project to do some domninoes falling.' But I wanna take it just a bit farther and have a spline path for the dominoes to follow. I have the dominoes all made and grouped. I know Spray Paint from digimation will take grouped objects and treat each member as a seperate 'particle'. but it's to random on the laying down of the dominoes and they end up either overlapping or not in a straight line from each other. Anyone know of a script to do this? I'd like to be able to just use the grouped objects used as a reference and each dominoe duplicated/instanced out of the group randomly. I'm hoping I wont have to script this myself but may have to.

TapioKa
03-15-2003, 12:47 AM
Interesting problem that you have posed.

The best way to do this is with Reactor or Max5 has Reactor integrated into it. Potentially the simulation of dynamics in version4 could also accomplish this.

Simcloth could also solve your problem with their rigid bodies solver.

With dynamics be prepared to "tweak and play" until the desired effect is achieved.

But that is the best and most accurate way to do it.

Hope that helps.

MFreywald
03-15-2003, 01:43 AM
Hehe, yea... that's not the problem. What I wanna do before applying Reactor to it is take the dominoes I've created (all 26 of em) and randomly distribute them along a spline including the banking of the turns. So for instance, I could make a spline in the shape of a spiral and the dominoes would be layed out along that spline evenly and turned slightly to follow each other.

Reality3D
03-15-2003, 07:59 AM
Use a path constraint with one of the objects and then apply snapshot within the animation range and with multiple copies. Or use spacing tool that allows to pick a spline a distribution path

MFreywald
03-15-2003, 09:24 AM
Path constraint just moves the object along the path. What I'm looking to do is copy/instance a object thats in a group/selection set randomly along a spline. This could be considered the pre-animation setup.

The spacing tool actually threw me for a loop since I'd never used it before, didn't even realize it was there. Unfortunatly it took the whole selection/group/selection set as a single entity and just copied them all for each point along the spline. Granted I could just select one and offset it and then do the same for the rest. But I'm still looking to do it in a random manner. Random meaning which dominoe it would put down would be random from among the 26.

I know it sounds kind of complicated but it really isn't per say. If I could find out how to determine how many objects are in a group and retrieve thier name from the index using Maxscript, I could prob write up a script to do it. I couldn't find any reference to getting the object count or name from a group. All the examples I saw in the help regarding groups assume you know the name already (ie. hardcoded names). Would be real convienent if I could just say something like..

(psuedo code)

vertice_count = getverticecount(spline)

while current_vertice <= vertice_count

object_index = random(group_count)

put group_member(object_index) at current_vertice

current_vertice = current_vertice + 1


or something to that extent.

gnarlycranium
03-15-2003, 09:49 AM
Originally posted by MFreywald
Path constraint just moves the object along the path. What I'm looking to do is copy/instance a object thats in a group/selection set randomly along a spline.

That's why you use Snapshot on it.

Though, that wouldn't be random, it would give you the same result as the Spacing tool. Since there's only 26 of them though, you ought to be able to add some randomness pretty easy yourself. If I can do it with 250 snapshot-ed eyelashes, you can do it with 26 dominoes!

TapioKa
03-16-2003, 07:19 AM
Ok, so now I understand that each domino is unique with it's own number but you want each to be an instance of one?

Personally, I think it would be a lot faster to lay them out on a spline using the spacing tool then moving random ones around.

Or, you can build stairs or a bunch of polys and use the scatter tool to randomly place them on Nfaces.

Or, you can take the spline, put a noise modifier in "x" and "y" direction then use the spacing tool. That will provide randomness.

MFreywald
03-17-2003, 09:36 AM
Almost got it right Tapioka. I have a 'pool' of 26 dominoes that are grouped. I want to take out one of the dominoes from the pool at random and put it down at one point on the spline. Then do it again with another dominoe from the 'pool' picked randomly again.

Alas, though.. Someone was actually kind enough to write a script to do this for me. Since it was sent to me via private message I wont say who or give out the script. If they are willing to share the script with everyone else I'll let them make that decision.

LFShade
03-18-2003, 01:24 AM
I'll be happy to make the script available to the masses just as soon as I create a download page for it on my website. I can't have a bunch o' folks downloading it from a direct link, as my host doesn't allow hotlinking files. Stay tuned:airguitar

Sgt.ArchAngel
03-18-2003, 02:16 AM
i wouldnt mind hosting it for you till you get one setup
cause i would like to have it as well =)

let me know

ICQ 25366398

LFShade
03-18-2003, 02:35 AM
Thanks for the offer, but no need - I've got a page up now :)

Go get the PathDistribute script (http://host.deluxnetwork.com/~rhyde/pathdistribute.html)

Sgt.ArchAngel
03-18-2003, 03:01 AM
np
i jsut looked at the script
works pretty well but is there any way to be able to use it with like helix?
i tried useing helix and even converting it to splien but it wont let me select it

gnarlycranium
03-18-2003, 03:48 AM
My goodness, LFShade, you're just spreading happiness everywhere! Like a geeky Santa! I love it! :D

LFShade
03-18-2003, 04:31 AM
Sgt.ArchAngel-
I made a tiny omission in the script that would make some spline objects un-pickable. I've fixed it, so just download it again and you'll be able to use that helix:thumbsup:

Gnarly Cranium-
Hah! "Geeky Santa" shall be the new title over my avatar:applause:

Sgt.ArchAngel
03-18-2003, 04:48 AM
i get an error when running the new script =(

-- Error occurred during fileIn in <File:D:\pathDistribute.ms>
>> MAXScript FileIn Exception: -- Unknown property: "heightt_pathDistribute" in Rollout:rlt_pathDistribute <<

(i tried changing the part i thoguht might be causing it but it didnt work)(i thought it might of been the heightt_pathDistribute after changing it to hight rlt_pathdistibute it would finaly run but not select helix)



thats from the script listener


ugh i shoulda kept learning to code

LFShade
03-18-2003, 05:53 AM
Wierd. When I uploaded the new version it didn't take...it just corrupted the old version by adding extra characters. That's a new one on me !?!

Oh, and perhaps I should have mentioned - you still need to convert the helix to an editable spline first:)

Try again (http://host.deluxnetwork.com/~rhyde/pathdistribute.html)

gnarlycranium
03-18-2003, 07:00 AM
Originally posted by LFShade
Hah! "Geeky Santa" shall be the new title over my avatar:applause:

Ohhh gawd! Don't make me laugh so much while I've got bronchitis, dood! :D

MFreywald
03-19-2003, 07:06 AM
My man LFShade.... YOU ARE A GENIUS!! The script works beautifully!! Does exactly what I was hoping for. Randomizes objects in a group and distributes them randomly along a spline including banking.

Word of caution to those using this script. Make sure your pivot point is centered to the object(s) (individually). Otherwise it'll offset from the spline and cause havok due to the banking.

CGTalk Moderation
01-14-2006, 03:00 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.