Exemple #1
0
 public void DebugDrawFixtures(Matrix view, Matrix projection)
 {
     var context = new Graphics3D.DebugDrawContext(view, projection);
     var broadPhase = _world.ContactManager.BroadPhase;
     foreach (var body in _world.BodyList)
     {
         if (!body.Enabled) continue;
         foreach (var fixture in body.FixtureList)
         {
             for (int t = 0; t < fixture.ProxyCount; ++t)
             {
                 var proxy = fixture.Proxies[t];
                 AABB aabb;
                 broadPhase.GetFatAABB(proxy.ProxyId, out aabb);
                 Graphics3D.DebugDrawPolyline(context,
                     aabb.LowerBound.FromFarseer(),
                     new Vector2(aabb.LowerBound.X, aabb.UpperBound.Y).FromFarseer(),
                     aabb.UpperBound.FromFarseer(),
                     new Vector2(aabb.UpperBound.X, aabb.LowerBound.Y).FromFarseer(),
                     aabb.LowerBound.FromFarseer());
             }
         }
     }
 }
 private void CircleGob(Gob gob)
 {
     var context = new Graphics3D.DebugDrawContext(ViewMatrix, GetProjectionMatrix(gob.Layer.Z));
     Graphics3D.DebugDrawCircle(context, new BoundingSphere(new Vector3(gob.Pos, 0), SMALL_GOB_RADIUS));
     Graphics3D.DebugDrawPolyline(context, gob.Pos, gob.Pos + SMALL_GOB_RADIUS * AWMathHelper.GetUnitVector2(gob.Rotation));
 }
Exemple #3
0
 public void DebugDrawBroadPhase(Matrix view, Matrix projection)
 {
     var context = new Graphics3D.DebugDrawContext(view, projection);
     Func<int, Color> getColor = count =>
         count <= 0 ? new Color(0f, 0f, 1f) :
         count <= 5 ? new Color(0f, 1f, 0f) :
         count <= 25 ? new Color(1f, 0.5f, 0f) :
         count <= 125 ? new Color(1f, 1f, 0f) :
         new Color(1f, 1f, 1f);
     Func<AABB, Vector2[]> getVertices = aabb =>
     {
         var awCenter = aabb.Center.FromFarseer();
         var extents = aabb.Extents.FromFarseer();
         var reducedExtents = extents - new Vector2((float)Math.Log(extents.X + 1, 1.5), (float)Math.Log(extents.Y + 1, 1.5));
         return new[]
         {
             awCenter - reducedExtents,
             awCenter + reducedExtents.MirrorX(),
             awCenter + reducedExtents,
             awCenter + reducedExtents.MirrorY(),
             awCenter - reducedExtents,
         };
     };
     var spansAndElementCounts = new List<Tuple<AABB, int>>();
     _world.ContactManager.BroadPhase.GetSpans(ref spansAndElementCounts);
     foreach (var aabbAndCount in spansAndElementCounts)
     {
         context.Color = getColor(aabbAndCount.Item2);
         Graphics3D.DebugDrawPolyline(context, getVertices(aabbAndCount.Item1));
     }
 }