The source code for the above demo is included with the library as an example to demonstrate how to use the features.
- stable and fast using verlet integration
- fully templated C++ classes, allows 2D physics or 3D physics (or 4D, or even 11D if you have the right vector classes)
- particles with variable mass, radius, drag, bounce, collision
- springs with variable strength, rest length, force cap, min and max radius of influence
- attractions with variable strength (+ve or -ve), min and max radius of influence
- collision can be enabled/disabled globally or per particle
- particles can be added to ‘collision layers’, only particles on the same layer will collide with each other
- individual collision constraints can be added between two (or more) specific particles
- custom particles (extend ofxMSAParticle and add to the system)
- custom constraints (extend ofxMSAConstraint and add to the system)
- custom force fields (extend ofxMSAParticleUpdater and add to the system)
- custom drawing (extend ofxMSAParticleDrawer and add to the system)
- all ‘setter’ methods return the instance so you can chain them (e.g. myParticle->setMass(1)->setBonuce(0.5)->enableCollision()->makeFree(); )
- super fast inverse square root approximation (attributed to john carmack but originally from Silicon Graphics)
- replay saving and load from disk (temporarily disabled and untested in latest release)
ofxMSAPhysics is an opensource C++ 2D/3D particle/constraint based physics library for openFrameworks 006+ and Cinder. It uses a similar API to the traer.physics library for processing, to make transferring code from processing+traer to openFrameworks or Cinder as painless as possible.
Released under the MIT License
ofxMSAPhysics uses verlet integration and principles found in this article at gamasutra.