コード例 #1
0
        public IntPtr AcquireDebugDrawOptions(IDebugDraw debugDraw, DebugDrawFlags flags, DebugDrawColors colors)
        {
            this.flags          = (int)flags;
            collisionPointColor = colors.CollisionPoint;
            constraintColor     = colors.Constraint;
            shapeOutlineColor   = colors.ShapeOutline;

            drawCircle     = spaceDebugDrawCircleCallback.ToFunctionPointer();
            drawSegment    = spaceDebugDrawSegmentCallback.ToFunctionPointer();
            drawFatSegment = spaceDebugDrawFatSegmentCallback.ToFunctionPointer();
            drawPolygon    = spaceDebugDrawPolygonCallback.ToFunctionPointer();
            drawDot        = spaceDebugDrawDotCallback.ToFunctionPointer();
            colorForShape  = spaceDebugDrawColorForShapeCallback.ToFunctionPointer();

            data = NativeInterop.RegisterHandle(debugDraw);

            return(ToPointer());
        }
コード例 #2
0
 /// Clear flags from the current flags.
 public void ClearFlags(DebugDrawFlags flags)
 {
     Flags &= ~flags;
 }
コード例 #3
0
 /// Append flags to the current flags.
 public void AppendFlags(DebugDrawFlags flags)
 {
     Flags |= flags;
 }
コード例 #4
0
ファイル: WorldCallbacks.cs プロジェクト: GretelF/squircle
 /// Clear flags from the current flags.
 public void ClearFlags(DebugDrawFlags flags)
 {
     Flags &= ~flags;
 }
コード例 #5
0
ファイル: WorldCallbacks.cs プロジェクト: GretelF/squircle
 /// Append flags to the current flags.
 public void AppendFlags(DebugDrawFlags flags)
 {
     Flags |= flags;
 }
コード例 #6
0
        /// Call this to draw shapes and other debug draw data.
        public void DrawDebugData()
        {
            if (DebugDraw == null)
            {
                return;
            }

            DebugDrawFlags flags = DebugDraw.Flags;

            if ((flags & DebugDrawFlags.Shape) == DebugDrawFlags.Shape)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    Transform xf;
                    b.GetTransform(out xf);
                    for (Fixture f = b.GetFixtureList(); f != null; f = f.GetNext())
                    {
                        if (b.IsActive() == false)
                        {
                            DrawShape(f, xf, new Color(0.5f, 0.5f, 0.3f));
                        }
                        else if (b.GetType() == BodyType.Static)
                        {
                            DrawShape(f, xf, new Color(0.5f, 0.9f, 0.5f));
                        }
                        else if (b.GetType() == BodyType.Kinematic)
                        {
                            DrawShape(f, xf, new Color(0.5f, 0.5f, 0.9f));
                        }
                        else if (b.IsAwake() == false)
                        {
                            DrawShape(f, xf, new Color(0.6f, 0.6f, 0.6f));
                        }
                        else
                        {
                            DrawShape(f, xf, new Color(0.9f, 0.7f, 0.7f));
                        }
                    }
                }
            }

            if ((flags & DebugDrawFlags.Joint) == DebugDrawFlags.Joint)
            {
                for (Joint j = _jointList; j != null; j = j.GetNext())
                {
                    DrawJoint(j);
                }
            }

            if ((flags & DebugDrawFlags.Pair) == DebugDrawFlags.Pair)
            {
                Color color = new Color(0.3f, 0.9f, 0.9f);
                for (Contact c = _contactManager._contactList; c != null; c = c.GetNext())
                {
                    Fixture fixtureA = c.GetFixtureA();
                    Fixture fixtureB = c.GetFixtureB();

                    AABB aabbA;
                    AABB aabbB;
                    fixtureA.GetAABB(out aabbA);
                    fixtureB.GetAABB(out aabbB);

                    Vector2 cA = aabbA.GetCenter();
                    Vector2 cB = aabbB.GetCenter();

                    DebugDraw.DrawSegment(cA, cB, color);
                }
            }

            if ((flags & DebugDrawFlags.AABB) == DebugDrawFlags.AABB)
            {
                Color      color = new Color(0.9f, 0.3f, 0.9f);
                BroadPhase bp    = _contactManager._broadPhase;

                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    if (b.IsActive() == false)
                    {
                        continue;
                    }

                    for (Fixture f = b.GetFixtureList(); f != null; f = f.GetNext())
                    {
                        AABB aabb;
                        bp.GetFatAABB(f._proxyId, out aabb);
                        FixedArray8 <Vector2> vs = new FixedArray8 <Vector2>();
                        vs[0] = new Vector2(aabb.lowerBound.X, aabb.lowerBound.Y);
                        vs[1] = new Vector2(aabb.upperBound.X, aabb.lowerBound.Y);
                        vs[2] = new Vector2(aabb.upperBound.X, aabb.upperBound.Y);
                        vs[3] = new Vector2(aabb.lowerBound.X, aabb.upperBound.Y);

                        DebugDraw.DrawPolygon(ref vs, 4, color);
                    }
                }
            }

            if ((flags & DebugDrawFlags.CenterOfMass) == DebugDrawFlags.CenterOfMass)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    Transform xf;
                    b.GetTransform(out xf);
                    xf.Position = b.GetWorldCenter();
                    DebugDraw.DrawTransform(ref xf);
                }
            }
        }
