Some times during the modelling process the problem of filling some volume with number of items occurs. For example it may be a jar with coffee grains, sugar bowl with pieces of sugar, bag of jewels, box with screws and nuts, a bowl of candy, and many others.
All this can be made manually. Creating some copys of items and filling voulume with arranging them in a random order. However this approach much time and efforts to control that the items do not overlap with each other and with the walls of the filled object. To simplify our work we can use the Rigid Body tool – solid-state simulation in Blender.
For a start we have a jar and a few items to fill it:
- Place items above the bank neck, so that they do not overlap.
- Multiply them to amount necessary for filling:
- Add the Array modifier to each item.
- Set:
- Relative Offset
- X = 0
- Z = 4 – set the value that each item copy can rotates without intersections with other copyes and other objects.
- Set the amount needed to fill the required volume:
- Count = 40
- Relative Offset
- Set:
- Add the Array modifier to each item.
- Apply Array modifier for all three objects.
After applying Array modifier item copys are merged into a single mesh. It is necessary to divide them into separate meshes: in edit mode break all vertexes by closed profiles.
- For each set of items copyes:
- tab
- p – By Loose Parts
- tab
Each of the divided objects origin remains in the same place – on the first object from which array begins. Place origins to items geometric center.
- Select all filling objects.
- In the T-bar
- Tool
- Transform
- Set Origin
- Select Origin To Center Of Mass
- Set Origin
- Transform
- Tool
- In the T-bar
To make some initial chaotic lets slightly rotate items:
- All items should be selected.
- Select in the menu:
- Object – Transform – Randomize Transform
- In the T-bar set the range within the items can be rotated with random angle:
- Randomize Rotation
- X = 90
- Y = 90
- Z = 90
- Randomize Rotation
- Select in the menu:
It remains to solidfy all the objects in scene. During the simulation, copyed items will fall into the jar, so set them the active solid status. The jar does not move and is an obstacle for active bodies – set the passive solid status to it.
- For items:
- All of them should be selected.
- In the T-bar
- Physics
- Rigid Body Tools
- Add / Remove
- Add Active
- Add / Remove
- Rigid Body Tools
- Physics
- In the T-bar
- All of them should be selected.
- Select the jar
- In the T-bar
- Physics
- Rigid Body Tools
- Add / Remove
- Add Passive
- Add / Remove
- Rigid Body Tools
- Physics
- In the T-bar
All is ready, start simulation.
- Open TimeLine window and press Play animation.
If all the objects, the jar and filling items, are too small (measured in centimeters), simulation can reckons with errors – filling items will fall through the jar walls. In this case, scale all objects, increase them by 10 times, run simulation, and decrease them back by 10 times.
After simulation finish all items will be backfilled into the jar. For more uniform items mixing you can vary locations and rotation angles of items above the jar neck.
To save the position of items after the simulation and leave the timeline:
- In the T-bar
- Physics
- Rigid Body Tools
- click Apply Transformation
- Physics