Giter Site home page Giter Site logo

branc116 / pbdchallange Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 140 KB

Chain of 100 Bodies using web assembly

Home Page: https://ricko.us.to/PBDChallange/

HTML 36.53% C++ 43.08% CMake 9.40% JavaScript 0.67% GLSL 10.32%
pbd wasm webassembly physics-simulation dynamics cpp

pbdchallange's Introduction

PBD challenge

Challenge accepted

I've decided to improve speed of PBD simulation

I've done so by writing small pbd library in c++ and compiling it for web assembly (WASM). Results are "dosta dobri." Implementation in javascript is running on my pc with ~10fps. WASM implementation is running on my pc with ~60fps.

You can test for yourself:

How to build

Prerequisite

  • Linux (I don't think it will work on Windows/Mac (prove me wrong ;]))
  • cmake
  • make
  • git
  • emsdk
  • gml (OpenGL math library)

Build && Run

  • git clone https://github.com/branc116/PBDChallange
  • cd PBDChallange
  • mkdir build
  • cd build
  • cmake ../src
  • cmake-gui
  • Edit variable ADITIONAL such that it's value points to the folder where your glm folder is located.
  • Press configure.
  • Exit cmake-guid
  • make
  • cd .. && serve

Serve is some tool that hosts your current directory on a local http server. I'm using npm install -g serve, but one can use what one wants.

If you don't want to build it yourself, you can just download prebuilt version of wasm and js files

Looking at a simulation

When you are hosting a server, you can go to localhost:5000 and you will see the PBD simulation of 100 boxes connected by joints. You can interact with them by dragging them (It's fun.)

It's is possible to tweek some parameters of the simulation in index.html file.

File descriptions

  • index.html - scene description created by Matthias with slight modification for making it consume wasam.
  • src/Body.cpp - Implementation of body as described in Original paper
  • src/CMakeLists.txt - cmake make file to make c++ make Wasm files.
  • src/Help.cpp - help me i need my head checked functions to help.
  • src/Joint.cpp - Implementation of joint as described in Original paper.
  • src/Pose.cpp - abstraction over position and rotation.
  • src/Simulator.cpp - entry point to the simulator. One can add bodies and joint in to the simulator and take them out. One can run few steps of the simulator.
  • src/Hello.hpp - declatraton of all the classes.
  • src/Hello.idl - some file that defines the surfice of the library that is exposed to the javascript world. This file is used by WEBidl tool to generate glue javascript code.
  • src/onload.js - some javascript (one must have some javascript file in ones repo.)

pbdchallange's People

Contributors

branc116 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.