int physics_fixture_create(int world) { get_worldr(sb2dworld, world, -1); int i = fixtures.size(); fixtureInstance* fixture = new fixtureInstance(); b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; fixture->body = sb2dworld->world->CreateBody(&bodyDef); fixtures.push_back(fixture); fixtures[i]->world = world; return i; }
int b2d_joint_create_mouse(int world, int bodya, int bodyb, bool collide, double x, double y) { get_worldr(b2dworld, world, -1); b2MouseJointDef jointDef; jointDef.bodyA = b2dbodies[bodya]->body; jointDef.bodyB = b2dbodies[bodyb]->body; jointDef.target.Set(x, y); jointDef.maxForce = 30000; jointDef.collideConnected = collide; B2DJoint* b2djoint = new B2DJoint(); b2djoint->joint = b2dworld->world->CreateJoint(&jointDef); b2djoint->worldid = world; b2djoints.push_back(b2djoint); return b2djoints.size() - 1; }
int b2d_joint_create_distance(int world, int bodya, int bodyb, bool collide) { get_worldr(b2dworld, world, -1); b2DistanceJointDef jointDef; jointDef.bodyA = b2dbodies[bodya]->body; jointDef.bodyB = b2dbodies[bodyb]->body; jointDef.collideConnected = collide; jointDef.frequencyHz = 4.0f; jointDef.dampingRatio = 0.5f; B2DJoint* b2djoint = new B2DJoint(); b2djoint->joint = b2dworld->world->CreateJoint(&jointDef); b2djoint->worldid = world; b2djoints.push_back(b2djoint); return b2djoints.size() - 1; }
int b2d_joint_create_revolute(int world, int bodya, int bodyb, bool limit, double lower, double upper) { get_worldr(b2dworld, world, -1); get_bodyr(b2dbodya, bodya, -1); get_bodyr(b2dbodyb, bodyb, -1); b2RevoluteJointDef jointDef; jointDef.bodyA = b2dbodya->body; jointDef.bodyB = b2dbodyb->body; jointDef.lowerAngle = cs_angular_degrees(lower); jointDef.upperAngle = cs_angular_degrees(upper); jointDef.localAnchorA = b2Vec2(0,0); jointDef.localAnchorB =b2Vec2(1,1); jointDef.enableLimit = limit; B2DJoint* b2djoint = new B2DJoint(); b2djoint->joint = b2dworld->world->CreateJoint(&jointDef); b2djoint->worldid = world; b2djoints.push_back(b2djoint); return b2djoints.size() - 1; }