Exemple #1
0
        protected override void CopyTo(JointInfo target)
        {
            base.CopyTo(target);
            PrismaticJointInfo c = target as PrismaticJointInfo;

            c.localAnchorA  = this.localAnchorA;
            c.localAnchorB  = this.localAnchorB;
            c.moveAxis      = this.moveAxis;
            c.refAngle      = this.refAngle;
            c.limitEnabled  = this.limitEnabled;
            c.lowerLimit    = this.lowerLimit;
            c.upperLimit    = this.upperLimit;
            c.motorEnabled  = this.motorEnabled;
            c.motorSpeed    = this.motorSpeed;
            c.maxMotorForce = this.maxMotorForce;
        }
        private void DrawJoint(Canvas canvas, PrismaticJointInfo joint)
        {
            float angularCircleRadA = joint.BodyA.BoundRadius * 0.25f;
            float angularCircleRadB = joint.BodyB.BoundRadius * 0.25f;
            bool displaySecondCollider = (joint.BodyA.GameObj.Transform.Pos - joint.BodyB.GameObj.Transform.Pos).Length >= angularCircleRadA + angularCircleRadB;

            if (joint.LimitEnabled)
                this.DrawLocalAxisConstraint(canvas, joint.BodyA, joint.BodyB, joint.MovementAxis, joint.LocalAnchorA, joint.LocalAnchorB, joint.LowerLimit, joint.UpperLimit);
            else
                this.DrawLocalAxisConstraint(canvas, joint.BodyA, joint.BodyB, joint.MovementAxis, joint.LocalAnchorA, joint.LocalAnchorB);

            this.DrawLocalAngleConstraint(canvas,
                joint.BodyA,
                joint.LocalAnchorA,
                joint.BodyB.GameObj.Transform.Angle - joint.ReferenceAngle,
                joint.BodyA.GameObj.Transform.Angle,
                angularCircleRadA);
            if (displaySecondCollider)
            {
                this.DrawLocalAngleConstraint(canvas,
                    joint.BodyB,
                    joint.LocalAnchorB,
                    joint.BodyA.GameObj.Transform.Angle + joint.ReferenceAngle,
                    joint.BodyB.GameObj.Transform.Angle,
                    angularCircleRadB);
            }

            if (joint.MotorEnabled)
                this.DrawLocalAxisMotor(canvas, joint.BodyA, joint.BodyB, joint.MovementAxis, joint.LocalAnchorA, joint.LocalAnchorB, joint.MotorSpeed, joint.MaxMotorForce, joint.BodyA.BoundRadius * 1.15f);

            this.DrawLocalAnchor(canvas, joint.BodyA, joint.LocalAnchorA);
            this.DrawLocalAnchor(canvas, joint.BodyB, joint.LocalAnchorB);
        }