Exemple #1
0
        public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
        {
            var centr = center.ToCCPoint() * PTMRatio;
            var rad   = radius * PTMRatio;

            DrawNode.DrawCircle(centr, rad, color.ToCCColor4B());
        }
Exemple #2
0
    private void testQueryShape_poly()
    {
        Vector3 mousePos        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        b2WorldQueryCallback cb = delegate(b2Fixture fixture) {
            b2Body body = fixture.GetBody();
            body.SetAwake(true);
            return(true);
        };

        b2Vec2[] vertices = new b2Vec2[4];
        vertices [0] = new b2Vec2(-100.0f / ptm_ratio, 0.0f / ptm_ratio);
        vertices [1] = new b2Vec2(0.0f / ptm_ratio, 100.0f / ptm_ratio);
        vertices [2] = new b2Vec2(100.0f / ptm_ratio, 0.0f / ptm_ratio);
        vertices [3] = new b2Vec2(0.0f / ptm_ratio, -200.0f / ptm_ratio);
        b2PolygonShape shape = b2PolygonShape.AsArray(vertices, vertices.Length);

        b2Transform transform = new b2Transform(new b2Vec2(mousePos.x, mousePos.y), b2Mat22.FromAngle(0));

        _world.QueryShape(cb, shape, transform);

        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i].x += mousePos.x;
            vertices[i].y += mousePos.y;
        }
        b2Color color = new b2Color(1.0f, 0.0f, 0.0f);

        _debugDraw.DrawPolygon(vertices, vertices.Length, color);
    }
Exemple #3
0
    private void testQueryAABB()
    {
        Vector3 mousePos        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        b2WorldQueryCallback cb = delegate(b2Fixture fixture) {
            b2Body body = fixture.GetBody();
            body.SetAwake(true);
            return(true);
        };

        float  w    = 200 / ptm_ratio;
        float  h    = 200 / ptm_ratio;
        b2AABB aabb = b2AABB.MakeWH(w, h, mousePos.x, mousePos.y);

        _world.QueryAABB(cb, aabb);

        b2Vec2[] vertices = new b2Vec2[] {
            new b2Vec2(aabb.lowerBound.x, aabb.lowerBound.y),
            new b2Vec2(aabb.upperBound.x, aabb.lowerBound.y),
            new b2Vec2(aabb.upperBound.x, aabb.upperBound.y),
            new b2Vec2(aabb.lowerBound.x, aabb.upperBound.y)
        };
        b2Color color = new b2Color(1.0f, 0.0f, 0.0f);

        _debugDraw.DrawPolygon(vertices, vertices.Length, color);
    }
