Hello everybody!
I am working on porting jbox2d to c# and I want to check, if results are correct and are identical to Java version.
It already compiles and code runs.
I don't have Jbox2d testbed compiled, so can anybody run this code and give me output?
You can see my port here https://github.com/gerich-home/box2dnet
I am working on porting jbox2d to c# and I want to check, if results are correct and are identical to Java version.
It already compiles and code runs.
I don't have Jbox2d testbed compiled, so can anybody run this code and give me output?
Code:
// Static Body
Vec2 gravity = new Vec2(0,-10);
boolean doSleep = true;
World world = new World(gravity,doSleep);
BodyDef groundBodyDef = new BodyDef();
groundBodyDef.position.set(0, -10);
Body groundBody = world.createBody(groundBodyDef);
PolygonShape groundBox = new PolygonShape();
groundBox.setAsBox(50,10);
groundBody.createFixture(groundBox, 0);
// Dynamic Body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DYNAMIC;
bodyDef.position.set(0, 4);
Body body = world.createBody(bodyDef);
PolygonShape dynamicBox = new PolygonShape();
dynamicBox.setAsBox(1, 1);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = dynamicBox;
fixtureDef.density=1;
fixtureDef.friction=0.3f;
body.createFixture(fixtureDef);
// Setup world
float timeStep = 1.0f/60.0f;
int velocityIterations = 6;
int positionIterations = 2;
// Run loop
for (int i = 0; i < 60; ++i)
{
world.step(timeStep, velocityIterations, positionIterations);
Vec2 position = body.getPosition();
float angle = body.getAngle();
System.out.printf("%f %f %f\n", position.x, position.y, angle);
}
Vec2 gravity = new Vec2(0,-10);
boolean doSleep = true;
World world = new World(gravity,doSleep);
BodyDef groundBodyDef = new BodyDef();
groundBodyDef.position.set(0, -10);
Body groundBody = world.createBody(groundBodyDef);
PolygonShape groundBox = new PolygonShape();
groundBox.setAsBox(50,10);
groundBody.createFixture(groundBox, 0);
// Dynamic Body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DYNAMIC;
bodyDef.position.set(0, 4);
Body body = world.createBody(bodyDef);
PolygonShape dynamicBox = new PolygonShape();
dynamicBox.setAsBox(1, 1);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = dynamicBox;
fixtureDef.density=1;
fixtureDef.friction=0.3f;
body.createFixture(fixtureDef);
// Setup world
float timeStep = 1.0f/60.0f;
int velocityIterations = 6;
int positionIterations = 2;
// Run loop
for (int i = 0; i < 60; ++i)
{
world.step(timeStep, velocityIterations, positionIterations);
Vec2 position = body.getPosition();
float angle = body.getAngle();
System.out.printf("%f %f %f\n", position.x, position.y, angle);
}
You can see my port here https://github.com/gerich-home/box2dnet