Exemple #1
0
        protected override CJoint OnInitialise()
        {
            CJointUserDefinedBilateral joint = new CJointUserDefinedBilateral(this.World.NewtonWorld);
            int count = 0;

            foreach (UserJointConstraint constraint in _constraints)
            {
                count += constraint.MaxDofCount;
            }

            joint.CreateUserBilateral(count, joint_Callback, this.ChildBody.NewtonBody, this.ParentBody.NewtonBody);
            return(joint);
        }
Exemple #2
0
        private void joint_Callback(object sender, CUserBilateralEventArgs e)
        {
            if (!IsEnabled)
            {
                return;
            }

            foreach (UserJointConstraint constraint in _constraints)
            {
                constraint.ApplyConstraint(this);
            }

            CJointUserDefinedBilateral handle = this.NewtonJoint;
            double maxForce = 0;

            // break any constraints
            for (int i = 0; i < _constraints.Count; i++)
            {
                _constraints[i].UpdateForce(this, i);
                double force = _constraints[i].Force;

                if (force > maxForce)
                {
                    maxForce = force;
                }

                if ((_constraints[i].MaxForce > 0) &&
                    (force > _constraints[i].MaxForce))
                {
                    OnBroke();
                    return;
                }
            }

            double max = this.MaxForce;

            if ((max > 0) && (maxForce > max))
            {
                OnBroke();
            }
        }
Exemple #3
0
        protected virtual void ApplyConstraintProperties(UserJointBase joint)
        {
            CJointUserDefinedBilateral handle = joint.NewtonJoint;

            object value = this.MinFriction;

            if (value != null)
            {
                handle.UserBilateralRowMinimumFriction = (float)(double)value;
            }

            value = this.MaxFriction;
            if (value != null)
            {
                handle.UserBilateralRowMaximumFriction = (float)(double)value;
            }

            value = this.Acceleration;
            if (value != null)
            {
                handle.UserBilateralRowAcceleration = (float)(double)value;
            }

            double dvalue = this.Stiffness;

            if (dvalue != STIFFNESS_DEFAULT)
            {
                handle.UserBilateralRowStiffness = (float)dvalue;
            }

            value = this.SpringStiffness;
            object value2 = this.SpringDamper;

            if ((value != null) && (value2 != null))
            {
                handle.UserBilateralSetRowSpringDamperAcceleration((float)(double)value, (float)(double)value2);
            }
        }
		protected override CJoint OnInitialise()
		{
			CJointUserDefinedBilateral joint = new CJointUserDefinedBilateral(this.World.NewtonWorld);
			int count = 0;
			foreach (UserJointConstraint constraint in _constraints)
			{
				count += constraint.MaxDofCount;
			}

			joint.CreateUserBilateral(count, joint_Callback, this.ChildBody.NewtonBody, this.ParentBody.NewtonBody);
			return joint;
		}