using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace BouncyCatIsBouncy.Debugging { static class RadialBBRenderer { static Texture2D s_radialTexture; const float RADIUS = 100f; static readonly Vector2 ORIGIN = new Vector2(RADIUS, RADIUS); static LineBrush s_brush; static bool s_initialized; static private void Init(GraphicsDevice device) { s_radialTexture = DrawingHelper.CreateCircleTexture(device, (int)RADIUS, 3, Color.Blue); s_brush = new LineBrush(2, Color.Blue); s_brush.Load(device); s_initialized = true; } [Conditional("DEBUG")] static public void Draw(SpriteBatch spriteBatch, RadialBB boundingBox) { Debug.Assert(spriteBatch != null); if (!s_initialized) Init(spriteBatch.GraphicsDevice); var scale = boundingBox.Radius / RADIUS; spriteBatch.Draw(s_radialTexture, boundingBox.Center, null, Color.White, 0.0f, ORIGIN, scale, SpriteEffects.None, 1.0f); const float LENGTH = 10.0f; s_brush.Draw(spriteBatch, boundingBox.Center + new Vector2(LENGTH, 0f), boundingBox.Center - new Vector2(LENGTH, 0f)); s_brush.Draw(spriteBatch, boundingBox.Center + new Vector2(0f, LENGTH), boundingBox.Center - new Vector2(0f, LENGTH)); } } }