Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattatz/unity-verlet-simulator
Simple verlet integration simulator for Unity.
https://github.com/mattatz/unity-verlet-simulator
Last synced: 1 day ago
JSON representation
Simple verlet integration simulator for Unity.
- Host: GitHub
- URL: https://github.com/mattatz/unity-verlet-simulator
- Owner: mattatz
- License: mit
- Created: 2017-09-25T10:51:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-23T01:20:12.000Z (over 5 years ago)
- Last Synced: 2024-10-31T16:58:19.325Z (8 days ago)
- Language: C#
- Size: 46.1 MB
- Stars: 260
- Watchers: 17
- Forks: 38
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-unity-open-source-on-github - unity-verlet-simulator - Simple verlet integration simulator (Physics)
README
unity-verlet-simulator
=====================GPU-based simple verlet integration simulator for Unity.
![Tentacles](https://raw.githubusercontent.com/mattatz/unity-verlet-simulator/master/Captures/Tentacles.gif)
![GPUChainDemo](https://raw.githubusercontent.com/mattatz/unity-verlet-simulator/master/Captures/GPUChainDemo.gif)
![GPUClothDemo](https://raw.githubusercontent.com/mattatz/unity-verlet-simulator/master/Captures/GPUClothDemo.gif)
## Usage (chain structure example)
```cs
[SerializeField] ComputeShader compute; // GPUVerletSimulator.compute
GPUVerletSimulator simulator;void Start() {
const float edgeLength = 0.5f;// define nodes and edges.
var nodes = new GPUNode[nodesCount];
for(int i = 0; i < nodesCount; i++)
{
var n = nodes[i];
var p = new Vector3(Random.value - 0.5f, i * edgeLength, Random.value - 0.5f);
n.position = n.prev = p;
n.decay = 1f;
nodes[i] = n;
}var edgesCount = nodesCount - 1;
var edges = new GPUEdge[edgesCount];
for(int i = 0; i < edgesCount; i++)
{
var e = edges[i];
e.a = i;
e.b = i + 1;
e.length = edgeLength;
edges[i] = e;
}// create simulator instance.
simulator = new GPUVerletSimulator(nodes, edges);
}void Update() {
const int iterations = 8;// simulate
simulator.Step(compute);
for(int i = 0; i < iterations; i++)
{
simulator.Solve(compute);
}
}```
## Sources
- Advanced Character Physics - http://web.archive.org/web/20080410171619/http://www.teknikus.dk/tj/gdc2001.htm
## Compatibility
tested on Unity 2018.2.4f, windows10 (GTX 1060).