Fill volume with objects

Yes, this question has quite a few posts already, but they look to be between 2005 and 20011, so a lot has changed.

Really I want to fill a container with objects. It would be nice if they were random objects from a collection, which leads you to particles for sure. But running the physics simulation takes Forever. It’s also overkill. I don’t want things to bounce. All I want to do is fill the volume without the objects intersecting. So I wondered if there was another tool for it that might do a bit better. And to fill an object for the purpose of visually looking like it’s filled? Well, really I’d want to start on the outside right? So if you’re filling a container will jellybeans to make it Look full like that old trick to guess how many jelly beans are in the container, you don’t actually need it to be full. I almost just want to shoot a random object from my collection, with slight random scale (optional) until it hits a surface. Then adjust the angle a little until it doesn’t collide with the first object and repeat until the entire surface is covered. Then treat all of those as the “surface” and repeat.

I’m sure there would be better/more efficient ways of doing it, but i was curious if there was a tool that did something like that.
Or maybe it’s just selecting all the objects, but it drops the objects one at a time instead of all together, which is Way too much calculation for what is needed. Unless the objects Lock together, then it’s much faster to calculate one object falling, then change that object to a passive object once it’s position/rotation only change a certain amount, then calculate the next, until all objects are complete.
I actually wonder if That one could be scripted.

So these are just some ideas that come to mind. The only things I’ve found that work ok are for balls, which have good ways of “cheating.” So lets, for arguments sake, say I’m filling a container with bowtie, elbow, and spiral pasta.

Any good ideas?

I am interested to know if you found an answer to your question?

Well, still nothing that is Amazing, but I did find quite a few things. And the main thing is Scale. You don’t just need to have units correct. So here is what I learned.

  1. Simulations for small objects, nobody out there seems to tell you that setting the unit scale is Absolutely necessary. If you change the units to millimeters, make a 2mm cube (default cube) it’ll work ok…because it’s a cube. Sphere’s also work ok. But Really you would also need to set the units scale to .001. Default blender unit is meters. So inches, you have to set it to .0254.
    But notice that once you set it to .001 you’re 2mm cube is now .002mm.
    The short of it is, either set that Right away, or you’ll have to go back and scale everything back up. But if you used modifiers then that can get difficult to find everything. So try and think ahead. Small objects, set to mm. Large, leave at meters, Giant…well, what the hell, are you filling the ocean with something? Anyway, you get the idea.

  2. drop it is an Awesome addon. It’s not a terrible idea to use drop it to “manually” place much of the first layer of objects.

  3. MassFX is also an awesome addon, but not free. It’s similar to drop it, but you basically “paint” with particles. You’re still at the mercy of physics simulations but you get to fill your object a little at a time. As soon as you let go, those objects switch to rigid body for the simulation. In theory, this is Exactly what I needed. But it’s still pretty tricky.

  4. not there quite yet, but looks like it might be coming, is geometry nodes. You can arrange things on a surface. They are working on filling volumes. And it sounds like they are working on a node(s) related to checking for intersection/collision. The few times I tried out some things on my own, they didn’t go super great, but it was in the early stages. Keep an eye out for geometry nodes. If they let you fill a volume using the same kind of distribution they use for a surface, and add in checks for intersection, it won’t be all that hard to create a node to fill any closed volume with objects that don’t intersect, even if it’s just kind of a brute force method where you tell it how dense to fill the volume, then you tell it to try putting one of your random objects on a point at a random rotation, if intersects, try a certain number of other random rotations, then move to the next point. If nothing else, that would start you off with the thing loosely filled with your objects, use drop it on each of those, then just fill the rest.

If simulation was slow, but just Worked, then it won’t be all that bad. But I’ve found that drop it is faster in a bunch of situations. The downside is that it only drops Down. So you have to rotate your entire object if you are trying to fill something a bit more complex.

I’ll try and remember to post back if I learn anything more, but I probably won’t be attempting that again for a while, unless a job comes up and someone wants me to fill it with objects again.

Thank you! MassFX looks very interesting indeed. If you go to https://gumroad.com/l/hHuFj
it is only $5.
Paul

Well son of a gun. I definitely paid 10 or 15 on blender market. I like to keep all the purchases in gumroad if I can because it’s Usually cheaper there, and I think the developers might get a better cut? Not sure actually, I suppose I should find out.
Either way, I’m glad to support people when I can. And 15 or less is an easy amount to do that. It’s tougher when it’s something like 50-100 bucks. I have to Really know that it’s going to improve my life. A couple I’ve purchased near there I somewhat regret because I don’t use them enough to actually build a workflow, and they are Super complex. If you don’t use them how they intended, they aren’t as useful.

