Skip to content
Openframework wrapper for box2d
C++ C Other
Find file
Latest commit 4ff6400 Apr 17, 2016 @kylemcdonald kylemcdonald Merge pull request #105 from danomatika/master
updates for latest OF & a few bug fixes
Failed to load latest commit information.
example-Bodies small whitespace fix Apr 5, 2016
example-ComplexPolygon updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-ContactListener updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-CustomData updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-EdgeShape updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-Edges updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-Forces updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-Joint updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-Performance updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-ShapeTexturing updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-Simple updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-TwoWorlds updated all examples: renamed testApp to ofApp, deprecation fixes for… Apr 5, 2016
example-iOS whitespace formatting fix Apr 5, 2016
libs merged, removed static_assert Apr 12, 2015
src added body getWorldPosition(), fixes #99 Apr 5, 2016
.gitignore reorganzied/renamed folder structure to follow ofxAddonTemplate, ofxB… Aug 12, 2012
License.txt Required License and Updated Readme Jul 10, 2013
README.md small readme formatting updates Apr 5, 2016
addon_config.mk don't need explicit ios libs include Apr 5, 2016
ofxaddons_thumbnail.png added (temporary) ofxaddons.com thumbnail for upcoming v2 Aug 13, 2013

README.md

ofxBox2d

ofxBox2d

Introduction

This is a simple wrapper for Box2d using Openframeworks. The examples below are still in progress, but should be stable for the most part. Please open up a issue if you have suggestions or find bugs. The wrapper is using Box2d version 2.3.

Thanks, Todd

Instructions

When making a vector of objects you need to be careful. You either need to make a vector of pointers of use the shared_ptr object.

Everytime you push into the vector circles the object is destroyed and the created. This causing issues for the b2dBody body object owned by Box2d.

Incorrect way to store objects.

vector <ofxBox2dCircle> circles;
ofxBox2dCircle circle;
circles.push_back(circle);

Here is the how to create a vector of Box2d objects.

// in your header files
vector <shared_ptr<ofxBox2dCircle> > circles;

// now add a circle to the vector
shared_ptr<ofxBox2dCircle> circle = shared_ptr<ofxBox2dCircle>(new ofxBox2dCircle);

// to grab the pointer you use the get() function of shared_ptr (std::shared_ptr)
circle.get()->setPhysics(3.0, 0.53, 0.1);
circle.get()->setup(box2d.getWorld(), 100, 100, 10);
circles.push_back(circle);

Installation

Place ofxBox2d within a folder in the apps folder of the OF dir tree:

openframeworks/addons/ofxBox2d

Compatibility

The master branch is compatible with the current release of openFrameworks, and the develop branch tries to stay up to date with openFrameworks on GitHub.

Something went wrong with that request. Please try again.