public override void Update(GameSettings settings, GameTime gameTime)
        {
            base.Update(settings, gameTime);

            PolyShapesCallback callback = new PolyShapesCallback();

            callback.Circle.Radius   = 2.0f;
            callback.Circle.Position = new Vector2(0.0f, 1.1f);
            callback.Transform.SetIdentity();
            callback.DebugDraw = DebugView;

            AABB aabb;

            callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0);

            DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
            World.QueryAABB(callback.ReportFixture, ref aabb);

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

            DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color);
            DebugView.EndCustomDraw();

            DrawString("Press 1-5 to drop stuff");
            DrawString("Press a to (de)activate some bodies");
            DrawString("Press d to destroy a body");
        }
        public override void Update(GameSettings settings, GameTime gameTime)
        {
            base.Update(settings, gameTime);

            PolygonShapesCallback callback = new PolygonShapesCallback();

            callback._circle.Radius   = 2.0f;
            callback._circle.Position = new Vector2(0.0f, 1.1f);
            callback._transform.SetIdentity();
            callback._debugView  = DebugView;
            callback._projection = GameInstance.Projection;
            callback._view       = GameInstance.View;

            AABB aabb;

            callback._circle.ComputeAABB(ref callback._transform, 0, out aabb);

            World.QueryAABB(callback.ReportFixture, ref aabb);

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

            DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
            DebugView.DrawCircle(callback._circle.Position, callback._circle.Radius, color);
            DebugView.EndCustomDraw();

            DrawString($"Press 1-5 to drop stuff, maximum of {PolygonShapesCallback.MaxCount} overlaps detected");
            DrawString("Press 'a' to enable/disable some bodies");
            DrawString("Press 'd' to destroy a body");
        }
        public override void Update(GameSettings settings, float elapsedSeconds)
        {
            base.Update(settings, elapsedSeconds);

            PolyShapesCallback callback = new PolyShapesCallback();

            callback.Circle.Radius   = 2.0f;
            callback.Circle.Position = new Vector2(0.0f, 1.1f);
            callback.Transform       = Transform.Identity;
            callback.DebugDraw       = DebugView;

            AABB aabb;

            callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0);

            DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
            World.FindFixtures(callback.ReportFixture, ref aabb);

            Color color = ColorHelper.FromPercentages(0.4f, 0.7f, 0.8f);

            DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color);
            DebugView.EndCustomDraw();

            DrawString("Press 1-5 to drop stuff");
            DrawString("Press a to (de)activate some bodies");
            DrawString("Press d to destroy a body");
        }
Beispiel #4
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            base.Update(settings);

            DrawString("Press: (,) to explode at mouse position.");

            DrawString("Press: (A) to decrease the explosion radius, (S) to increase it.");

            DrawString("Press: (D) to decrease the explosion power, (F) to increase it.");

            // Fighting against double decimals
            double powernumber = (double)((int)(_force * 10)) / 10;

            DrawString("Power: " + powernumber);

            Color color = new ColorR(0.4f, 0.7f, 0.8f);

            DebugView.DrawCircle(_mousePos, _radius, color);
        }
        public override void Update(GameSettings settings, GameTime gameTime)
        {
            base.Update(settings, gameTime);

            DrawString("Press: (,) to explode at mouse position.");
            
            DrawString("Press: (A) to decrease the explosion radius, (S) to increase it.");
            
            DrawString("Press: (D) to decrease the explosion power, (F) to increase it.");
            
            // Fighting against float decimals
            float powernumber = (float)((int)(_force * 10)) / 10;
            DrawString("Power: " + powernumber);

            Color color = new Color(0.4f, 0.7f, 0.8f);
            DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
            DebugView.DrawCircle(_mousePos, _radius, color);

            DebugView.EndCustomDraw();
        }
 public void DrawPointForce()
 {
     DebugView.DrawPoint(_simpleWind.Position, 2, Color.Red);
     DebugView.DrawCircle(_simpleWind.Position, _simpleWind.DecayStart, Color.Green);
     DebugView.DrawCircle(_simpleWind.Position, _simpleWind.DecayEnd, Color.Red);
 }
        public override void Update(GameSettings settings, GameTime gameTime)
        {
            base.Update(settings, gameTime);

            ShapeCastInput input = new ShapeCastInput();

            input.ProxyA       = new DistanceProxy(_vAs, _radiusA);
            input.ProxyB       = new DistanceProxy(_vBs, _radiusB);
            input.TransformA   = _transformA;
            input.TransformB   = _transformB;
            input.TranslationB = _translationB;

            ShapeCastOutput output;
            bool            hit = DistanceGJK.ShapeCast(ref input, out output);

            Transform transformB2;

            transformB2.q = _transformB.q;
            transformB2.p = _transformB.p + output.Lambda * input.TranslationB;

            DistanceInput distanceInput = new DistanceInput();

            distanceInput.ProxyA     = new DistanceProxy(_vAs, _radiusA);
            distanceInput.ProxyB     = new DistanceProxy(_vBs, _radiusB);
            distanceInput.TransformA = _transformA;
            distanceInput.TransformB = transformB2;
            distanceInput.UseRadii   = false;
            SimplexCache   simplexCache;
            DistanceOutput distanceOutput;

            DistanceGJK.ComputeDistance(ref distanceInput, out distanceOutput, out simplexCache);

            DrawString($"hit = {(hit ? "true" : "false")}, iters = {output.Iterations}, lambda = {output.Lambda}, distance = {distanceOutput.Distance}");

            Vector2[] vertices = new Vector2[Settings.MaxPolygonVertices];

            for (int i = 0; i < _countA; ++i)
            {
                vertices[i] = MathUtils.Mul(ref _transformA, _vAs[i]);
            }

            DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);

            if (_countA == 1)
            {
                DebugView.DrawCircle(vertices[0], _radiusA, new Color(0.9f, 0.9f, 0.9f));
            }
            else
            {
                DebugView.DrawPolygon(vertices, _countA, new Color(0.9f, 0.9f, 0.9f));
            }

            for (int i = 0; i < _countB; ++i)
            {
                vertices[i] = MathUtils.Mul(ref _transformB, _vBs[i]);
            }

            if (_countB == 1)
            {
                DebugView.DrawCircle(vertices[0], _radiusB, new Color(0.5f, 0.9f, 0.5f));
            }
            else
            {
                DebugView.DrawPolygon(vertices, _countB, new Color(0.5f, 0.9f, 0.5f));
            }

            for (int i = 0; i < _countB; ++i)
            {
                vertices[i] = MathUtils.Mul(ref transformB2, _vBs[i]);
            }

            if (_countB == 1)
            {
                DebugView.DrawCircle(vertices[0], _radiusB, new Color(0.5f, 0.7f, 0.9f));
            }
            else
            {
                DebugView.DrawPolygon(vertices, _countB, new Color(0.5f, 0.7f, 0.9f));
            }

            if (hit)
            {
                Vector2 p1 = output.Point;
                DebugView.DrawPoint(p1, 10.0f, new Color(0.9f, 0.3f, 0.3f));
                Vector2 p2 = p1 + output.Normal;
                DebugView.DrawSegment(p1, p2, new Color(0.9f, 0.3f, 0.3f));
            }

            DebugView.EndCustomDraw();
        }