Exemplo n.º 1
0
        private void DrawShape(Fixture fixture, Transform xf, Color color)
        {
            Color coreColor = new Color(0.9f, 0.6f, 0.6f);

            switch (fixture.GetType())
            {
            case ShapeType.CircleShape:
            {
                CircleShape circle = (CircleShape)fixture.GetShape();

                Vec2  center = Math.Mul(xf, circle._p);
                float radius = circle._radius;
                Vec2  axis   = xf.R.Col1;

                _debugDraw.DrawSolidCircle(center, radius, axis, color);
            }
            break;

            case ShapeType.PolygonShape:
            {
                PolygonShape poly        = (PolygonShape)fixture.GetShape();
                int          vertexCount = poly.VertexCount;
                Box2DXDebug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                Vec2[] vertices = new Vec2[Settings.MaxPolygonVertices];

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = Math.Mul(xf, poly.Vertices[i]);
                }

                _debugDraw.DrawSolidPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
Exemplo n.º 2
0
        public static Contact Create(Fixture fixtureA, Fixture fixtureB)
        {
            if (Initialized == false)
            {
                InitializeRegisters();
                Initialized = true;
            }

            ShapeType type1 = fixtureA.GetType();
            ShapeType type2 = fixtureB.GetType();

            Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

            ContactCreateFcn createFcn = Registers[(int)type1][(int)type2].CreateFcn;

            if (createFcn != null)
            {
                if (Registers[(int)type1][(int)type2].Primary)
                {
                    return(createFcn(fixtureA, fixtureB));
                }
                else
                {
                    return(createFcn(fixtureB, fixtureA));
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 public CircleContact(Fixture fixtureA, Fixture fixtureB)
     : base(fixtureA, fixtureB)
 {
     Box2DXDebug.Assert(fixtureA.GetType() == ShapeType.CircleShape);
     Box2DXDebug.Assert(fixtureB.GetType() == ShapeType.CircleShape);
 }
Exemplo n.º 4
0
 public CircleContact(Fixture fixtureA, Fixture fixtureB)
     : base(fixtureA, fixtureB)
 {
     Box2DXDebug.Assert(fixtureA.GetType() == ShapeType.CircleShape);
     Box2DXDebug.Assert(fixtureB.GetType() == ShapeType.CircleShape);
 }
Exemplo n.º 5
0
        public static Contact Create(Fixture fixtureA, Fixture fixtureB)
        {
            if (Initialized == false)
            {
                InitializeRegisters();
                Initialized = true;
            }

            ShapeType type1 = fixtureA.GetType();
            ShapeType type2 = fixtureB.GetType();

            Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

            ContactCreateFcn createFcn = Registers[(int)type1][(int)type2].CreateFcn;
            if (createFcn != null)
            {
                if (Registers[(int)type1][(int)type2].Primary)
                {
                    return createFcn(fixtureA, fixtureB);
                }
                else
                {
                    return createFcn(fixtureB, fixtureA);
                }
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 6
0
        private void DrawShape(Fixture fixture, Transform xf, Color color)
        {
            Color coreColor = new Color(0.9f, 0.6f, 0.6f);

            switch (fixture.GetType())
            {
                case ShapeType.CircleShape:
                    {
                        CircleShape circle = (CircleShape)fixture.GetShape();

                        Vec2 center = Math.Mul(xf, circle._p);
                        float radius = circle._radius;
                        Vec2 axis = xf.R.Col1;

                        _debugDraw.DrawSolidCircle(center, radius, axis, color);
                    }
                    break;

                case ShapeType.PolygonShape:
                    {
                        PolygonShape poly = (PolygonShape)fixture.GetShape();
                        int vertexCount = poly.VertexCount;
                        Box2DXDebug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                        Vec2[] vertices = new Vec2[Settings.MaxPolygonVertices];

                        for (int i = 0; i < vertexCount; ++i)
                        {
                            vertices[i] = Math.Mul(xf, poly.Vertices[i]);
                        }

                        _debugDraw.DrawSolidPolygon(vertices, vertexCount, color);
                    }
                    break;
            }
        }