Keep watching out for geometry nodes though. In most cases, you could use something like massFX or DropIt (free on gumroad) to put objects on the side of your object. Then you could use geometry nodes to fill an offset version of your object for objects in the center. Those ones will overlap, for now, but wouldn’t be as important since they would be in the middle…unless you’re objects are transparent.
I’m really hoping to be able to fill objects with geometry nodes entirely, using either a repulsion method of some sort, or collision detection. That would be Pretty complex if you’re filling something with a couple thousand objects or more, but if you know it’s going to work right then it’s Definitely worth waiting a few minutes for it to calculate.

I am guessing the objects in massFX and DropIt have to be low-poly. Is that correct?

They don’t Have to be, but just like any simulation, a low poly collision object will calculate faster. DropIt really doesn’t matter though, for the most part. It just moves in one direction until it reaches a collision.

I had a pretty high polygon object, and what I did was use low poly object in my collection to do the simulation. Those are all instanced objects. So then I just replaced the data of those objects with the high resolutions ones after I was finished. That let me have good control over the collision objects without having to settle on the default shrinkwrap methods simulation uses while still having low polygon collision objects.
I did try it with the high resolution objects as well though, and it wasn’t All that slow. My machine is from 2016, and it’s a laptop, so if you have something more current good processor then it may not even be necessary. Remember that simulations are currently single thread, so a faster processor with less threads is a better choice for those that do a lot of simulations. Where for rendering more threads is nearly always better.

Hi, I installed massFX and then before I could work out how to use it, I promptly uninstalled it. I use Python with Blender (from the command line) and there are some errors and warnings that come up with the add-on even when I am doing something completely different.
For example: Warning: ‘MassFX_PT_Panel’ doesn’t have upper case alpha-numeric prefix

But anyway, I have found out that my problem is not with the active objects. It is with the passive object. I didn’t expect that. So now I am looking at normals, etc. to see why the objects are flying off when they tough the passive object. Have you had this problem?

Yes, I’ve had that, and unfortunately it could be for various reasons. The biggest one is scale.
Realistically, you have better luck with Giant objects. If you notice nearly every tutorial dealing with physics out there is doing a simulation of something that looks relatively small, but then you see them creating nearly default spheres straight from the default scene, meaning those are 2 meters in diameter? Maybe 1, I can’t remember. Anyway, their scenes are Huge.

So first, make a test scene, and keep it big like that. If you’re happy with the results, create a new scene that you intend to use, keeping the scale of your scene in mind. Lets say you’re using inches now, and filling a vase with those silly looking flattened decorative marble things. Before you do anything, set your units to inches AND set your unit scale to .0254. If you set the unit scale after you have objects, you’ll notice it doesn’t seem that anything changed, but if you look at the scale of your objects, they are now tiny. Based on what I saw in the manual, that seems like a mistake/bug (depending on how you define bug). But what really sucks there is, if you already have collision objects, objects with modifiers, etc, then it’s more than just the scale of your units that need to be scaled back up.
Hey, if you’re handy with python, that would be a really slick add-on. Change the unit scale, and automatically change the scale of everything else inversely.

Anyway, I’d tests with files you make yourself, but don’t use spheres or cubes. Make sure the objects are really simple, but odd shaped.

About MassFX errors. Well, I don’t know enough about programming. I’m not even quite sure what you mean by using blender from command line. I thought the only real reason to do that was submitting renderings, large simulation, or other batch files of some sort. MassFX has a GUI which requires user interaction. I probably misunderstood there, but wanted to explain my confusion. If there’s something wrong with it though, please report it so the developer is aware.

I’ll take the giant objects on board. Good tip!

I do not use units. I set them to None and there does not seem to be any relationship between units and Physics but I get your point that what I think is a large object might have ‘shrunk’.

Please will you expand on this comment?

Anyway, I’d tests with files you make yourself, but don’t use spheres or cubes. Make sure the objects are really simple, but odd shaped.

Why not cubes? Why ‘odd shaped’?

Yes, massFX has a GUI but it is Python code and because it breaks some rules, it shoots up alerts when I am doing any Python. I use Python from the command line because I can set everything up once and just tweak the code to change thousands of objects. I can also print values of different settings to see what is going on. I go from the command line because it is quicker than copying and pasting the code into Blender.

I do small tests in the GUI before I write the code and have everything working now, except the collisions are too boring. Objects fall, hit the passive object and more or less stop. So, I need some rotation or other dynamics to get more action. Any ideas?

