DrawPoint() public static method

public static DrawPoint ( Vec2 p, float size, Color color ) : void
p Box2DX.Common.Vec2
size float
color Box2DX.Dynamics.Color
return void
示例#1
0
        public override void Step(Settings settings)
        {
            base.Step(settings);

            DistanceInput input = new DistanceInput();

            input.TransformA = _transformA;
            input.TransformB = _transformB;
            input.UseRadii   = true;
            SimplexCache cache = new SimplexCache();

            cache.Count = 0;
            DistanceOutput output;

            Collision.Distance(out output, ref cache, ref input, _polygonA, _polygonB);

            StringBuilder strBld = new StringBuilder();

            strBld.AppendFormat("distance = {0}", new object[] { output.Distance });
            OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString());
            _textLine += 15;

            strBld = new StringBuilder();
            strBld.AppendFormat("iterations = {0}", new object[] { output.Iterations });
            OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString());
            _textLine += 15;

            {
                Color color = new Color(0.9f, 0.9f, 0.9f);
                int   i;
                for (i = 0; i < _polygonA.VertexCount; ++i)
                {
                    _dv[i] = Math.Mul(_transformA, _polygonA.Vertices[i]);
                }
                _debugDraw.DrawPolygon(_dv, _polygonA.VertexCount, color);

                for (i = 0; i < _polygonB.VertexCount; ++i)
                {
                    _dv[i] = Math.Mul(_transformB, _polygonB.Vertices[i]);
                }
                _debugDraw.DrawPolygon(_dv, _polygonB.VertexCount, color);
            }

            Vec2 x1 = output.PointA;
            Vec2 x2 = output.PointB;

            OpenGLDebugDraw.DrawPoint(x1, 4.0f, new Color(1, 0, 0));
            OpenGLDebugDraw.DrawSegment(x1, x2, new Color(1, 1, 0));
            OpenGLDebugDraw.DrawPoint(x2, 4.0f, new Color(1, 0, 0));
        }
示例#2
0
        public override void Step(Settings settings)
        {
            settings.pause = 1;
            base.Step(settings);
            settings.pause = 0;

            Vec2  x1, x2;
            float distance = Collision.Distance(out x1, out x2, _shape1, _body1.GetXForm(), _shape2, _body2.GetXForm());

            StringBuilder strBld = new StringBuilder();

            strBld.AppendFormat("distance = {0}", new object[] { distance });
            OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString());
            _textLine += 15;

            strBld = new StringBuilder();
            strBld.AppendFormat("iterations = {0}", new object[] { Collision.GJKIterations });
            OpenGLDebugDraw.DrawString(5, _textLine, strBld.ToString());
            _textLine += 15;

            OpenGLDebugDraw.DrawPoint(x1, 4.0f, new Color(1, 0, 0));
            OpenGLDebugDraw.DrawSegment(x1, x2, new Color(1, 0, 0));
            OpenGLDebugDraw.DrawPoint(x2, 4.0f, new Color(1, 0, 0));
        }
