This project is read-only.


The DebugDrawer is a utility class you can quickly drop into your project to add some debugging overlays to your scene. It allows you to draw 3D arrows, boxes and triangles into your scene with a single calls, thereby enabling you to visualize vectors, bounding boxes or individual polygons.



Using the debug drawer is intentionally simple. It concentrates on just one purpose and doesn't require any initialization work or configuration.

1. Make sure the debug drawer's namespace is imported
using Nuclex.Graphics.Debugging;

2. Add a field for the debug drawer in your Game class
/// <summary>Draws debugging overlays into the scene</summary>
private DebugDrawer debugDrawer;}}
3. Create an instance of the DebugDrawer class in your Initialize() method
/// <summary>
///   Allows the game to perform any initialization it needs to before starting to run.
///   This is where it can query for any required services and load any non-graphic
///   related content. Calling base.Initialize will enumerate through any components
///   and initialize them as well.
/// </summary>
protected override void Initialize() {
  this.debugDrawer = new DebugDrawer(GraphicsDevice);

4. In your Draw() method, hand your projection and view matrices to the DebugDrawer and draw something
/// <summary>This is called when the game should draw itself.</summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime) {

  this.debugDrawer.ViewProjection = *;
  // ...other drawing code...
    Vector3.Zero, Vector3.Forward, Color.Green
  // ...more other drawing code...

  // Render everything the debug drawer has queued on top of the scene

Last edited Sep 12, 2009 at 7:42 PM by Cygon, version 4


No comments yet.