Bouyancy Tutorial Questions

General discussion about Box2D tutorials
Post Reply
mortl66
Posts: 2
Joined: Mon Feb 11, 2013 3:38 pm

Bouyancy Tutorial Questions

Post by mortl66 »

Hello, I wanted to say first that your tutorials are really great. They help me with my Physics course.

I just have a few questions about the code, specifically, the values you use to set the objects in the code?

for example like :

Code: Select all

b2FixtureDef fd;
    fd.friction = 2.000000029802322e-01f;
    fd.restitution = 0.000000000000000e+00f;
    fd.density = 1.000000000000000e+00f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1);
    fd.filter.maskBits = uint16(65535);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(2.000000000000000e+01f, -5.000000000000000e-01f);
    vs[1].Set(2.000000000000000e+01f, 5.000000000000000e-01f);
    vs[2].Set(-5.485061645507812e+01f, 5.000000000000000e-01f);
    vs[3].Set(-5.485061645507812e+01f, -5.000000000000000e-01f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[1]->CreateFixture(&fd);
Also I haven't seen such notation for setting a bool.

Anyway thanks for the tutorials! Keep up the great work ^_^
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Bouyancy Tutorial Questions

Post by iforce2d »

Is this from the .cpp file that gets included? As it says at the top of the file, that is generated from the RUBE editor. The actual source code used to make this 'dump' is just the b2World::Dump function that you can find in the Box2D source. It tries to output the values with as much precision as possible so that the scene can be reproduced without changes. About the bool(0) type setting, yeah, I had not seen that before either :)
mortl66
Posts: 2
Joined: Mon Feb 11, 2013 3:38 pm

Re: Bouyancy Tutorial Questions

Post by mortl66 »

Yes it is and oh okay that make's sense ^_^. Thanks
Post Reply