This tests stacking. It also shows how to use World.Query() and AABB.TestOverlap(). This callback is called by World.QueryAABB(). We find all the fixtures that overlap an AABB. Of those, we use AABB.TestOverlap() to determine which fixtures overlap a circle. Up to 4 overlapped fixtures will be highlighted with a yellow border.
Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }