Binary marble adding machine

Hi,

I modeled Matthias Wandel's (http://woodgears.ca/marbleadd/) binary marble adding machine with Mekanimo (uses Box2D).

You can see the details at http://mekanimo.net/tutorial/binary-marble-adder/.
I am displaying some animations from the page.

Image

Image

Image

Image


Do you guys think automatically generating C++ code of the model from Mekanimo would be any use?

Regards,

Fahri
That's pretty awesome. I'd love to see an example like that in the testbed...
F.B. wrote:
Do you guys think automatically generating C++ code of the model from Mekanimo would be any use?
For testbed examples maybe? Or for level creation in games? I guess it would.
Daid wrote:
F.B. wrote:
Do you guys think automatically generating C++ code of the model from Mekanimo would be any use?
For testbed examples maybe? Or for level creation in games? I guess it would.

I will try to add this feature to the next version then.
I think, this is a really cool box2d-cad-editor. 🙂)

Adding C++ (or/and Java / Flash) source output ? Yes, would be great.


saludos, nimodo
ewjordan wrote:
That's pretty awesome. I'd love to see an example like that in the testbed...


This is my first try of the auto code generation from Mekanimo. My C++ is pretty rusty, so let
me know if there is anything wrong with this code.

//Auto-generated by Mekanimo (http://www.mekanimo.net) on Thu Nov 13 17:53:34 2008

b2Body* ground = m_world->GetGroundBody();
b2BodyDef bodyDef;
b2Vec2 initVel;
b2PolygonDef shapeDef;
b2CircleDef circleDef;

b2DistanceJointDef jointDef;
b2RevoluteJointDef revJointDef;
b2Vec2 pos;


//Polygons
//flip_flop1
bodyDef.position.Set(26.516073f, 27.478506f);
bodyDef.angle = 0.377903f;
b2Body* flip_flop1 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
flip_flop1->SetLinearVelocity(initVel);
flip_flop1->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 6;
shapeDef.vertices[0].Set(15.000000f, 2.333333f);
shapeDef.vertices[1].Set(-15.000000f, 2.333333f);
shapeDef.vertices[2].Set(-15.000000f, -0.166667f);
shapeDef.vertices[3].Set(-2.500000f, -5.166667f);
shapeDef.vertices[4].Set(2.500000f, -5.166667f);
shapeDef.vertices[5].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
flip_flop1->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(5.000000f, 2.333333f);
shapeDef.vertices[1].Set(0.000000f, 7.333333f);
shapeDef.vertices[2].Set(-5.000000f, 2.333333f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
flip_flop1->CreateShape(&shapeDef);

flip_flop1->SetMassFromShapes();

//retainer1
bodyDef.position.Set(29.152931f, 8.750000f);
bodyDef.angle = 0.000000f;
b2Body* retainer1 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
retainer1->SetLinearVelocity(initVel);
retainer1->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-2.902930f, -2.500000f);
shapeDef.vertices[1].Set(-6.652930f, -3.750000f);
shapeDef.vertices[2].Set(-6.652930f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer1->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-6.652930f, 3.750000f);
shapeDef.vertices[1].Set(-2.902930f, 2.500000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.vertices[3].Set(-6.652930f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer1->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-1.652930f, -1.250000f);
shapeDef.vertices[1].Set(-2.902930f, -2.500000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer1->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.652930f, 1.250000f);
shapeDef.vertices[1].Set(-1.652930f, -1.250000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer1->CreateShape(&shapeDef);

//Partition 4
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-2.902930f, 2.500000f);
shapeDef.vertices[1].Set(-1.652930f, 1.250000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer1->CreateShape(&shapeDef);

//grounded
//retainer1->SetMassFromShapes();

//retainer2
bodyDef.position.Set(54.152931f, 26.250000f);
bodyDef.angle = 0.000000f;
b2Body* retainer2 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
retainer2->SetLinearVelocity(initVel);
retainer2->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-2.902930f, -2.500000f);
shapeDef.vertices[1].Set(-6.652930f, -3.750000f);
shapeDef.vertices[2].Set(-6.652930f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer2->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-6.652930f, 3.750000f);
shapeDef.vertices[1].Set(-2.902930f, 2.500000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.vertices[3].Set(-6.652930f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer2->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-1.652930f, -1.250000f);
shapeDef.vertices[1].Set(-2.902930f, -2.500000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer2->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.652930f, 1.250000f);
shapeDef.vertices[1].Set(-1.652930f, -1.250000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer2->CreateShape(&shapeDef);

//Partition 4
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-2.902930f, 2.500000f);
shapeDef.vertices[1].Set(-1.652930f, 1.250000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
retainer2->CreateShape(&shapeDef);

//grounded
//retainer2->SetMassFromShapes();

//polygon6
bodyDef.position.Set(40.861111f, 55.861111f);
bodyDef.angle = 0.000000f;
b2Body* polygon6 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon6->SetLinearVelocity(initVel);
polygon6->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 6;
shapeDef.vertices[0].Set(-5.861111f, 1.638889f);
shapeDef.vertices[1].Set(-5.861111f, -0.861111f);
shapeDef.vertices[2].Set(-0.861111f, -5.861111f);
shapeDef.vertices[3].Set(1.638889f, 1.638889f);
shapeDef.vertices[4].Set(1.638889f, 6.638889f);
shapeDef.vertices[5].Set(-0.861111f, 6.638889f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon6->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 5;
shapeDef.vertices[0].Set(-0.861111f, -5.861111f);
shapeDef.vertices[1].Set(1.638889f, -5.861111f);
shapeDef.vertices[2].Set(6.638889f, -0.861111f);
shapeDef.vertices[3].Set(6.638889f, 1.638889f);
shapeDef.vertices[4].Set(1.638889f, 1.638889f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon6->CreateShape(&shapeDef);

polygon6->SetMassFromShapes();

//polygon7
bodyDef.position.Set(33.352273f, 41.714015f);
bodyDef.angle = 0.000000f;
b2Body* polygon7 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon7->SetLinearVelocity(initVel);
polygon7->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-2.102273f, 0.785985f);
shapeDef.vertices[1].Set(-2.102273f, -3.589015f);
shapeDef.vertices[2].Set(1.647727f, -3.589015f);
shapeDef.vertices[3].Set(1.647727f, 5.785985f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon7->CreateShape(&shapeDef);

//grounded
//polygon7->SetMassFromShapes();

//polygon8
bodyDef.position.Set(1.516073f, 9.978506f);
bodyDef.angle = 0.377903f;
b2Body* polygon8 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon8->SetLinearVelocity(initVel);
polygon8->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 6;
shapeDef.vertices[0].Set(-5.000000f, 2.333333f);
shapeDef.vertices[1].Set(-15.000000f, 2.333333f);
shapeDef.vertices[2].Set(-15.000000f, -0.166667f);
shapeDef.vertices[3].Set(-2.500000f, -5.166667f);
shapeDef.vertices[4].Set(2.500000f, -5.166667f);
shapeDef.vertices[5].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon8->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(15.000000f, 2.333333f);
shapeDef.vertices[1].Set(5.000000f, 2.333333f);
shapeDef.vertices[2].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon8->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(5.000000f, 2.333333f);
shapeDef.vertices[1].Set(0.000000f, 7.333333f);
shapeDef.vertices[2].Set(-5.000000f, 2.333333f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon8->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(5.000000f, 2.333333f);
shapeDef.vertices[1].Set(-5.000000f, 2.333333f);
shapeDef.vertices[2].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon8->CreateShape(&shapeDef);

polygon8->SetMassFromShapes();

//polygon9
bodyDef.position.Set(4.152931f, -8.750000f);
bodyDef.angle = 0.000000f;
b2Body* polygon9 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon9->SetLinearVelocity(initVel);
polygon9->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-2.902930f, -2.500000f);
shapeDef.vertices[1].Set(-6.652930f, -3.750000f);
shapeDef.vertices[2].Set(-6.652930f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon9->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-6.652930f, 3.750000f);
shapeDef.vertices[1].Set(-2.902930f, 2.500000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.vertices[3].Set(-6.652930f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon9->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-1.652930f, -1.250000f);
shapeDef.vertices[1].Set(-2.902930f, -2.500000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon9->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.652930f, 1.250000f);
shapeDef.vertices[1].Set(-1.652930f, -1.250000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon9->CreateShape(&shapeDef);

//Partition 4
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-2.902930f, 2.500000f);
shapeDef.vertices[1].Set(-1.652930f, 1.250000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon9->CreateShape(&shapeDef);

//grounded
//polygon9->SetMassFromShapes();

//polygon10
bodyDef.position.Set(-23.483927f, -7.521494f);
bodyDef.angle = 0.377903f;
b2Body* polygon10 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon10->SetLinearVelocity(initVel);
polygon10->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 6;
shapeDef.vertices[0].Set(-5.000000f, 2.333333f);
shapeDef.vertices[1].Set(-15.000000f, 2.333333f);
shapeDef.vertices[2].Set(-15.000000f, -0.166667f);
shapeDef.vertices[3].Set(-2.500000f, -5.166667f);
shapeDef.vertices[4].Set(2.500000f, -5.166667f);
shapeDef.vertices[5].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon10->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(15.000000f, 2.333333f);
shapeDef.vertices[1].Set(5.000000f, 2.333333f);
shapeDef.vertices[2].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon10->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(5.000000f, 2.333333f);
shapeDef.vertices[1].Set(0.000000f, 7.333333f);
shapeDef.vertices[2].Set(-5.000000f, 2.333333f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon10->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(5.000000f, 2.333333f);
shapeDef.vertices[1].Set(-5.000000f, 2.333333f);
shapeDef.vertices[2].Set(15.000000f, -0.166667f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon10->CreateShape(&shapeDef);

polygon10->SetMassFromShapes();

//polygon11
bodyDef.position.Set(-20.847069f, -26.250000f);
bodyDef.angle = 0.000000f;
b2Body* polygon11 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
polygon11->SetLinearVelocity(initVel);
polygon11->SetAngularVelocity(0.000000f);

//Partition 0
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-2.902930f, -2.500000f);
shapeDef.vertices[1].Set(-6.652930f, -3.750000f);
shapeDef.vertices[2].Set(-6.652930f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon11->CreateShape(&shapeDef);

//Partition 1
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-6.652930f, 3.750000f);
shapeDef.vertices[1].Set(-2.902930f, 2.500000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.vertices[3].Set(-6.652930f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon11->CreateShape(&shapeDef);

//Partition 2
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-1.652930f, -1.250000f);
shapeDef.vertices[1].Set(-2.902930f, -2.500000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon11->CreateShape(&shapeDef);

//Partition 3
shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.652930f, 1.250000f);
shapeDef.vertices[1].Set(-1.652930f, -1.250000f);
shapeDef.vertices[2].Set(5.847070f, -12.500000f);
shapeDef.vertices[3].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon11->CreateShape(&shapeDef);

//Partition 4
shapeDef.vertexCount = 3;
shapeDef.vertices[0].Set(-2.902930f, 2.500000f);
shapeDef.vertices[1].Set(-1.652930f, 1.250000f);
shapeDef.vertices[2].Set(5.847070f, 12.500000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
polygon11->CreateShape(&shapeDef);

//grounded
//polygon11->SetMassFromShapes();

//stopper1
bodyDef.position.Set(13.750000f, 20.625000f);
bodyDef.angle = 0.000000f;
b2Body* stopper1 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
stopper1->SetLinearVelocity(initVel);
stopper1->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-3.750000f, -0.625000f);
shapeDef.vertices[1].Set(3.750000f, -0.625000f);
shapeDef.vertices[2].Set(3.750000f, 0.625000f);
shapeDef.vertices[3].Set(-3.750000f, 0.625000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
stopper1->CreateShape(&shapeDef);

//grounded
//stopper1->SetMassFromShapes();

//rectangle3
bodyDef.position.Set(45.625000f, 83.437500f);
bodyDef.angle = 0.000000f;
b2Body* rectangle3 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle3->SetLinearVelocity(initVel);
rectangle3->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.875000f, -19.062500f);
shapeDef.vertices[1].Set(1.875000f, -19.062500f);
shapeDef.vertices[2].Set(1.875000f, 19.062500f);
shapeDef.vertices[3].Set(-1.875000f, 19.062500f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle3->CreateShape(&shapeDef);

//grounded
//rectangle3->SetMassFromShapes();

//rectangle4
bodyDef.position.Set(36.500000f, 83.437500f);
bodyDef.angle = 0.000000f;
b2Body* rectangle4 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle4->SetLinearVelocity(initVel);
rectangle4->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(1.875000f, 19.062500f);
shapeDef.vertices[1].Set(-1.875000f, 19.062500f);
shapeDef.vertices[2].Set(-1.875000f, -19.062500f);
shapeDef.vertices[3].Set(1.875000f, -19.062500f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle4->CreateShape(&shapeDef);

//grounded
//rectangle4->SetMassFromShapes();

//rectangle5
bodyDef.position.Set(23.750000f, 44.062500f);
bodyDef.angle = 0.000000f;
b2Body* rectangle5 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle5->SetLinearVelocity(initVel);
rectangle5->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.250000f, -5.937500f);
shapeDef.vertices[1].Set(1.250000f, -5.937500f);
shapeDef.vertices[2].Set(1.250000f, 5.937500f);
shapeDef.vertices[3].Set(-1.250000f, 5.937500f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle5->CreateShape(&shapeDef);

//grounded
//rectangle5->SetMassFromShapes();

//rectangle6
bodyDef.position.Set(-11.250000f, 3.125000f);
bodyDef.angle = 0.000000f;
b2Body* rectangle6 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle6->SetLinearVelocity(initVel);
rectangle6->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-3.750000f, -0.625000f);
shapeDef.vertices[1].Set(3.750000f, -0.625000f);
shapeDef.vertices[2].Set(3.750000f, 0.625000f);
shapeDef.vertices[3].Set(-3.750000f, 0.625000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle6->CreateShape(&shapeDef);

//grounded
//rectangle6->SetMassFromShapes();

//rectangle7
bodyDef.position.Set(-1.250000f, 26.562500f);
bodyDef.angle = 0.000000f;
b2Body* rectangle7 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle7->SetLinearVelocity(initVel);
rectangle7->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.250000f, -5.937500f);
shapeDef.vertices[1].Set(1.250000f, -5.937500f);
shapeDef.vertices[2].Set(1.250000f, 5.937500f);
shapeDef.vertices[3].Set(-1.250000f, 5.937500f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle7->CreateShape(&shapeDef);

//grounded
//rectangle7->SetMassFromShapes();

//rectangle8
bodyDef.position.Set(-36.250000f, -14.375000f);
bodyDef.angle = 0.000000f;
b2Body* rectangle8 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle8->SetLinearVelocity(initVel);
rectangle8->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-3.750000f, -0.625000f);
shapeDef.vertices[1].Set(3.750000f, -0.625000f);
shapeDef.vertices[2].Set(3.750000f, 0.625000f);
shapeDef.vertices[3].Set(-3.750000f, 0.625000f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle8->CreateShape(&shapeDef);

//grounded
//rectangle8->SetMassFromShapes();

//rectangle9
bodyDef.position.Set(-26.250000f, 9.062500f);
bodyDef.angle = 0.000000f;
b2Body* rectangle9 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000f, 0.000000f);
rectangle9->SetLinearVelocity(initVel);
rectangle9->SetAngularVelocity(0.000000f);

shapeDef.vertexCount = 4;
shapeDef.vertices[0].Set(-1.250000f, -5.937500f);
shapeDef.vertices[1].Set(1.250000f, -5.937500f);
shapeDef.vertices[2].Set(1.250000f, 5.937500f);
shapeDef.vertices[3].Set(-1.250000f, 5.937500f);
shapeDef.density = 0.015000f;
shapeDef.friction = 0.300000f;
shapeDef.restitution = 0.200000f;
shapeDef.filter.groupIndex = int16(0);
shapeDef.filter.categoryBits = uint16(65535);
shapeDef.filter.maskBits = uint16(65535);
rectangle9->CreateShape(&shapeDef);

//grounded
//rectangle9->SetMassFromShapes();


//Circles
//marble1
bodyDef.position.Set(41.250000f, 65.000000f);
bodyDef.angle = 0.000000f;
b2Body* marble1 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
marble1->SetLinearVelocity(initVel);
marble1->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
marble1->CreateShape(&circleDef);

marble1->SetMassFromShapes();

//circle2
bodyDef.position.Set(41.250000f, 70.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle2 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle2->SetLinearVelocity(initVel);
circle2->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle2->CreateShape(&circleDef);

circle2->SetMassFromShapes();

//circle3
bodyDef.position.Set(41.250000f, 75.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle3 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle3->SetLinearVelocity(initVel);
circle3->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle3->CreateShape(&circleDef);

circle3->SetMassFromShapes();

//circle4
bodyDef.position.Set(41.250000f, 80.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle4 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle4->SetLinearVelocity(initVel);
circle4->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle4->CreateShape(&circleDef);

circle4->SetMassFromShapes();

//circle5
bodyDef.position.Set(41.250000f, 85.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle5 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle5->SetLinearVelocity(initVel);
circle5->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle5->CreateShape(&circleDef);

circle5->SetMassFromShapes();

//circle6
bodyDef.position.Set(41.250000f, 90.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle6 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle6->SetLinearVelocity(initVel);
circle6->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle6->CreateShape(&circleDef);

circle6->SetMassFromShapes();

//circle7
bodyDef.position.Set(41.250000f, 95.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle7 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle7->SetLinearVelocity(initVel);
circle7->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle7->CreateShape(&circleDef);

circle7->SetMassFromShapes();

//circle8
bodyDef.position.Set(41.250000f, 100.000000f);
bodyDef.angle = 0.000000f;
b2Body* circle8 = m_world->CreateBody(&bodyDef);
initVel.Set(0.000000, 0.000000);
circle8->SetLinearVelocity(initVel);
circle8->SetAngularVelocity(0.000000);
circleDef.radius = 2.500000f;
circleDef.density = 0.152789f;
circleDef.friction = 0.300000f;
circleDef.restitution = 0.200000f;
circleDef.filter.groupIndex = int16(0);
circleDef.filter.categoryBits = uint16(65535);
circleDef.filter.maskBits = uint16(65535);
circle8->CreateShape(&circleDef);

circle8->SetMassFromShapes();


//Revolute joints
pos.Set(27.499999f, 24.999998f);
revJointDef.Initialize(flip_flop1, ground, pos);
revJointDef.collideConnected = false;
m_world->CreateJoint(&revJointDef);

pos.Set(2.499999f, 7.499998f);
revJointDef.Initialize(polygon8, ground, pos);
revJointDef.collideConnected = false;
m_world->CreateJoint(&revJointDef);

pos.Set(-22.500001f, -10.000002f);
revJointDef.Initialize(polygon10, ground, pos);
revJointDef.collideConnected = false;
m_world->CreateJoint(&revJointDef);

//Motors
pos.Set(41.250000f, 56.250000f);
revJointDef.Initialize(polygon6, ground, pos);
revJointDef.collideConnected = false;
revJointDef.maxMotorTorque = 10000.000000f;
revJointDef.motorSpeed = -30.000000f / 60;
revJointDef.enableMotor = true;
m_world->CreateJoint(&revJointDef);
nimodo wrote:
I think, this is a really cool box2d-cad-editor. 🙂)

Adding C++ (or/and Java / Flash) source output ? Yes, would be great.


saludos, nimodo


I am almost done with the C++ generator and planning to release it in a few days. I may try adding Flash next.
Really amusing work!
nimodo wrote:
I think, this is a really cool box2d-cad-editor. 🙂)

Adding C++ (or/and Java / Flash) source output ? Yes, would be great.


saludos, nimodo


Nimodo,

I have added the C++ generator to Mekanimo. Have you had a chance to test it? If people find this useful, I may try to add Flash code generation next.

Fahri
I would really really love to see a flash conversion of this 😀 great work

Original thread: https://box2d.org/forum/viewtopic.php?t=1767