vanderlin / ofxBox2d

Openframework wrapper for box2d
zlib License
320 stars 122 forks source link

Missing / erroneous GetWorldCenter() #99

Closed chrisAbyi closed 8 years ago

chrisAbyi commented 8 years ago

I'm using the ofxBox2d plugin in of 0.9 for my physics. As a start, I want a cube to jump. Without any additional velocities applied, this should result in a movement on the vertical axis.

My objects' physics: box.setPhysics(10,0,0);

The impulse used for jumping: box.addImpulseForce(ofVec2f(0,-5), box.getPosition());

Unfortunately, the impulse doesn't seem to be applied at the object's centre of mass, resulting in a crazy rotation. On http://www.iforce2d.net/b2dtut/jumping2 , it says to pass box.GetWorldCenter() as a second argument, but this is not available in ofxBox2d. I tried to fetch this information from box.body->getWorldCentre(), but these values are not very helpful.

This question is also in the OF forums: http://forum.openframeworks.cc/t/why-does-my-vertical-impulse-in-ofxbox2d-results-in-rotation/21327