private void spawnMouseJoint(Vec2 p) { if (mouseJoint != null) { return; } queryAABB.lowerBound.set(p.x - .001f, p.y - .001f); queryAABB.upperBound.set(p.x + .001f, p.y + .001f); callback.point.set(p); callback.fixture = null; m_world.queryAABB(callback, queryAABB); if (callback.fixture != null) { Body body = callback.fixture.getBody(); MouseJointDef def = new MouseJointDef(); def.bodyA = groundBody; def.bodyB = body; def.collideConnected = true; def.target.set(p); def.maxForce = 1000f*body.getMass(); mouseJoint = (MouseJoint) m_world.createJoint(def); body.setAwake(true); } }
public void sayGoodbye(Joint joint) { if (mouseJoint == joint) { mouseJoint = null; } else { jointDestroyed(joint); } }
private void destroyMouseJoint() { if (mouseJoint != null) { m_world.destroyJoint(mouseJoint); mouseJoint = null; } }
public void init(TestbedModel model) { this.model = model; Vec2 gravity = new Vec2(0, -10f); m_world = model.getWorldCreator().createWorld(gravity); m_world.setParticleGravityScale(0.4f); m_world.setParticleDensity(1.2f); bomb = null; mouseJoint = null; mouseTracing = false; mouseTracerPosition.setZero(); mouseTracerVelocity.setZero(); BodyDef bodyDef = new BodyDef(); groundBody = m_world.createBody(bodyDef); init(m_world, false); }