GetType() public method

Get the type of the concrete joint.
public GetType ( ) : JointType
return JointType
Esempio n. 1
0
        private void DrawJoint(Joint joint)
        {
            Body      b1  = joint.GetBody1();
            Body      b2  = joint.GetBody2();
            Transform xf1 = b1.GetTransform();
            Transform xf2 = b2.GetTransform();
            Vec2      x1  = xf1.Position;
            Vec2      x2  = xf2.Position;
            Vec2      p1  = joint.Anchor1;
            Vec2      p2  = joint.Anchor2;

            Color color = new Color(0.5f, 0.8f, 0.8f);

            switch (joint.GetType())
            {
            case JointType.DistanceJoint:
                _debugDraw.DrawSegment(p1, p2, color);
                break;

            case JointType.PulleyJoint:
            {
                PulleyJoint pulley = (PulleyJoint)joint;
                Vec2        s1     = pulley.GroundAnchor1;
                Vec2        s2     = pulley.GroundAnchor2;
                _debugDraw.DrawSegment(s1, p1, color);
                _debugDraw.DrawSegment(s2, p2, color);
                _debugDraw.DrawSegment(s1, s2, color);
            }
            break;

            case JointType.MouseJoint:
                // don't draw this
                break;

            default:
                _debugDraw.DrawSegment(x1, p1, color);
                _debugDraw.DrawSegment(p1, p2, color);
                _debugDraw.DrawSegment(x2, p2, color);
                break;
            }
        }
Esempio n. 2
0
		private void DrawJoint(Joint joint)
		{
			Body b1 = joint.GetBody1();
			Body b2 = joint.GetBody2();
			XForm xf1 = b1.GetXForm();
			XForm xf2 = b2.GetXForm();
			Vec2 x1 = xf1.Position;
			Vec2 x2 = xf2.Position;
			Vec2 p1 = joint.Anchor1;
			Vec2 p2 = joint.Anchor2;

			Color color = new Color(0.5f, 0.8f, 0.8f);

			switch (joint.GetType())
			{
				case JointType.DistanceJoint:
					_debugDraw.DrawSegment(p1, p2, color);
					break;

				case JointType.PulleyJoint:
					{
						PulleyJoint pulley = (PulleyJoint)joint;
						Vec2 s1 = pulley.GroundAnchor1;
						Vec2 s2 = pulley.GroundAnchor2;
						_debugDraw.DrawSegment(s1, p1, color);
						_debugDraw.DrawSegment(s2, p2, color);
						_debugDraw.DrawSegment(s1, s2, color);
					}
					break;

				case JointType.MouseJoint:
					// don't draw this
					break;

				default:
					_debugDraw.DrawSegment(x1, p1, color);
					_debugDraw.DrawSegment(p1, p2, color);
					_debugDraw.DrawSegment(x2, p2, color);
					break;
			}
		}
Esempio n. 3
0
 private void DrawJoint(Joint joint)
 {
     Body body = joint.GetBody1();
     Body body2 = joint.GetBody2();
     XForm xForm = body.GetXForm();
     XForm xForm2 = body2.GetXForm();
     Vec2 position = xForm.Position;
     Vec2 position2 = xForm2.Position;
     Vec2 anchor = joint.Anchor1;
     Vec2 anchor2 = joint.Anchor2;
     Color color = new Color(0.5f, 0.8f, 0.8f);
     switch (joint.GetType())
     {
         case JointType.DistanceJoint:
         {
             this._debugDraw.DrawSegment(anchor, anchor2, color);
             break;
         }
         case JointType.PulleyJoint:
         {
             PulleyJoint pulleyJoint = (PulleyJoint)joint;
             Vec2 groundAnchor = pulleyJoint.GroundAnchor1;
             Vec2 groundAnchor2 = pulleyJoint.GroundAnchor2;
             this._debugDraw.DrawSegment(groundAnchor, anchor, color);
             this._debugDraw.DrawSegment(groundAnchor2, anchor2, color);
             this._debugDraw.DrawSegment(groundAnchor, groundAnchor2, color);
             break;
         }
         case JointType.MouseJoint:
         {
             break;
         }
         default:
         {
             this._debugDraw.DrawSegment(position, anchor, color);
             this._debugDraw.DrawSegment(anchor, anchor2, color);
             this._debugDraw.DrawSegment(position2, anchor2, color);
             break;
         }
     }
 }
Esempio n. 4
0
        public void DrawDebugData()
        {
            if (_debugDraw == null)
            {
                return;
            }

            DebugDraw.DrawFlags flags = _debugDraw.Flags;

            if ((flags & DebugDraw.DrawFlags.Shape) != 0)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    Transform xf = b.GetTransform();
                    for (Fixture f = b.GetFixtureList(); f != null; f = f.GetNext())
                    {
                        if (b.IsStatic())
                        {
                            DrawShape(f, xf, new Color(0.5f, 0.9f, 0.5f));
                        }
                        else if (b.IsSleeping())
                        {
                            DrawShape(f, xf, new Color(0.5f, 0.5f, 0.9f));
                        }
                        else
                        {
                            DrawShape(f, xf, new Color(0.9f, 0.9f, 0.9f));
                        }
                    }
                }
            }

            if ((flags & DebugDraw.DrawFlags.Joint) != 0)
            {
                for (Joint j = _jointList; j != null; j = j.GetNext())
                {
                    if (j.GetType() != JointType.MouseJoint)
                    {
                        DrawJoint(j);
                    }
                }
            }

            if ((flags & DebugDraw.DrawFlags.Pair) != 0)
            {
                // TODO_ERIN
            }

            if ((flags & DebugDraw.DrawFlags.Aabb) != 0)
            {
                Color      color = new Color(0.9f, 0.3f, 0.9f);
                BroadPhase bp    = _contactManager._broadPhase;

                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    for (Fixture f = b.GetFixtureList(); f != null; f = f.GetNext())
                    {
                        AABB   aabb = bp.GetFatAABB(f.ProxyId);
                        Vec2[] vs   = new Vec2[4];
                        vs[0].Set(aabb.LowerBound.X, aabb.LowerBound.Y);
                        vs[1].Set(aabb.UpperBound.X, aabb.LowerBound.Y);
                        vs[2].Set(aabb.UpperBound.X, aabb.UpperBound.Y);
                        vs[3].Set(aabb.LowerBound.X, aabb.UpperBound.Y);

                        _debugDraw.DrawPolygon(vs, 4, color);
                    }
                }
            }

            if ((flags & DebugDraw.DrawFlags.CenterOfMass) != 0)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    Transform xf = b.GetTransform();
                    xf.Position = b.GetWorldCenter();
                    _debugDraw.DrawXForm(xf);
                }
            }
        }