Git Product home page Git Product logo

ofxbox2d's Introduction

ofxBox2d

ofxBox2d

Introduction

This is a simple wrapper for box2d using Openframeworks. The examples below are still in progressive, but should be stable for the most part. Please open up a issue if you have suggestions or find bugs. The wrapper is using the version Box2D v2.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.

ofxbox2d's People

Contributors

cpietsch avatar cyrildiagne avatar danoli3 avatar danomatika avatar groolot avatar ilektron avatar julapy avatar julianadenauer avatar kylemcdonald avatar mat-loz avatar neilmendoza avatar nickhardeman avatar obviousjim avatar ofzach avatar totalgee avatar vanderlin avatar zlalvani avatar

Watchers

 avatar  avatar

Forkers

kentoids

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.