Similar to javax.vecmath.Color3f holder
Exemplo n.º 1
0
        private void DrawShape(Fixture fixture, Transform xf, Color3f color)
        {
            switch (fixture.Type)
            {

                case ShapeType.Circle:
                    {
                        CircleShape circle = (CircleShape)fixture.Shape;

                        // Vec2 center = Mul(xf, circle.m_p);
                        Transform.MulToOutUnsafe(xf, circle.P, center);
                        float radius = circle.Radius;
                        xf.Q.GetXAxis(axis);

                        if (fixture.UserData != null && fixture.UserData.Equals(LIQUID_INT))
                        {
                            Body b = fixture.Body;
                            liquidOffset.Set(b.LinearVelocity);
                            float linVelLength = b.LinearVelocity.Length();
                            if (averageLinearVel == -1)
                            {
                                averageLinearVel = linVelLength;
                            }
                            else
                            {
                                averageLinearVel = .98f * averageLinearVel + .02f * linVelLength;
                            }
                            liquidOffset.MulLocal(LIQUID_LENGTH / averageLinearVel / 2);
                            circCenterMoved.Set(center).AddLocal(liquidOffset);
                            center.SubLocal(liquidOffset);
                            DebugDraw.DrawSegment(center, circCenterMoved, liquidColor);
                            return;
                        }

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

                case ShapeType.Polygon:
                    {
                        PolygonShape poly = (PolygonShape)fixture.Shape;
                        int vertexCount = poly.VertexCount;
                        Debug.Assert(vertexCount <= Settings.MAX_POLYGON_VERTICES);
                        Vec2[] vertices = tlvertices.Get(Settings.MAX_POLYGON_VERTICES);

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

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

                case ShapeType.Edge:
                    {
                        EdgeShape edge = (EdgeShape)fixture.Shape;
                        Transform.MulToOutUnsafe(xf, edge.Vertex1, v1);
                        Transform.MulToOutUnsafe(xf, edge.Vertex2, v2);
                        DebugDraw.DrawSegment(v1, v2, color);
                    }
                    break;

                case ShapeType.Chain:
                    {
                        ChainShape chain = (ChainShape)fixture.Shape;
                        int count = chain.Count;
                        Vec2[] vertices = chain.Vertices;

                        Transform.MulToOutUnsafe(xf, vertices[0], v1);
                        for (int i = 1; i < count; ++i)
                        {
                            Transform.MulToOutUnsafe(xf, vertices[i], v2);
                            DebugDraw.DrawSegment(v1, v2, color);
                            DebugDraw.DrawCircle(v1, 0.05f, color);
                            v1.Set(v2);
                        }
                    }
                    break;
            }
        }
Exemplo n.º 2
0
        private void drawShape(Fixture fixture, Transform xf, Color3f color)
        {
            switch (fixture.Type)
            {

                case ShapeType.CIRCLE:
                    {
                        CircleShape circle = (CircleShape)fixture.Shape;

                        // Vec2 center = Mul(xf, circle.m_p);
                        Transform.mulToOutUnsafe(xf, circle.m_p, center);
                        float radius = circle.m_radius;
                        xf.q.getXAxis(axis);

                        if (fixture.UserData != null && fixture.UserData.Equals(LIQUID_INT))
                        {
                            Body b = fixture.Body;
                            liquidOffset.set_Renamed(b.m_linearVelocity);
                            float linVelLength = b.m_linearVelocity.length();
                            if (averageLinearVel == -1)
                            {
                                averageLinearVel = linVelLength;
                            }
                            else
                            {
                                averageLinearVel = .98f * averageLinearVel + .02f * linVelLength;
                            }
                            liquidOffset.mulLocal(liquidLength / averageLinearVel / 2);
                            circCenterMoved.set_Renamed(center).addLocal(liquidOffset);
                            center.subLocal(liquidOffset);
                            m_debugDraw.drawSegment(center, circCenterMoved, liquidColor);
                            return;
                        }

                        m_debugDraw.drawSolidCircle(center, radius, axis, color);
                    }
                    break;

                case ShapeType.POLYGON:
                    {
                        PolygonShape poly = (PolygonShape)fixture.Shape;
                        int vertexCount = poly.m_count;
                        Debug.Assert(vertexCount <= Settings.maxPolygonVertices);
                        Vec2[] vertices = tlvertices.get_Renamed(Settings.maxPolygonVertices);

                        for (int i = 0; i < vertexCount; ++i)
                        {
                            // vertices[i] = Mul(xf, poly.m_vertices[i]);
                            Transform.mulToOutUnsafe(xf, poly.m_vertices[i], vertices[i]);
                        }

                        m_debugDraw.drawSolidPolygon(vertices, vertexCount, color);
                    }
                    break;

                case ShapeType.EDGE:
                    {
                        EdgeShape edge = (EdgeShape)fixture.Shape;
                        Transform.mulToOutUnsafe(xf, edge.m_vertex1, v1);
                        Transform.mulToOutUnsafe(xf, edge.m_vertex2, v2);
                        m_debugDraw.drawSegment(v1, v2, color);
                    }
                    break;

                case ShapeType.CHAIN:
                    {
                        ChainShape chain = (ChainShape)fixture.Shape;
                        int count = chain.m_count;
                        Vec2[] vertices = chain.m_vertices;

                        Transform.mulToOutUnsafe(xf, vertices[0], v1);
                        for (int i = 1; i < count; ++i)
                        {
                            Transform.mulToOutUnsafe(xf, vertices[i], v2);
                            m_debugDraw.drawSegment(v1, v2, color);
                            m_debugDraw.drawCircle(v1, 0.05f, color);
                            v1.set_Renamed(v2);
                        }
                    }
                    break;

                default:
                    break;

            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Draw a string.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="s"></param>
 /// <param name="color"></param>
 public abstract void DrawString(float x, float y, String s, Color3f color);
Exemplo n.º 4
0
 public void DrawString(Vec2 pos, String s, Color3f color)
 {
     DrawString(pos.X, pos.Y, s, color);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Draw a solid circle.
 /// </summary>
 /// <param name="center"></param>
 /// <param name="radius"></param>
 /// <param name="axis"></param>
 /// <param name="color"></param>
 public abstract void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color);
Exemplo n.º 6
0
 /// <summary>
 /// Draw a solid closed polygon provided in CCW order.
 /// </summary>
 /// <param name="vertices"></param>
 /// <param name="vertexCount"></param>
 /// <param name="color"></param>
 public abstract void DrawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color);
Exemplo n.º 7
0
 /// <summary>
 /// Draw a line segment.
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <param name="color"></param>
 public abstract void DrawSegment(Vec2 p1, Vec2 p2, Color3f color);
Exemplo n.º 8
0
        /// <summary>
        /// Draw a closed polygon provided in CCW order.  This implementation
        /// uses {@link #drawSegment(Vec2, Vec2, Color3f)} to draw each side of the
        /// polygon.
        /// </summary>
        /// <param name="vertices"></param>
        /// <param name="vertexCount"></param>
        /// <param name="color"></param>
        public void DrawPolygon(Vec2[] vertices, int vertexCount, Color3f color)
        {
            if (vertexCount == 1)
            {
                DrawSegment(vertices[0], vertices[0], color);
                return;
            }

            for (int i = 0; i < vertexCount - 1; i += 1)
            {
                DrawSegment(vertices[i], vertices[i + 1], color);
            }

            if (vertexCount > 2)
            {
                DrawSegment(vertices[vertexCount - 1], vertices[0], color);
            }
        }
Exemplo n.º 9
0
 public abstract void DrawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor);
Exemplo n.º 10
0
 /// <summary>
 /// Draw a circle.
 /// </summary>
 /// <param name="center"></param>
 /// <param name="radius"></param>
 /// <param name="color"></param>
 public abstract void DrawCircle(Vec2 center, float radius, Color3f color);
Exemplo n.º 11
0
 public void drawString(Vec2 pos, String s, Color3f color)
 {
     drawString(pos.x, pos.y, s, color);
 }