cloth-physics
cloth-physics is a native desktop application for 2D cloth physics simulation implementing Verlet integration. It's written in Gio, a GUI framework for Go.
It has the following characteristics:
- 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.
- Possibility to make up a hole in the cloth structure by pressing the right mouse button.
- You can change the mouse cloth interaction area by using the scroll button.
- 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 details of how it was implemented, there is a detailed article I wrote here: https://medium.com/@esimov/2d-cloth-simulation-in-go-using-gio-gui-b3dfe00b7223.
How to run
Before running the application check the Gio documentation for the system requirements. Install the required dependencies then type the following commands.
$ git clone https://github.com/esimov/cloth-physics
$ go run ./...
Another way is to build the executable yourself then simply run it.
$ 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 page.
Debugging:
$ cloth-physics -h
-debug-cpuprofile string
write CPU profile to this file
-debug-frame
debug the Gio frame rates
Supported key bindings:
- SPACE - Reset the cloth to the default values
- RIGHT CLICK - Make a hole in the cloth structure
- SCROLL - Increase/decrease the mouse focus area
- CTRL+CLICK - Pin up a cloth stick
- LEFT CLICK+HOLD - Increase the mouse pressure
Author
License
Copyright © 2023 Endre Simo
This software is distributed under the MIT license. See the LICENSE file for the full license text.