Gumball machine script ?

Hi,

I’m new to this forum, and this is my first post with a probably easy question.

Any way, I’m in the making of a short movie, and after a while searching the scripts catalog at blender.org I find my self a bit lost because I’m looking for a script that could help me place a bunch of gumballs in to the gumball machine’s glass bowl…

Any suggestions ?

Ps. If someone tought the title was stupid, I really hate finding names for stuff.

//AMZi

you could use the physics engine to naturally drop the gumballs in the bowl

Well I have tried that, it looks really like i want em to. Any idea how to make em stick that way after I stop the engine ?

Cause I have been playing around with the tree from curves script and had thought some one maybe had made something similar, the part when you generate twigs inside the mesh that you place on the trunk acting as a boundary for how fare the twigs reach.
It would be awesome if I could have a script that used a sphere that was big as the bowl and decided a gumball mesh, and how many of them to be duplicated inside of the sphere.

I’m probably asking for a miracle, but my intention is to learn to script in the future. At the moment I’ve been spending night and day trying to learn everything else that is to blender for a couple of months.

//AMZi

Before you press P, go to Game -> Record Game Physics to IPO
That will make an IPO curve for the objects and you can render any frame of the animation.

Well, I’d say it is a nice task to start learning scripting for Blender :wink:

Personally, I am interested in solving it but I dont know how much time I can devote to this right now. I usually dont read other’s related scripts cause I like MY ideas getting implemented. May be this is NOT the perfect tactics but this really leads to making scripts MY way, not developing scripts of others, ok? :stuck_out_tongue:

Mathematically, the task is to inscribe spheres into a bigger one. So lets take it that gums are spheres with radius r and the gumbowl - with R. For 1 gum inside => you’d need to just “drop” it down. For this (and anything else) you dont need any physics engine but only make a simulation. Sooo you simply place the first gum right at the bottom of the bigger sphere. What does it mean? Suppose the gumbowl (its center) is at X,Y,Z => gum #0 should be at X,Y,(Z-r)… It’s easier then physics engine, right? :slight_smile:

It is also know from geometry of the plane that if you have a circle there with radius r, then you can circumscribe exactly 6 such circle around the main one. It works for a sphere placed on a plane too - you may have exactly 6 such spheres around the main one - each touching the other and ALL touching the plane, right? But we have a sphere, not a plane… Your parameters are R and r… soo how many gums can be placed inside the gumbowl depends on the ratio R/r… Anyway, if you have one gum in the middle and 5 other around it in a way to touch it and ALL touching the bowl, then you will have insufficient space for the 6-th gum so the 6-th gum will be a bit higher then the others. I hope it is possible for everyone to imagine this. It is important before scripting anything to know what really happens… Sorry, I dont know a better term than “touch”, “touching” but I mean that two bodies/object have only 1 common point, ok? :slight_smile: So far Im trying to implement location of cums preserving maximum symmetry. Just one is odd so far. And here is the first challenge - to find its proper place. It could be done under conditions discussed above + gum #6 (7-th one) should be not only touching the #5 (6-th one) but also gum #1 (the 2-nd one), ok? This implements some disorder which you need to consider further while placing another gums inside. It is also to judge whether to try reserving symmetry (order) at least on 1 side of the bowl or not.

Another strategy is to randomly place around the main gum another 5 then place other above following the conditions described above. This would be even more realistic, right? Soooo… if I had all those strategies implemented, I make at the end an interface for the user to choose what and how to do - to enter values for R and r, etc… :wink:

Regards,

Guys I’m impressed !
Never experienced such welcoming spirit before.
I’ll try both techniques sometime while the evening and decide which result I prefer.

And post the result’s.

Thanks again.

//AMZi

I would recommend using the record physics to ipo method. I used it for a gumball machine I did fairly recently:http://blenderartists.org/forum/showthread.php?t=162818

Well I didn’t get that random feeling from Abidos technique, and recording in the IPO work’t really great.

But I will saving Abidos answer to read once more, and hopefully it will soak in a bit more.

Here’s the result any way. Haven’t made the coin mechanism yet but its coming. If someone got an idea how to fix the oddity’s in the glass, do tell.

http://img168.imageshack.us/img168/5910/gumballmachine.jpg