*Copyright 2007-2023. Algoryx Simulation AB.*

# Simulation of flexible bags

#### Disclaimer

This project is a prototype for simulating flexible objects such as polybags. This model is a work in progress and will not be supported in the future.
The purpose of this model is for evaluation only. See LICENSE.TXT


## Limitations
Currently the dimensions (length, width, height) of a polybag is quite limited. We have only tested with the current scenario. We know that making the size in Length < Width will generate invalid geometries, causing the simulation to behave bad.

We know that using thin meshes will cause problems due to very small volumes for collision geometries.

There is no plasticity for this model.

## Source code
All source code can be found in the directory AGXUnity_Polybag_Assets\Scripts:

### Polybag.cs
Implementation of a flexible object using lumped element modelling.
The bag consists of a set of rigid bodies, collision shapes and 6DOF-constraints (LockJoint)
The flexibility is controlled using compliance on the constraints.
Plasticity is currently not part of the model meaning that the bags will always strive towards restoring its original shape.

Polybags has a number of parameters:

- **resolution** - Specifies the resolution of the model. Keep this at LOW for now. It has a large effect on performance as a higher resolution will create more rigid bodies, shapes and constraints.

- **length** - Specifies the length of the bag (m)
- **width** - Specifies the width of the bag (m)
- **height** - Specifies the height of the bag (m)
- **compressibility** - Higher value indicates a softer bag in the compression aspect.
- **bendability** - Higher value indicates a softer bag in terms of bending.
- **mass** - Total mass of the bag (kg)
- **renderMaterial** - The render material used for the polybag
- **material**  - The physical shape material.
- **polybagMesh** - The 3D mesh asset that should define the bag.
- **useContactReduction** - If true, a contact reduction will be performed between the bag and other objects. For other friction model solvers than ITERATIVE this can have a huge positive performance impact.


### PolybagEmitter.cs
This class emits bags with a specified interval.

### ObjectSink.cs
Example of a polybag sink that will destroy any polybag that is in contact with a shape associated with this Component.

### SurfaceVelocity.cs
Example of how to simulate a conveyorbelt using Shape surface velocity.
This is also tightly connected to the texture which is applied to the associated visual shape.

### DeformerSingleton.cs
This class manages the existance of a agxUtil.ParallelTrimeshDeformer that is responsible of accelerating the simulation of polybags using multithreading.

