コード例 #1
0
b2Joint *Box2DWeldJoint::createJoint(b2World *world)
{
    mJointDef.Initialize(bodyA()->body(), bodyB()->body(), 0.5f * (bodyA()->body()->GetWorldCenter() + bodyA()->body()->GetWorldCenter()));
    mJointDef.collideConnected = collideConnected();

    return world->CreateJoint(&mJointDef);
}
コード例 #2
0
void Box2DFrictionJoint::createJoint()
{
    mFrictionJointDef.Initialize(bodyA()->body(), bodyB()->body(), bodyA()->body()->GetWorldCenter());
    mFrictionJointDef.collideConnected = collideConnected();

    mFrictionJoint = static_cast<b2FrictionJoint*>(world()->CreateJoint(&mFrictionJointDef));
    mInitializePending = false;
}
コード例 #3
0
void Box2DPrismaticJoint::createJoint()
{
    mPrismaticJointDef.Initialize(bodyA()->body(), bodyB()->body(),
                                 bodyA()->body()->GetWorldCenter(),
                                  mPrismaticJointDef.localAxis1);
    mPrismaticJointDef.collideConnected = collideConnected();

    mPrismaticJoint = static_cast<b2PrismaticJoint*>
            (world()->CreateJoint(&mPrismaticJointDef));
    mPrismaticJoint->SetUserData(this);
    mInitializePending = false;
}
コード例 #4
0
void Box2DWeldJoint::createJoint()
{
    if (anchorsAuto)
        mWeldJointDef.Initialize(bodyA()->body(), bodyB()->body(),bodyA()->body()->GetWorldCenter());
    else
    {
        mWeldJointDef.bodyA = bodyA()->body();
        mWeldJointDef.bodyB = bodyB()->body();
    }
    mWeldJointDef.collideConnected = collideConnected();
    mWeldJoint = static_cast<b2WeldJoint*>
            (world()->CreateJoint(&mWeldJointDef));

    mWeldJoint->SetUserData(this);
    mInitializePending = false;
    emit created();
}
コード例 #5
0
void Box2DDistanceJoint::createJoint()
{
    b2Vec2 anchorA = mOverrideLocalAnchorA ?
                b2Vec2(mLocalAnchorA.x() / scaleRatio,
                       -mLocalAnchorA.y() / scaleRatio) +
                bodyA()->body()->GetPosition() :
                bodyA()->body()->GetWorldCenter();

    b2Vec2 anchorB = mOverrideLocalAnchorB ?
                b2Vec2(mLocalAnchorB.x() / scaleRatio,
                       -mLocalAnchorB.y() / scaleRatio) +
                bodyB()->body()->GetPosition() :
                bodyB()->body()->GetWorldCenter();

    mDistanceJointDef.Initialize(bodyA()->body(), bodyB()->body(),
                                 anchorA, anchorB);
    mDistanceJointDef.collideConnected = collideConnected();
    if (mOverrideAnchorLength)
        mDistanceJointDef.length = mLength;
    mDistanceJoint = static_cast<b2DistanceJoint*>
            (world()->CreateJoint(&mDistanceJointDef));
    mDistanceJoint->SetUserData(this);
    mInitializePending = false;
}