Exemple #4
0
        public void DrawFixture(b2Fixture fixture)
        {
            b2Color     color = new b2Color(0.95f, 0.95f, 0.6f);
            b2Transform xf    = fixture.Body.Transform;

            switch (fixture.ShapeType)
            {
            case b2ShapeType.e_circle:
            {
                b2CircleShape circle = (b2CircleShape)fixture.Shape;

                b2Vec2 center = b2Math.b2Mul(xf, circle.Position);
                float  radius = circle.Radius;

                m_debugDraw.DrawCircle(center, radius, color);
            }
            break;

            case b2ShapeType.e_polygon:
            {
                b2PolygonShape poly        = (b2PolygonShape)fixture.Shape;
                int            vertexCount = poly.VertexCount;
                Debug.Assert(vertexCount <= b2Settings.b2_maxPolygonVertices);
                b2Vec2[] vertices = new b2Vec2[b2Settings.b2_maxPolygonVertices];

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

                m_debugDraw.DrawPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
Exemple #5
0
        public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
        {
            if (!primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            const double increment = Math.PI * 2.0 / CircleSegments;
            double       theta     = 0.0;

            var       col   = color.ToCCColor4B();
            CCVector2 centr = center.ToCCVector2();

            for (int i = 0, count = CircleSegments; i < count; i++)
            {
                CCVector2 v1 = (centr + radius * new CCVector2((float)Math.Cos(theta), (float)Math.Sin(theta))) * PTMRatio;
                CCVector2 v2 = (centr +
                                radius *
                                new CCVector2((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment))) * PTMRatio;

                primitiveBatch.AddVertex(ref v1, col, PrimitiveType.LineList);
                primitiveBatch.AddVertex(ref v2, col, PrimitiveType.LineList);

                theta += increment;
            }
        }
Exemple #6
0
        protected override void Draw(Settings settings)
        {
            base.Draw(settings);

            PolyShapesCallback callback = new PolyShapesCallback();

            callback.m_circle.Radius = 2.0f;
            callback.m_circle.Position.Set(0.0f, 1.1f);
            callback.m_transform.SetIdentity();
            callback.m_debugDraw = m_debugDraw;

            b2AABB aabb;

            callback.m_circle.ComputeAABB(out aabb, ref callback.m_transform, 0);

            m_world.QueryAABB(callback, aabb);

            b2Color color = new b2Color(0.4f, 0.7f, 0.8f);

            m_debugDraw.DrawCircle(callback.m_circle.Position, callback.m_circle.Radius, color);

            m_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff");
            m_textLine += 15;
            m_debugDraw.DrawString(5, m_textLine, "Press 'a' to (de)activate some bodies");
            m_textLine += 15;
            m_debugDraw.DrawString(5, m_textLine, "Press 'd' to destroy a body");
            m_textLine += 15;
        }
Exemple #7
0
 public virtual void DrawCircle(b2Vec2 center, float radius, b2Color color)
 {
     Box2DPINVOKE.b2Draw_DrawCircle(swigCPtr, b2Vec2.getCPtr(center), radius, b2Color.getCPtr(color));
     if (Box2DPINVOKE.SWIGPendingException.Pending)
     {
         throw Box2DPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #8
0
 public virtual void DrawSolidPolygon(b2Vec2 vertices, int vertexCount, b2Color color)
 {
     Box2DPINVOKE.b2Draw_DrawSolidPolygon(swigCPtr, b2Vec2.getCPtr(vertices), vertexCount, b2Color.getCPtr(color));
     if (Box2DPINVOKE.SWIGPendingException.Pending)
     {
         throw Box2DPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #9
0
 public virtual void DrawPoint(b2Vec2 p, float size, b2Color color)
 {
     Box2DPINVOKE.b2Draw_DrawPoint(swigCPtr, b2Vec2.getCPtr(p), size, b2Color.getCPtr(color));
     if (Box2DPINVOKE.SWIGPendingException.Pending)
     {
         throw Box2DPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #10
0
 public virtual void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     Box2DPINVOKE.b2Draw_DrawSegment(swigCPtr, b2Vec2.getCPtr(p1), b2Vec2.getCPtr(p2), b2Color.getCPtr(color));
     if (Box2DPINVOKE.SWIGPendingException.Pending)
     {
         throw Box2DPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #11
0
 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glBegin(Gl.GL_LINES);
     Gl.glVertex2f(p1.x, p1.y);
     Gl.glVertex2f(p2.x, p2.y);
     Gl.glEnd();
 }
 public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     b2Vec2[] alt = new b2Vec2[vertexCount];
     for (int i = 0; i < vertexCount; i++)
     {
         alt[i] = vertices[i] * PTMRatio + _Center;
     }
     CCDrawingPrimitives.DrawSolidPoly(alt, vertexCount, color);
 }
        public virtual void Draw(b2Draw draw)
        {
            b2Color c = new b2Color(0.4f, 0.5f, 0.7f);

            for (int i = 0; i < m_count - 1; ++i)
            {
                draw.DrawSegment(m_ps[i], m_ps[i + 1], c);
            }
        }
        public static void DrawLine(b2Vec2 origin, b2Vec2 destination, b2Color color)
        {
            float factor = CCDirector.SharedDirector.ContentScaleFactor;

            var c = new Color(color.r, color.g, color.b, 255);

            m_Batch.AddVertex(new Vector2(origin.x * factor, origin.y * factor), c, PrimitiveType.LineList);
            m_Batch.AddVertex(new Vector2(destination.x * factor, destination.y * factor), c, PrimitiveType.LineList);
        }
Exemple #15
0
 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     if (!primitiveBatch.IsReady())
     {
         throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
     }
     primitiveBatch.AddVertex(p1.ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
     primitiveBatch.AddVertex(p2.ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
 }
Exemple #16
0
 public void DrawPoint(b2Vec2 p, float size, b2Color color)
 {
     Gl.glPointSize(size);
     Gl.glBegin(Gl.GL_POINTS);
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glVertex2f(p.x, p.y);
     Gl.glEnd();
     Gl.glPointSize(1.0f);
 }
Exemple #17
0
        public void DrawAABB(b2AABB aabb, b2Color p1)
        {
            b2Vec2[] verts = new b2Vec2[4];
            verts[0] = new b2Vec2(aabb.LowerBound.x, aabb.LowerBound.y);
            verts[1] = new b2Vec2(aabb.UpperBound.x, aabb.LowerBound.y);
            verts[2] = new b2Vec2(aabb.UpperBound.x, aabb.UpperBound.y);
            verts[3] = new b2Vec2(aabb.LowerBound.x, aabb.UpperBound.y);

            DrawPolygon(verts, 4, p1);
        }
Exemple #18
0
 public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     for (int i = 0; i < vertexCount; ++i)
     {
         Gl.glVertex2f(vertices[i].x, vertices[i].y);
     }
     Gl.glEnd();
 }
Exemple #19
0
 public void DrawAABB(b2AABB aabb, b2Color c)
 {
     Gl.glColor3f(c.r, c.g, c.b);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     Gl.glVertex2f(aabb.lowerBound.x, aabb.lowerBound.y);
     Gl.glVertex2f(aabb.upperBound.x, aabb.lowerBound.y);
     Gl.glVertex2f(aabb.upperBound.x, aabb.upperBound.y);
     Gl.glVertex2f(aabb.lowerBound.x, aabb.upperBound.y);
     Gl.glEnd();
 }
Exemple #20
0
        public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            for (int i = 0; i < vertexCount - 1; i++)
            {
                DrawNode.AddLineVertex(vertices[i].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i + 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
            }

            DrawNode.AddLineVertex(vertices[vertexCount - 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
            DrawNode.AddLineVertex(vertices[0].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
        }
Exemple #21
0
        protected override void Draw(Settings settings)
        {
            base.Draw(settings);

            for (int i = 0; i < e_actorCount; ++i)
            {
                Actor actor = m_actors[i];
                if (actor.proxyId == b2_nullNode)
                {
                    continue;
                }

                b2Color c = new b2Color(0.9f, 0.9f, 0.9f);
                if (actor == m_rayActor && actor.overlap)
                {
                    c.Set(0.9f, 0.6f, 0.6f);
                }
                else if (actor == m_rayActor)
                {
                    c.Set(0.6f, 0.9f, 0.6f);
                }
                else if (actor.overlap)
                {
                    c.Set(0.6f, 0.6f, 0.9f);
                }

                m_debugDraw.DrawAABB(actor.aabb, c);
            }

            b2Color cc = new b2Color(0.7f, 0.7f, 0.7f);

            m_debugDraw.DrawAABB(m_queryAABB, cc);

            m_debugDraw.DrawSegment(m_rayCastInput.p1, m_rayCastInput.p2, cc);

            b2Color c1 = new b2Color(0.2f, 0.9f, 0.2f);
            b2Color c2 = new b2Color(0.9f, 0.2f, 0.2f);

            m_debugDraw.DrawPoint(m_rayCastInput.p1, 6.0f, c1);
            m_debugDraw.DrawPoint(m_rayCastInput.p2, 6.0f, c2);

            if (m_rayActor != null)
            {
                b2Color cr = new b2Color(0.2f, 0.2f, 0.9f);
                b2Vec2  p  = m_rayCastInput.p1 + m_rayActor.fraction * (m_rayCastInput.p2 - m_rayCastInput.p1);
                m_debugDraw.DrawPoint(p, 6.0f, cr);
            }

            {
                int height = m_tree.GetHeight();
                m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = {0}", height);
                m_textLine += 15;
            }
        }
Exemple #22
0
        public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            _list.Count = vertexCount;
            var alt = _list.Elements;

            for (int i = 0; i < vertexCount; i++)
            {
                alt[i] = vertices[i] * PTMRatio + _Center;
            }
            CCDrawingPrimitives.DrawSolidPoly(alt, vertexCount, color);
        }
Exemple #23
0
        public void DrawPoint(b2Vec2 p, float size, b2Color color)
        {
            b2Vec2[] verts = new b2Vec2[4];
            float    hs    = size / 2.0f;

            verts[0] = p + new b2Vec2(-hs, -hs);
            verts[1] = p + new b2Vec2(hs, -hs);
            verts[2] = p + new b2Vec2(hs, hs);
            verts[3] = p + new b2Vec2(-hs, hs);

            DrawSolidPolygon(verts, 4, color);
        }
Exemple #24
0
        protected override void Draw(Settings settings)
        {
            base.Draw(settings);

            b2DistanceInput input = b2DistanceInput.Create();

            input.proxyA.Set(m_polygonA, 0);
            input.proxyB.Set(m_polygonB, 0);
            input.transformA = m_transformA;
            input.transformB = m_transformB;
            input.useRadii   = true;
            b2SimplexCache cache = b2SimplexCache.Create();

            cache.count = 0;
            b2DistanceOutput output = new b2DistanceOutput();

            b2Simplex.b2Distance(ref output, ref cache, ref input);

            m_debugDraw.DrawString(5, m_textLine, "distance = {0}", output.distance);
            m_textLine += 15;

            m_debugDraw.DrawString(5, m_textLine, "iterations = {0}", output.iterations);
            m_textLine += 15;

            {
                b2Color  color = new b2Color(0.9f, 0.9f, 0.9f);
                b2Vec2[] v     = new b2Vec2[b2Settings.b2_maxPolygonVertices];
                for (int i = 0; i < m_polygonA.VertexCount; ++i)
                {
                    v[i] = b2Math.b2Mul(m_transformA, m_polygonA.Vertices[i]);
                }
                m_debugDraw.DrawPolygon(v, m_polygonA.VertexCount, color);

                for (int i = 0; i < m_polygonB.VertexCount; ++i)
                {
                    v[i] = b2Math.b2Mul(m_transformB, m_polygonB.Vertices[i]);
                }
                m_debugDraw.DrawPolygon(v, m_polygonB.VertexCount, color);
            }

            b2Vec2 x1 = output.pointA;
            b2Vec2 x2 = output.pointB;

            b2Color c1 = new b2Color(1.0f, 0.0f, 0.0f);

            m_debugDraw.DrawPoint(x1, 4.0f, c1);

            b2Color c2 = new b2Color(1.0f, 1.0f, 0.0f);

            m_debugDraw.DrawPoint(x2, 4.0f, c2);
        }
Exemple #25
0
        public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            if (!_primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            for (int i = 0; i < vertexCount - 1; i++)
            {
                _primitiveBatch.AddVertex(vertices[i].ToVector2(), color.ToColor(), PrimitiveType.LineList);
                _primitiveBatch.AddVertex(vertices[i + 1].ToVector2(), color.ToColor(), PrimitiveType.LineList);
            }

            _primitiveBatch.AddVertex(vertices[vertexCount - 1].ToVector2(), color.ToColor(), PrimitiveType.LineList);
            _primitiveBatch.AddVertex(vertices[0].ToVector2(), color.ToColor(), PrimitiveType.LineList);
        }
        public override void Draw(b2DebugDraw debugDraw)
        {
            float r = 1000;
            //Would like to draw a semi-transparent box
            //But debug draw doesn't support that
            b2Vec2 p1 = new b2Vec2();
            b2Vec2 p2 = new b2Vec2();

            p1.x = normal.x * offset + normal.y * r;
            p1.y = normal.y * offset - normal.x * r;
            p2.x = normal.x * offset - normal.y * r;
            p2.y = normal.y * offset + normal.x * r;
            b2Color color = new b2Color(0.0f, 0.0f, 1.0f);

            debugDraw.DrawSegment(p1, p2, color);
        }
Exemple #27
0
            public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
            {
                const float k_segments  = 16.0f;
                const float k_increment = (float)(2.0f * System.Math.PI / k_segments);
                float       theta       = 0.0f;

                Gl.glColor3f(color.r, color.g, color.b);
                Gl.glBegin(Gl.GL_LINE_LOOP);
                for (int i = 0; i < k_segments; ++i)
                {
                    b2Vec2 v = center + radius * new b2Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
                    Gl.glVertex2f(v.x, v.y);
                    theta += k_increment;
                }
                Gl.glEnd();
            }
Exemple #28
0
 /**
  * Draw a circle.
  */
 public void DrawCircle(b2Vec2 center, float radius, b2Color color)
 {
     for (float i = 0; i < 360.0f; i++)
     {
         if (i + 1.0f < 360.0f)
         {
             Debug.DrawLine(new Vector3((center.x + Mathf.Cos(i * 0.01745f) * radius) * m_drawScale, (center.y + Mathf.Sin(i * 0.01745f) * radius) * m_drawScale),
                            new Vector3((center.x + Mathf.Cos((i + 1.0f) * 0.01745f) * radius) * m_drawScale, (center.y + Mathf.Sin((i + 1.0f) * 0.01745f) * radius) * m_drawScale),
                            color.unityColor);
         }
         else
         {
             Debug.DrawLine(new Vector3((center.x + Mathf.Cos(i * 0.01745f) * radius) * m_drawScale, (center.y + Mathf.Sin(i * 0.01745f) * radius) * m_drawScale),
                            new Vector3((center.x + Mathf.Cos(0.0f) * radius) * m_drawScale, (center.y + Mathf.Sin(0.0f) * radius) * m_drawScale),
                            color.unityColor);
         }
     }
 }
Exemple #29
0
 /**
  * Draw a solid closed polygon provided in CCW order.
  */
 public void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     for (int i = 0; i < vertexCount; i++)
     {
         if (i + 1 < vertexCount)
         {
             Debug.DrawLine(new Vector3(vertices[i].x * m_drawScale, vertices[i].y * m_drawScale),
                            new Vector3(vertices[i + 1].x * m_drawScale, vertices[i + 1].y * m_drawScale),
                            color.unityColor);
         }
         else
         {
             Debug.DrawLine(new Vector3(vertices[i].x * m_drawScale, vertices[i].y * m_drawScale),
                            new Vector3(vertices[0].x * m_drawScale, vertices[0].y * m_drawScale),
                            color.unityColor);
         }
     }
 }
Exemple #30
0
    private void testQueryShape_circle()
    {
        Vector3 mousePos        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        b2WorldQueryCallback cb = delegate(b2Fixture fixture) {
            b2Body body = fixture.GetBody();
            body.SetAwake(true);
            return(true);
        };

        b2CircleShape shape = new b2CircleShape(200.0f / ptm_ratio);

        b2Transform transform = new b2Transform(new b2Vec2(mousePos.x, mousePos.y), b2Mat22.FromAngle(0));

        _world.QueryShape(cb, shape, transform);

        b2Color color = new b2Color(1.0f, 0.0f, 0.0f);

        _debugDraw.DrawCircle(new b2Vec2(mousePos.x, mousePos.y), 200.0f / ptm_ratio, color);
    }
Exemple #31
0
            public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
            {
                Gl.glEnable(Gl.GL_BLEND);
                Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
                Gl.glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
                Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                for (int i = 0; i < vertexCount; ++i)
                {
                    Gl.glVertex2f(vertices[i].x, vertices[i].y);
                }
                Gl.glEnd();
                Gl.glDisable(Gl.GL_BLEND);

                Gl.glColor4f(color.r, color.g, color.b, 1.0f);
                Gl.glBegin(Gl.GL_LINE_LOOP);
                for (int i = 0; i < vertexCount; ++i)
                {
                    Gl.glVertex2f(vertices[i].x, vertices[i].y);
                }
                Gl.glEnd();
            }
Exemple #32
0
 public void DrawAABB(b2AABB aabb, b2Color c)
 {
     Gl.glColor3f(c.r, c.g, c.b);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     Gl.glVertex2f(aabb.lowerBound.x, aabb.lowerBound.y);
     Gl.glVertex2f(aabb.upperBound.x, aabb.lowerBound.y);
     Gl.glVertex2f(aabb.upperBound.x, aabb.upperBound.y);
     Gl.glVertex2f(aabb.lowerBound.x, aabb.upperBound.y);
     Gl.glEnd();
 }
Exemple #33
0
 public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
 {
     const float k_segments = 16.0f;
     const float k_increment = (float)(2.0f * System.Math.PI / k_segments);
     float theta = 0.0f;
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     for (int i = 0; i < k_segments; ++i)
     {
         b2Vec2 v = center + radius * new b2Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
         Gl.glVertex2f(v.x, v.y);
         theta += k_increment;
     }
     Gl.glEnd();
 }
Exemple #34
0
 public void DrawPoint(b2Vec2 p, float size, b2Color color)
 {
     Gl.glPointSize(size);
     Gl.glBegin(Gl.GL_POINTS);
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glVertex2f(p.x, p.y);
     Gl.glEnd();
     Gl.glPointSize(1.0f);
 }
Exemple #35
0
 public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glBegin(Gl.GL_LINE_LOOP);
     for (int i = 0; i < vertexCount; ++i)
     {
         Gl.glVertex2f(vertices[i].x, vertices[i].y);
     }
     Gl.glEnd();
 }
Exemple #36
0
 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     Gl.glColor3f(color.r, color.g, color.b);
     Gl.glBegin(Gl.GL_LINES);
     Gl.glVertex2f(p1.x, p1.y);
     Gl.glVertex2f(p2.x, p2.y);
     Gl.glEnd();
 }
Exemple #37
0
            public override void DrawSolidCircle(b2Vec2 center, float radius, b2Vec2 axis, b2Color color)
            {
                const float k_segments = 16.0f;
                const float k_increment = (float)(2.0f * System.Math.PI / k_segments);
                float theta = 0.0f;
                Gl.glEnable(Gl.GL_BLEND);
                Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
                Gl.glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
                Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                for (int i = 0; i < k_segments; ++i)
                {
                    b2Vec2 v = center + radius * new b2Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
                    Gl.glVertex2f(v.x, v.y);
                    theta += k_increment;
                }
                Gl.glEnd();
                Gl.glDisable(Gl.GL_BLEND);

                theta = 0.0f;
                Gl.glColor4f(color.r, color.g, color.b, 1.0f);
                Gl.glBegin(Gl.GL_LINE_LOOP);
                for (int i = 0; i < k_segments; ++i)
                {
                    b2Vec2 v = center + radius * new b2Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
                    Gl.glVertex2f(v.x, v.y);
                    theta += k_increment;
                }
                Gl.glEnd();

                b2Vec2 p = center + radius * axis;
                Gl.glBegin(Gl.GL_LINES);
                Gl.glVertex2f(center.x, center.y);
                Gl.glVertex2f(p.x, p.y);
                Gl.glEnd();
            }