MSAPhysics
ofxMSAPhysics is an opensource, C++ 3D particle/constraint based physics library for openFrameworks 006+. It uses a very similar api to the traer.physics library for processing to make getting into it as easy as possible.
The source code for the above demo is included with the library as an example to demonstrate how to use the features.
Main features include
- particles
- springs
- attractions (+ve or -ve)
- collision
- replay saving and load from disk (temporarily disabled in current alpha release)
- 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)
ofxMSAPhysics requires my ofxObjCPointer v1.1+ addon which makes memory management easier. It does not require ofxVectorMath anymore as the required functionality is now in the new OF core. You can download ofxMSAPhysics from here.
List of new features (from changelog):
- a lot of new files in this one, so you'll need to remove and re-add it to your project
- no longer requires ofxVectorMath
- attractors fully implemented
- collision (between particles) fully implemented
- you can enable/disable collision per particle, and it will collide with all other particles which have collisin enabled
- AND/OR you can globally enable or disable collision
- AND/OR you can manually create a collision constraint between any 2 (or more) specific particles
- you can set world dimenensions for optimized collision (using Zach L.'s binning code) and particle world edge collision
- particles have individual drag
- particles have individual bounce (for collision)
- particles have individual size (for collision and rendering)
- all 'setter' methods return the instance so you can chain them (e.g. myParticle->setMass(1)->setBonuce(0.5)->enableCollision()->makeFree(); )
- replay functionality temporarily disabled while I fix stuff
- intense testing of memory management so should be stable as a rock, lemme know if you see anything weird (turn verbose on to see whats going on)
- using the super fast inverse square root approximation (attributed to john carmack but originally from Silicon Graphics)
- lots of internal restructing and optimization
ofxMSAPhysics uses verlet integration and principles found in this article at gamasutra and binning code for collision optimization from Zach Lieberman.