Paul

Well MassFX isn’t an animation or physics tool really? Yes, it uses physics, but only because that’s the most readily available tool to drop things randomly and use collisions. I would actually prefer they don’t bounce at All. I’m just looking to plop the object down.
Really, if I could program things, I’d have it shoot random objects from my collection one at a time, but with some randomness in the shooting angle as well so the objects are always in a different spot. Each ‘particle’ would continue on until it made any collision, which will likely be with a single vertex right? The 'particle’s pivot point then changes to that and it start to rotate until another vertex touches another object. Then the pivot changes again, using that as an axis, and rotating now on that axis until another point touches. That Should be super “cheap” collision calculations being kept to a minimum, but would make for a pretty darn fast way to fill objects. Just set the rate at which you want the objects to come out, and just point the emitter where you want to start kind of “painting” your objects.
Really similar to MassFX, but wouldn’t even use physics. The obvious downside are you are responsible to avoid empty pockets on your own. Physics, those would constantly collapse.

Anyway, why not cubes or spheres? Because those have default their own defined collision objects already to be extremely efficient. They work great. Do the exact same thing with something that is a more real-world object, and it starts failing.

Also, using units, none is just using units=meters. As soon as they added physical attributes, the developers had to use it to base other attributes off of. Gravity, as an example is set to 9.8units/s^2. So obviously meters then right? Light, materials, etc all have similar settings. If you change from none units, to something else, it converts it from meters.

Units doesn’t make a difference in physics simulations, but decimal points do. So you have to set your scene scale whatever unit you are using for your objects, which will be based off of meters. It’s best to set that up before you start modeling/importing. So if your objects are mostly between 1-10cm, then it’s likely you should be using cm as your scale, so your unit scale should be .01. If you’re using inches, really it should be .0254. Mostly it moves the decimal so that every calculation doesn’t have to be something like .0000054987749111, rather than 5.4987749111468178. At some point it truncates the number lengths, causing an increased number of errors, many of which cause objects to collide when they aren’t, or just travel right through another object at high speed.
That’s how it was explained to me at least, and that seems to make sense based on what I’ve experienced.

But also, my object bounce pretty well. So if you’re saying they are boring, perhaps it’s because you aren’t using units, but Are? Since the none units is actually meters, if you make a grape, which is what, 3x1.5cm? But you didn’t have units, so it’s 3x1.5meters instead. So interactions will be somewhat dull, because they are Giant.

Thanks! I am at the modelling stage now and will get to the Physics next step so I will take what you say on board then. I have solved the problem somewhat by having invisible colliders in the path of the falling objects that set up rotations. This makes everything more interesting.
It seems my gap in knowledge is units and scale so I will use your notes when I set this up. So, thank you!

I don’t Quite know what you mean by the rotations. You can set up random rotations with a random phase as well. These are basically the same settings you find in particles. Random phase sets the initial position of each “particle” to a random rotation. Then if you want them to actually have rotation velocity, set the random rotation as well.

It sounds like you’re making sure they collide with something prior to getting into your container, but that sounds more complicated. Sorry if I didn’t understand, but it Sounded like that’s what you were getting at.

You are absolutely right. But I know nothing about random rotations, please tell me more.

You can set up random rotations with a random phase as well.
What is this random phase???
Thanks,
Paul

Well after further testing, I think the developer maybe didn’t get the setting correct.
Basically what he’s done here is used a particle system to emit the objects, temporarily. Upon completion it takes all those objects just created from active to passive objects.

Normally, for particle systems, you can set initial rotation phase to random, which is the rotation it starts at when it is created, as well as a random rotation amount so that the particle itself is rotating upon creation, without a need to collide it with anything.

Of course, as this tool is only for positioning the objects, that should be fine. You aren’t capturing this as an animation. So do the objects really need to spin as they fall?

But if you want to anyway, In the brush tab, just adjust the randomize value under the rotation settings:
It might be best also to change the default rotation method to something else. The default isn’t very noticeable.

One thing I really don’t like about the tool is the brush. Its perfect if you want to emit 1 at a time. But the emitter size is too small for anything I tried. So I had to make a custom brush, make sure the origin is below that emitter.

Because it’s so small, you almost Always have to enable the “Split Impulse” option because the objects start already intersecting. This causes them to immediately repel eachother with a really high velocity, which of course causes errors. But if you create a brush big enough to encapsulate all of your objects then you can turn that off, which makes things a bit faster (but not much).
The thing that makes this fast is doing just a few at a time.