コード例 #7
0
ファイル: DebugDraw.cs プロジェクト: Nomad1/sharpbox2d
 public void clearFlags(DebugDrawFlags flags)
 {
     m_drawFlags &= ~flags;
 }
コード例 #8
0
ファイル: DebugDraw.cs プロジェクト: Nomad1/sharpbox2d
 public void appendFlags(DebugDrawFlags flags)
 {
     m_drawFlags |= flags;
 }
コード例 #9
0
ファイル: DebugDraw.cs プロジェクト: Nomad1/sharpbox2d
 protected DebugDraw(IViewportTransform viewport)
 {
     m_drawFlags = DebugDrawFlags.None;
     viewportTransform = viewport;
 }
コード例 #10
0
ファイル: DebugDraw.cs プロジェクト: Nomad1/sharpbox2d
 public void setFlags(DebugDrawFlags flags)
 {
     m_drawFlags = flags;
 }
コード例 #11
0
        /// Call this to draw shapes and other debug draw data.
        public void DrawDebugData()
        {
            if (DebugDraw == null)
            {
                return;
            }

            DebugDrawFlags flags = DebugDraw.Flags;

            if ((flags & DebugDrawFlags.Shape) == DebugDrawFlags.Shape)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    XForm xf;
                    b.GetXForm(out xf);
                    for (Fixture f = b.GetFixtureList(); f != null; f = f.GetNext())
                    {
                        if (b.IsStatic)
                        {
                            DrawShape(f, xf, ColorEx.FromScRgb(0.5f, 0.9f, 0.5f));
                        }
                        else if (b.IsSleeping)
                        {
                            DrawShape(f, xf, ColorEx.FromScRgb(0.5f, 0.5f, 0.9f));
                        }
                        else
                        {
                            DrawShape(f, xf, ColorEx.FromScRgb(0.9f, 0.9f, 0.9f));
                        }
                    }
                }
            }

            if ((flags & DebugDrawFlags.Joint) == DebugDrawFlags.Joint)
            {
                for (Joint j = _jointList; j != null; j = j.GetNext())
                {
                    if (j.JointType != JointType.Mouse)
                    {
                        DrawJoint(j);
                    }
                }
            }

            if ((flags & DebugDrawFlags.Pair) == DebugDrawFlags.Pair)
            {
                // TODO
            }

            if ((flags & DebugDrawFlags.AABB) == DebugDrawFlags.AABB)
            {
                Color      color = ColorEx.FromScRgb(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.GetAABB(f._proxyId, out aabb);
                        FixedArray8 <Vector2> vs = new FixedArray8 <Vector2>();
                        vs[0] = new Vector2(aabb.lowerBound.X, aabb.lowerBound.Y);
                        vs[1] = new Vector2(aabb.upperBound.X, aabb.lowerBound.Y);
                        vs[2] = new Vector2(aabb.upperBound.X, aabb.upperBound.Y);
                        vs[3] = new Vector2(aabb.lowerBound.X, aabb.upperBound.Y);

                        DebugDraw.DrawPolygon(ref vs, 4, color);
                    }
                }
            }

            if ((flags & DebugDrawFlags.CenterOfMass) == DebugDrawFlags.CenterOfMass)
            {
                for (Body b = _bodyList; b != null; b = b.GetNext())
                {
                    XForm xf;
                    b.GetXForm(out xf);
                    xf.Position = b.GetWorldCenter();
                    DebugDraw.DrawXForm(ref xf);
                }
            }
        }