Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/esimov/cloth-physics

Desktop application for cloth physics simulation using Gio GUI.
https://github.com/esimov/cloth-physics

cloth cloth-simulation desktop-app gio go golang math physics simulation verlet

Last synced: 16 days ago
JSON representation

Desktop application for cloth physics simulation using Gio GUI.

Awesome Lists containing this project

README

        

# cloth-physics
[![Build](https://github.com/esimov/cloth-physics/actions/workflows/build.yml/badge.svg)](https://github.com/esimov/cloth-physics/actions/workflows/build.yml)
[![License](https://img.shields.io/github/license/esimov/cloth-physics)](./LICENSE)
[![Release](https://img.shields.io/badge/release-v1.0.3-blue.svg)](https://github.com/esimov/cloth-physics/releases/tag/v1.0.3)

**cloth-physics** is a native desktop application for 2D cloth physics simulation implementing [Verlet integration](https://en.wikipedia.org/wiki/Verlet_integration). It's written in [Gio](https://gioui.org), a GUI framework for [Go](https://golang.org/).

It has the following characteristics:
- [x] Possibility to tear up the cloth by applying a mouse pressure on the cloth structure. You can increase the mouse dragging force by pressing and holding the left mouse button. The mouse focus area will change its color depending on the applied force.
- [x] Possibility to make up a hole in the cloth structure by pressing the right mouse button.
- [x] You can change the mouse cloth interaction area by using the scroll button.
- [x] With CTRL-left click you can pin up the cloth stick under the mouse position.

**Note:** In case you want to learn more about the implementation details, here is a detailed article I wrote: https://medium.com/@esimov/2d-cloth-simulation-in-go-using-gio-gui-b3dfe00b7223.

## How to run
Before running the application check the Gio [documentation](https://gioui.org/doc/install) for the system requirements. Install the required dependencies then type the following commands.

```bash
$ git clone https://github.com/esimov/cloth-physics
$ go run ./...
```

Another way is to build the executable yourself then simply run it.

```bash
$ go build ./...
$ cloth-physics
```

If you don't have Go installed on your machine you can run the prebuild binary files from the project [packages](https://github.com/esimov/cloth-physics/packages) page. For convenience if you wish to try the application on a mobile device the **`.apk`** file is also provided in the same packages page.

#### Debugging:
```bash
$ cloth-physics -h

-debug-cpuprofile string
write CPU profile to this file
-debug-frame
debug the Gio frame rates
```

## Supported key bindings:
* F1 - Show/hide the quick help panel
* SPACE - Redraw the cloth
* RIGHT CLICK - Tear the cloth at the mouse position
* SCROLL Up/Down - Increase/decrease the mouse focus area
* CTRL+CLICK - Pin up the cloth on the mouse position
* LEFT CLICK+HOLD - Increase the mouse pressure

## Author
* Endre Simo ([@simo_endre](https://twitter.com/simo_endre))

## License
Copyright © 2023 Endre Simo

This software is distributed under the MIT license. See the [LICENSE](https://github.com/esimov/cloth-physics/blob/master/LICENSE) file for the full license text.