PDA

View Full Version : filling popcorn in a bowl


modi
07-28-2003, 11:08 PM
like the subject says, how do i go bout filling popcorn in a bowl, i've modelled 2 or 3 diff shapes and sizes of popcorn and i need to fill up a bowl full of these lil guys. It'll probably take about 200 of these guys to fill up the bowl so any ideas on how i go about doing that other than manually doing it and randomising it??
Cheers.

Jozvex
07-28-2003, 11:41 PM
Well do you really need to fill the whole bowl? Or could you just create the top two layers for example?

If you really need the whole bowl full, you could perhaps try using my Interparticle Collisions tutorial to fill the bowl with particles, then instance the popcorn objects onto the particles. The only trick would be trying to prevent any intersections between the popcorn meshes.

My tutorial: www.jozvex.com/tutorials/interparticle.html

Or, you could do what I once did to fill a jar with lollies. Which was to makes lots of copies of the popcorn, turn them into Active Rigid Bodies, turn the bowl into a Passive Rigid Body, apply Gravity and actually drop the popcorn into the bowl dynamically. It would probably be a huge calculation. But you could always do it with 15 pieces at a time or something??

:shrug:

modi
07-29-2003, 12:34 AM
Originally posted by Jozvex


Or, you could do what I once did to fill a jar with lollies. Which was to makes lots of copies of the popcorn, turn them into Active Rigid Bodies, turn the bowl into a Passive Rigid Body, apply Gravity and actually drop the popcorn into the bowl dynamically. It would probably be a huge calculation. But you could always do it with 15 pieces at a time or something??

:shrug:

Genius!!!. One question though, i'm kinda new to particles. After i'm done filling up the bowl (say 15 popcorns at a time, how do i delete the connection to being active rigid bodies?
Also, in your tutorial, how do i go about replacing those particles with my geometry and breaking the connection again so i can do a software render. I don't need any effects of the partilces i just need them to be filled in a bowl. Cheers n thanx.

Jozvex
07-29-2003, 03:45 AM
Originally posted by modi

One question though, i'm kinda new to particles. After i'm done filling up the bowl (say 15 popcorns at a time, how do i delete the connection to being active rigid bodies?

Well, firstly you'd need to select those pieces of popcorn that you want to stay the way they are and go:

Solvers > Initial State > Set for Selected

That'll make their current position their starting position even when you rewind your animation. Then you can go (with them still selected):

Soft/Rigid Bodies > Break Rigid Body Connections

Then they'll just be ordinary objects again.

Originally posted by modi

Also, in your tutorial, how do i go about replacing those particles with my geometry and breaking the connection again so i can do a software render.

Well you won't need to worry about breaking the connection, because instanced particles render in the software renderer just fine.

To instance multiple objects into a particle system, select one of each of the types of popcorn you made and go to:

Particles > Instancer (Replacement)

But that will actually only instance one of the popcorn types to all the particles. To get the particles to randomly pick which popcorn model to choose for each particle, you need to create a custom per-particle attribute:

1. Open the Attribute Editor with the particles selected (not the emitter, the actual particleShape node).

2. Go down to the "Per Particle (Array) Attributes" section.

3. Click on "General" (it's in the next little section).

This will let you create a new attribute for the particles.

In the window that pops up, type in the Attribute Name (something like randomPopcorm), keep the Data Type as Float, and change the Attribute Type to "Per Particle (Array)".

4. Click Add.

Now if you look back in the Attribute Editor there should be a new attribute called randomPopcorn (or whatever) in the list.

Ok, now you have an attribute, but it doesn't do anything or have a value. So right click in the slot next to it and choose "Creation Expression".

You have to write a very simple creation expression that will give this attribute a random value. You may have noticed that in the list of instanced objects, each object listed has an index number in front of it, (the first object's index is 0 though, not 1). So if you have 5 objects instanced, the indicies (no idea how to spell that ) go from 0 to 4. Get it?

So anway, you need the attribute to give you a random number from 0 to 4 (if there are only 5 objects). This expression will do that:

particleShape1.randomPopcorn = rand(0,4);

So type that expression in (but substitute anything that needs to be changed) and click the "Create" button.

Still with me? Now for the last easy steps:

1. In the Attribute Editor still, scroll up to and open the "Instancer (Geometry Replacement)" section.

2. Tick the "Allow All Data Types" check box.

3. Find the "ObjectIndex" dropdown and change it from "None" to our new attribute "randomPopcorn".

And that's it!!! You should be able to rewind then play your scene and it will randomly emit the different popcorn objects.

Ok, I hope that wasn't too complicated because I actually just copy/pasted those instructions from another thread where I had already explained the steps to go through (it was about cars though).

modi
07-29-2003, 07:46 PM
wow, thank u, that took me a while to figure out but it seems to work. I'll post an avi soon. Cheers.

modi
07-29-2003, 08:08 PM
k i did run into a problem, i did all the steps u told me for instancing but when i do, my popcorn is not filling in the bowl but it starts to fall from an arbitrary point and also they fall very mechanically, i.e no rotations all the same size(scale). I wanna be able to just replace all those spheres with the popcorn,(diff sizes and rotations) Is this possible. Thank u for ur help again.

Jozvex
07-30-2003, 12:19 AM
Hmm, I don't know why it would be emitting from a different place now. All we did was attach geometry to the particles...but:

For the scale:

1. Just create another attribute in the same way as with 'randomPopcorn' called randomScale.

2. Right click on the randomScale attribute and choose Creation Expression, enter something like:

particleShape1.randomScale = rand(0.5,3);

Which means the scale will vary from half sized to 3 times the size (change to suit your needs). Don't forget to press Create/Edit after you add in the new expression!

3. Then in the section where you changed the instancer "ObjectIndex" dropdown, change the "Scale" dropdown to "randomScale"

4. Rewind, press play, that's it!

For the rotation:

1. Yes, create another attribute. This time called randomRotation but in the creation options, change the type from being a float to a Per Particle (Array).

2. Right click on the attribute and choose Creation Expression.

3. Enter this as the expression:

particleShape1.randomRotation = sphrand(1);

This will generate a random vector to use as a rotation value.

4. Press the Create/Edit button to save it. Then back in the instancer section, select randomRotation from the Rotation dropdown box.

And so now your popcorn should be created with random scaling and rotation!

modi
07-30-2003, 03:02 AM
thank u so much for ur help, i understand each n every step u've siad but heres the problem i'm having

it still is emitting from an arbitrary space. Should i place all 5 of my popcorns in the exact same place my emitter is?

K i tried that, din't work
the pop corn is all over the place, how do i get the popcorn to be in the same place as my spheres. Is this because of the radial feild that it doesn't instance it in the same position? Is there a workaround?

Thanx again.

Jozvex
07-30-2003, 06:27 AM
I don't suppose you could post your scene file for me to look at? You could take out everything except the popcorn if you want.

I really don't know what could be going wrong..

:surprised

modi
07-30-2003, 08:12 AM
Hey Jozvex, thank u for all ur help, i figured it out, when i modelled my popcorns, i used to lattice and i moved the objects by selecting all the vertices. Its kinda like when u make blendshape it calculates by the position of the vertices and not the object itself. Dunno if i made any sense there but i remodelled them and it works fine. Cheers man, n thanx for offering to take a look at my scene, i love this forum , one dosen't need to go to school(for technical issues) with forums like these. Thanx again.

CGTalk Moderation
01-15-2006, 06: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.