Giter Club home page Giter Club logo

cloth-sim's Introduction


Logo

Cloth-Simulator

A spring-model cloth physics simulator made using C/C++

Report Bug


Preview

demo.mp4

As of 30/12/2021, Cloth-Sim features a cloth mesh importer (in the form of a WaveFront obj file), a cloth mesh exporter, a cloth-sphere and cloth-plane collision simulation with options to apply forces such as angular velocity and a cloth free-fall simulation with options to apply forces such as wind direction

Future Releases

Features that I would like to work towards implementing

  • Adding textures/lighting and face triangulation
  • Improving the spring-model
  • Increasing performance (less load with more springs)
  • More simulation scenarios

Feel free to suggest some in the issues tab!

How

To create a cloth mesh, you simply need an easy WaveFront obj editor so that you can import the obj file. The simplest way is to just create a plane in blender and add equal number of cut loops on both the horizontal and vertical. Export as quads.

Cloth Mesh

The program uses the mass-spring-damper model to model the cloth. In this case, each vertex in the mesh would be considered a mass (particle with a fixed weight). After loading in the cloth mesh, springs are created using adjacent and diagonal connections between the particles as shown in the following diagram.

Spring Model

Then to simulate the cloth, you apply the spring force and gravity to all of the created springs (and additional ones depending on the simulation such as friction or wind)

Force

The parameters that worked for me were

mass = 0.5
ks = 10
kd = 5
g = -0.981

Installation

Linux

Dependencies include OpenGL 4.50, libdl, glfw3, pthread, glm

git clone https://github.com/ranaxdev/Masters/
cd Animation_Simulation/Cloth-Sim
mkdir Release
cd Release
cmake -DCMAKE_BUILD_TYPE=Release ../
make

Windows

I'm currently working on releasing an executable so that you don't have to use cmake to build it on windows

Libraries Used

  • GLAD : OpenGL Loading Library

  • GLM : OpenGL Mathematics

  • GLFW : A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input

  • Dear ImGui : Bloat-free Graphical User interface for C++ with minimal dependencies

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

Contact

S.R. Qaiser - @pitu_dev - [email protected]

Project Link: https://github.com/ranaxdev/Cloth-Sim

cloth-sim's People

Contributors

ranaxdev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.