示例#1
0
        // p = attached point, m = mouse point
        // C = p - m
        // Cdot = v
        //      = v + cross(w, r)
        // J = [I r_skew]
        // Identity used:
        // w k % (rx i + ry j) = w * (-ry i + rx j)
        internal MouseJoint(MouseJointDef def) : base(def)
        {
            Utilities.Assert(def.target.IsValid());
            Utilities.Assert(Utilities.IsValid(def.maxForce) && def.maxForce >= 0.0f);
            Utilities.Assert(Utilities.IsValid(def.frequencyHz) && def.frequencyHz >= 0.0f);
            Utilities.Assert(Utilities.IsValid(def.dampingRatio) && def.dampingRatio >= 0.0f);

            m_targetA      = def.target;
            m_localAnchorB = Utilities.MulT(m_bodyB.GetTransform(), m_targetA);

            m_maxForce = def.maxForce;
            m_impulse.SetZero();

            m_frequencyHz  = def.frequencyHz;
            m_dampingRatio = def.dampingRatio;

            m_beta  = 0.0f;
            m_gamma = 0.0f;
        }
示例#2
0
        internal MouseJoint(MouseJointDef def)
            : base(def)
        {
            //Debug.Assert(def.target.IsValid());
            //Debug.Assert(MathUtils.IsValid(def.maxForce) && def.maxForce >= 0.0f);
            //Debug.Assert(MathUtils.IsValid(def.frequencyHz) && def.frequencyHz >= 0.0f);
            //Debug.Assert(MathUtils.IsValid(def.dampingRatio) && def.dampingRatio >= 0.0f);

            Transform xf1;

            _bodyB.GetTransform(out xf1);

            _target      = def.target;
            _localAnchor = MathUtils.MultiplyT(ref xf1, _target);

            _maxForce = def.maxForce;
            _impulse  = Vector2.zero;

            _frequencyHz  = def.frequencyHz;
            _dampingRatio = def.dampingRatio;

            _beta  = 0.0f;
            _gamma = 0.0f;
        }
示例#3
0
		// p = attached point, m = mouse point
		// C = p - m
		// Cdot = v
		//      = v + cross(w, r)
		// J = [I r_skew]
		// Identity used:
		// w k % (rx i + ry j) = w * (-ry i + rx j)
		internal MouseJoint(MouseJointDef def) : base(def){
			Utilities.Assert(def.target.IsValid());
			Utilities.Assert(Utilities.IsValid(def.maxForce) && def.maxForce >= 0.0f);
			Utilities.Assert(Utilities.IsValid(def.frequencyHz) && def.frequencyHz >= 0.0f);
			Utilities.Assert(Utilities.IsValid(def.dampingRatio) && def.dampingRatio >= 0.0f);

			m_targetA = def.target;
			m_localAnchorB = Utilities.MulT(m_bodyB.GetTransform(), m_targetA);

			m_maxForce = def.maxForce;
			m_impulse.SetZero();

			m_frequencyHz = def.frequencyHz;
			m_dampingRatio = def.dampingRatio;

			m_beta = 0.0f;
			m_gamma = 0.0f;
		}
示例#4
0
		public virtual void MouseDown(Vec2 p){
			m_mouseWorld = p;
	
			if (m_mouseJoint != null)
			{
				return;
			}

			// Make a small box.
			AABB aabb;
			Vec2 d = new Vec2();
			d.Set(0.001f, 0.001f);
			aabb.lowerBound = p - d;
			aabb.upperBound = p + d;

			// Query the world for overlapping shapes.
			TestQueryCallback callback = new TestQueryCallback(p);
			m_world.QueryAABB(callback, aabb);

			if (callback.m_fixture != null)
			{
				Body body = callback.m_fixture.GetBody();
				MouseJointDef md = new MouseJointDef();
				md.bodyA = m_groundBody;
				md.bodyB = body;
				md.target = p;
				md.maxForce = 1000.0f * body.GetMass();
				m_mouseJoint = (MouseJoint)m_world.CreateJoint(md);
				body.SetAwake(true);
			}
		}