Line joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
Inheritance: JointDef
Exemple #1
0
 public LineJoint(LineJointDef def) : base(def)
 {
     this._localAnchor1 = def.localAnchor1;
     this._localAnchor2 = def.localAnchor2;
     this._localXAxis1  = def.localAxis1;
     this._localYAxis1  = Vec2.Cross(1f, this._localXAxis1);
     this._impulse.SetZero();
     this._motorMass        = 0f;
     this._motorImpulse     = 0f;
     this._lowerTranslation = def.lowerTranslation;
     this._upperTranslation = def.upperTranslation;
     this._maxMotorForce    = Settings.FORCE_INV_SCALE(def.maxMotorForce);
     this._motorSpeed       = def.motorSpeed;
     this._enableLimit      = def.enableLimit;
     this._enableMotor      = def.enableMotor;
     this._axis.SetZero();
     this._perp.SetZero();
 }
Exemple #2
0
 public LineJoint(LineJointDef def)
     : base(def)
 {
     this._localAnchor1 = def.localAnchor1;
     this._localAnchor2 = def.localAnchor2;
     this._localXAxis1 = def.localAxis1;
     this._localYAxis1 = Vec2.Cross(1f, this._localXAxis1);
     this._impulse.SetZero();
     this._motorMass = 0f;
     this._motorImpulse = 0f;
     this._lowerTranslation = def.lowerTranslation;
     this._upperTranslation = def.upperTranslation;
     this._maxMotorForce = Settings.FORCE_INV_SCALE(def.maxMotorForce);
     this._motorSpeed = def.motorSpeed;
     this._enableLimit = def.enableLimit;
     this._enableMotor = def.enableMotor;
     this._axis.SetZero();
     this._perp.SetZero();
 }
Exemple #3
0
		public LineJoint()
		{
			Body ground = null;
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, -10.0f);
				ground = _world.CreateBody(bd);
				ground.CreateShape(sd);
			}

			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(0.5f, 2.0f);
				sd.Density = 1.0f;


				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, 7.0f);
				Body body = _world.CreateBody(bd);
				body.CreateShape(sd);
				body.SetMassFromShapes();

				LineJointDef jd = new LineJointDef();
				Vec2 axis = new Vec2(2.0f, 1.0f);
				axis.Normalize();
				jd.Initialize(ground, body, new Vec2(0.0f, 8.5f), axis);
				jd.motorSpeed = 0.0f;
				jd.maxMotorForce = 100.0f;
				jd.enableMotor = true;
				jd.lowerTranslation = -4.0f;
				jd.upperTranslation = 4.0f;
				jd.enableLimit = true;
				_world.CreateJoint(jd);
			}
		}
Exemple #4
0
        public LineJoint(LineJointDef def)
            : base(def)
        {
            _localAnchor1 = def.localAnchor1;
            _localAnchor2 = def.localAnchor2;
            _localXAxis1  = def.localAxis1;
            _localYAxis1  = _localXAxis1.CrossScalarPreMultiply(1.0f);

            _impulse      = Vector2.Zero;
            _motorMass    = 0.0f;
            _motorImpulse = 0.0f;

            _lowerTranslation = def.lowerTranslation;
            _upperTranslation = def.upperTranslation;
            _maxMotorForce    = Settings.FORCE_INV_SCALE(def.maxMotorForce);
            _motorSpeed       = def.motorSpeed;
            _enableLimit      = def.enableLimit;
            _enableMotor      = def.enableMotor;
            _limitState       = LimitState.InactiveLimit;

            _axis = Vector2.Zero;
            _perp = Vector2.Zero;
        }
Exemple #5
0
        public LineJoint(LineJointDef def)
            : base(def)
        {
            _localAnchor1 = def.localAnchor1;
            _localAnchor2 = def.localAnchor2;
            _localXAxis1  = def.localAxis1;
            _localYAxis1  = Vec2.Cross(1.0f, _localXAxis1);

            _impulse.SetZero();
            _motorMass    = 0.0f;
            _motorImpulse = 0.0f;

            _lowerTranslation = def.lowerTranslation;
            _upperTranslation = def.upperTranslation;
            _maxMotorForce    = def.maxMotorForce;
            _motorSpeed       = def.motorSpeed;
            _enableLimit      = def.enableLimit;
            _enableMotor      = def.enableMotor;
            _limitState       = LimitState.InactiveLimit;

            _axis.SetZero();
            _perp.SetZero();
        }
Exemple #6
0
		public LineJoint(LineJointDef def)
			: base(def)
		{
			_localAnchor1 = def.localAnchor1;
			_localAnchor2 = def.localAnchor2;
			_localXAxis1 = def.localAxis1;
			_localYAxis1 = Vec2.Cross(1.0f, _localXAxis1);

			_impulse.SetZero();
			_motorMass = 0.0f;
			_motorImpulse = 0.0f;

			_lowerTranslation = def.lowerTranslation;
			_upperTranslation = def.upperTranslation;
			_maxMotorForce = Settings.FORCE_INV_SCALE(def.maxMotorForce);
			_motorSpeed = def.motorSpeed;
			_enableLimit = def.enableLimit;
			_enableMotor = def.enableMotor;
			_limitState = LimitState.InactiveLimit;

			_axis.SetZero();
			_perp.SetZero();
		}
        public LineJoint(LineJointDef def)
            : base(def)
        {
            _localAnchor1 = def.localAnchor1;
            _localAnchor2 = def.localAnchor2;
            _localXAxis1 = def.localAxis1;
            _localYAxis1 = _localXAxis1.CrossScalarPreMultiply(1.0f);

            _impulse = Vector2.zero;
            _motorMass = 0.0f;
            _motorImpulse = 0.0f;

            _lowerTranslation = def.lowerTranslation;
            _upperTranslation = def.upperTranslation;
            _maxMotorForce = Settings.FORCE_INV_SCALE(def.maxMotorForce);
            _motorSpeed = def.motorSpeed;
            _enableLimit = def.enableLimit;
            _enableMotor = def.enableMotor;
            _limitState = LimitState.InactiveLimit;

            _axis = Vector2.zero;
            _perp = Vector2.zero;
        }