public Vector2 getLocalCenter () { Vec2 lc = body.getLocalCenter(); localCenter.set(lc.x, lc.y); return localCenter; }
Vec2 bp = b.getWorldCenter(); float bm = b.getMass(); float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared(); float invBm = bm > 0 ? 1 / bm : 0; float invBI = bI > 0 ? 1 / bI : 0;
@Override public void step(TestbedSettings settings) { super.step(settings); addTextLine("Use 'wasd' to move, 'e' and 's' drift."); if (getModel().getKeys()['w']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(0.0f, 2.0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['q']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(-.2f, 0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['e']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(.2f, 0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['s']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, 30.0f)); Vec2 p = m_body.getWorldCenter(); m_body.applyForce(f, p); } if (getModel().getKeys()['a']) { m_body.applyTorque(20.0f); } if (getModel().getKeys()['d']) { m_body.applyTorque(-20.0f); } }
Vec2 bp = b.getWorldCenter(); float bm = b.getMass(); float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared(); float invBm = bm > 0 ? 1 / bm : 0; float invBI = bI > 0 ? 1 / bI : 0;
@Override public void step(TestbedSettings settings) { super.step(settings); addTextLine("Use 'wasd' to move, 'e' and 's' drift."); if (getModel().getKeys()['w']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(0.0f, 2.0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['q']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(-.2f, 0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['e']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, -30.0f)); Vec2 p = m_body.getWorldPoint(m_body.getLocalCenter().add(new Vec2(.2f, 0f))); m_body.applyForce(f, p); } else if (getModel().getKeys()['s']) { Vec2 f = m_body.getWorldVector(new Vec2(0.0f, 30.0f)); Vec2 p = m_body.getWorldCenter(); m_body.applyForce(f, p); } if (getModel().getKeys()['a']) { m_body.applyTorque(20.0f); } if (getModel().getKeys()['d']) { m_body.applyTorque(-20.0f); } }
Vec2 bp = b.getWorldCenter(); float bm = b.getMass(); float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared(); float invBm = bm > 0 ? 1 / bm : 0; float invBI = bI > 0 ? 1 / bI : 0;
Vec2 bp = b.getWorldCenter(); float bm = b.getMass(); float bI = b.getInertia() - bm * b.getLocalCenter().lengthSquared(); float invBm = bm > 0 ? 1 / bm : 0; float invBI = bI > 0 ? 1 / bI : 0;