Reputation: 6874
I need to get the list of co-ordinates for my box2d world- I'm trying to get a wrap around effect so that particles that go off the side of the screen appear on the opposite side. box2d is not well documented for Processing and the only example I could find was in java (I know its the parent language but it needs translating). This is here.
I think the action is here:
private function updateWorld(e:Event):void {
world.Step(1/30,10,10);
world.ClearForces();
for (var b:b2Body=world.GetBodyList(); b; b=b.GetNext()) {
if (b.GetType()==b2Body.b2_dynamicBody) {
if (b.GetJointList()==null) {
if (b.GetPosition().x*worldScale>640) {
b.SetPosition(new b2Vec2(0,b.GetPosition().y));
}
if (b.GetPosition().x*worldScale<0) {
b.SetPosition(new b2Vec2(640/worldScale,b.GetPosition().y));
}
}
}
}
world.DrawDebugData();
}
So I have tried translating this although I get stuck at the point of world.GetBodyList
I assume world is the instantiated box2d world I have created. I that is so, Processing doesn't seem to recognise this. Basically how to I just get an array of all the particle co-ordinates. Should be easier....
Upvotes: 0
Views: 698
Reputation: 42176
Anything you can do in Java, you can do in Processing. But the code you posted is not Java. It's C++. (Edit: George pointed out that it looks like ActionScript. Either way, it's not Java!)
You don't need to use these libraries in order to use JBox2D from Processing.
You can find the documentation for JBox2D here.
To answer your question, yes, the world
variable would be the instance of World
you created when you set up your physics environment.
If you're using one of the Processing libraries, the creation of the World
instance might be hidden from you. You might have to use JBox2D directly yourself.
Upvotes: 1