示例#3
0
        public virtual void Step(Settings settings)
        {
            float timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f;

            if (settings.pause != 0)
            {
                if (settings.singleStep != 0)
                {
                    settings.singleStep = 0;
                }
                else
                {
                    timeStep = 0.0f;
                }

                OpenGLDebugDraw.DrawString(5, _textLine, "****PAUSED****");
                _textLine += 15;
            }

            uint flags = 0;

            flags           += (uint)settings.drawShapes * (uint)DebugDraw.DrawFlags.Shape;
            flags           += (uint)settings.drawJoints * (uint)DebugDraw.DrawFlags.Joint;
            flags           += (uint)settings.drawCoreShapes * (uint)DebugDraw.DrawFlags.CoreShape;
            flags           += (uint)settings.drawAABBs * (uint)DebugDraw.DrawFlags.Aabb;
            flags           += (uint)settings.drawOBBs * (uint)DebugDraw.DrawFlags.Obb;
            flags           += (uint)settings.drawPairs * (uint)DebugDraw.DrawFlags.Pair;
            flags           += (uint)settings.drawCOMs * (uint)DebugDraw.DrawFlags.CenterOfMass;
            flags           += (uint)settings.drawController * (uint)DebugDraw.DrawFlags.Controller;
            _debugDraw.Flags = (DebugDraw.DrawFlags)flags;

            _world.SetWarmStarting(settings.enableWarmStarting > 0);
            _world.SetContinuousPhysics(settings.enableTOI > 0);

            _pointCount = 0;

            _world.Step(timeStep, settings.velocityIterations, settings.positionIterations);

            _world.Validate();

            if (_bomb != null && _bomb.IsFrozen())
            {
                _world.DestroyBody(_bomb);
                _bomb = null;
            }

            if (settings.drawStats != 0)
            {
                OpenGLDebugDraw.DrawString(5, _textLine, String.Format("proxies(max) = {0}({1}), pairs(max) = {2}({3})",
                                                                       new object[] { _world.GetProxyCount(), Box2DX.Common.Settings.MaxProxies,
                                                                                      _world.GetPairCount(), Box2DX.Common.Settings.MaxProxies }));
                _textLine += 15;

                OpenGLDebugDraw.DrawString(5, _textLine, String.Format("bodies/contacts/joints = {0}/{1}/{2}",
                                                                       new object[] { _world.GetBodyCount(), _world.GetContactCount(), _world.GetJointCount() }));
                _textLine += 15;
            }

            if (_mouseJoint != null)
            {
                Body body = _mouseJoint.GetBody2();
                Vec2 p1   = body.GetWorldPoint(_mouseJoint._localAnchor);
                Vec2 p2   = _mouseJoint._target;

                Gl.glPointSize(4.0f);
                Gl.glColor3f(0.0f, 1.0f, 0.0f);
                Gl.glBegin(Gl.GL_POINTS);
                Gl.glVertex2f(p1.X, p1.Y);
                Gl.glVertex2f(p2.X, p2.Y);
                Gl.glEnd();
                Gl.glPointSize(1.0f);

                Gl.glColor3f(0.8f, 0.8f, 0.8f);
                Gl.glBegin(Gl.GL_LINES);
                Gl.glVertex2f(p1.X, p1.Y);
                Gl.glVertex2f(p2.X, p2.Y);
                Gl.glEnd();
            }

            if (settings.drawContactPoints != 0)
            {
                //float k_forceScale = 0.01f;
                float k_axisScale = 0.3f;

                for (int i = 0; i < _pointCount; ++i)
                {
                    MyContactPoint point = _points[i];

                    if (point.state == ContactState.ContactAdded)
                    {
                        // Add
                        OpenGLDebugDraw.DrawPoint(point.position, 10.0f, new Color(0.3f, 0.95f, 0.3f));
                    }
                    else if (point.state == ContactState.ContactPersisted)
                    {
                        // Persist
                        OpenGLDebugDraw.DrawPoint(point.position, 5.0f, new Color(0.3f, 0.3f, 0.95f));
                    }
                    else
                    {
                        // Remove
                        OpenGLDebugDraw.DrawPoint(point.position, 10.0f, new Color(0.95f, 0.3f, 0.3f));
                    }

                    if (settings.drawContactNormals == 1)
                    {
                        Vec2 p1 = point.position;
                        Vec2 p2 = p1 + k_axisScale * point.normal;
                        OpenGLDebugDraw.DrawSegment(p1, p2, new Color(0.4f, 0.9f, 0.4f));
                    }
                    else if (settings.drawContactForces == 1)
                    {
                        /*Vector2 p1 = point.position;
                         * Vector2 p2 = p1 + k_forceScale * point.normalForce * point.normal;
                         * OpenGLDebugDraw.DrawSegment(p1, p2, new Color(0.9f, 0.9f, 0.3f));*/
                    }

                    if (settings.drawFrictionForces == 1)
                    {
                        /*Vector2 tangent = Vector2.Cross(point.normal, 1.0f);
                         * Vector2 p1 = point.position;
                         * Vector2 p2 = p1 + k_forceScale * point.tangentForce * tangent;
                         * OpenGLDebugDraw.DrawSegment(p1, p2, new Color(0.9f, 0.9f, 0.3f));*/
                    }
                }
            }
        }