예제 #1
0
 protected virtual void OnHinge(CHingeEventArgs pEventArgs)
 {
     if (m_Hinge != null)
     {
         m_Hinge(this, pEventArgs);
     }
 }
예제 #2
0
        private uint InvokeHinge(IntPtr pNewtonJoint, Newton.NewtonHingeSliderUpdateDesc pDesc)
        {
            CHingeEventArgs e = new CHingeEventArgs(new HingeSliderUpdateDesc(pDesc));

            OnHinge(e);

            if (e.ApplyConstraint)
            {
                e.Desc.ToNewton(pDesc);
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #3
0
		protected virtual void OnHinge(CHingeEventArgs pEventArgs)
		{
			if (m_Hinge != null)
				m_Hinge(this, pEventArgs);
		}
예제 #4
0
		private void joint_Hinge(object sender, CHingeEventArgs e)
        {
            double newAngle = Math1D.RadiansToDegrees(NewtonJoint.HingeAngle);
            double angle = this.Angle + AngleDiffence(this.Angle, newAngle);
            SetValue(AnglePropertyKey, angle);

            if (this.SetAngle != null)
            {
                e.Desc.m_Accel = NewtonJoint.HingeCalculateStopAlpha(e.Desc,
                                                                     Math1D.DegreesToRadians((float)MathUtils.MinMax(this.MinAngle, (double)this.SetAngle, this.MaxAngle)))

                                                                     * (float)this.SetAngleStiffness;
                e.ApplyConstraint = true;
            }
            else if ((this.MinAngle != null) && (angle < (double)this.MinAngle))
            {
                e.Desc.m_Accel = NewtonJoint.HingeCalculateStopAlpha(e.Desc,
                                                                     (float)Math1D.DegreesToRadians((double)this.MinAngle));
                e.ApplyConstraint = true;
            }
            else if ((this.MaxAngle != null) && (angle > (double)this.MaxAngle))
            {
                e.Desc.m_Accel = NewtonJoint.HingeCalculateStopAlpha(e.Desc,
                                                                     (float)Math1D.DegreesToRadians((double)this.MaxAngle));
                e.ApplyConstraint = true;
            }
            else
            {
                if (this.AngularDamperning != 0)
                {
                    // -(NewtonJoint.HingeOmega * e.Desc.m_Timestep * (float)this.AngularDamperning);
                    e.Desc.m_Accel = -(NewtonJoint.HingeOmega / e.Desc.m_Timestep) * (float)AngularDamperning;
                    e.ApplyConstraint = true;
                }

                if (this.Torque != 0)
                {
                    e.Desc.m_Accel += (float)this.Torque;
                    e.ApplyConstraint = true;
                }
            }
		}
예제 #5
0
        private uint InvokeHinge(IntPtr pNewtonJoint, Newton.NewtonHingeSliderUpdateDesc pDesc)
		{
            CHingeEventArgs e = new CHingeEventArgs(new HingeSliderUpdateDesc(pDesc));
            OnHinge(e);

            if (e.ApplyConstraint)
            {
                e.Desc.ToNewton(pDesc);
                return 1;
            }
            else
                return 0;
		}