---
title: "Draw replay wireframe overlays in C#"
url: https://recursiveai.org/onescope/cookbook/draw-wireframe-replay-overlays/
description: "Draw wireframe geometry in a C# simulation replay. Use OneScope DrawStyle flags for edges, a toggleable bounds overlay, and lines that stay visible through solids."
version: "1.0.0"
---

# Draw replay wireframe overlays in C#

**OneScope** is a free, open-source viewer for simulation recordings, with a desktop window or command-line control, from Recursive AI. MIT or Apache-2.0.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneScope.Sdk) · [GitHub](https://github.com/recursive-ai-oss/onescope-csharp) · [Docs](https://recursiveai.org/onescope/docs/) · [Download example (.zip)](https://recursiveai.org/onescope/cookbook/draw-wireframe-replay-overlays/draw-wireframe-replay-overlays.zip)

Show a box’s bounds without filling it.

```shell
dotnet add package RecursiveAI.OneScope.Sdk
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneScope.Sdk;
using Rot = System.Numerics.Quaternion;
var frame = new DrawList();
var style = new DrawStyle(Color32.White,
    Flags: DrawFlags.Wireframe);
frame.Box(new(0), new(1), Rot.Identity, style);
Console.WriteLine(frame.Items[0].Flags);
```

Unzip [the example](https://recursiveai.org/onescope/cookbook/draw-wireframe-replay-overlays/draw-wireframe-replay-overlays.zip), then `dotnet run`.

```text
Wireframe
```

The console example submits a draw item and prints its flag; it doesn’t open a replay window. In a OneScope module, add the box to the `DrawList` passed to `IScopeWorld.Draw`.

To see the outline in the replay viewer, [write and load a OneScope replay module](https://recursiveai.org/onescope/cookbook/write-a-onescope-module/).

## The full program

The example submits a solid box and a slightly larger wireframe box at the same position. It takes no input files. The sizes passed to `Box` are half extents, so `Vector3.One` gives a box two units wide along each axis.

```csharp
using System.Numerics;
using OneScope.Sdk;

const int boundsOverlay = 1;
var overlay = new OverlayInfo(boundsOverlay, "Bounds", DefaultOn: true);
var frame = new DrawList();

// In a replay module, use the current frame's position and rotation.
var center = new Vector3(3, 0, 2);
var rotation = Quaternion.Identity;
var body = new DrawStyle(Color32.White);
var bounds = new DrawStyle(new Color32(255, 190, 0, 255), Overlay: overlay.Id,
    Flags: DrawFlags.Wireframe);

frame.Box(center, new Vector3(0.75f), rotation, body);
frame.Box(center, Vector3.One, rotation, bounds);

Console.WriteLine($"{overlay.Name} overlay: default on = {overlay.DefaultOn}");
foreach (var item in frame.Items)
    Console.WriteLine($"{item.Kind}: overlay {item.Overlay}, {item.Flags}");
```

```text
Bounds overlay: default on = True
Box: overlay 0, None
Box: overlay 1, Wireframe
```

In your module, include the `OverlayInfo` in `SourceInfo.Overlays` to give the bounds their own toggle. If the overlay is off in the view, the shell hides items with that overlay ID even though they’re in the draw list.

## Variations

To keep the bounds visible even when a solid object is in front of them in 3D, replace the `bounds` declaration in the full program with this one:

```csharp
var bounds = new DrawStyle(new Color32(255, 190, 0, 255),
    Overlay: overlay.Id,
    Flags: DrawFlags.Wireframe | DrawFlags.OnTop);
```

The second box now prints:

```text
Box: overlay 1, Wireframe, OnTop
```

## Related recipes

- [Write a OneScope replay module](https://recursiveai.org/onescope/cookbook/write-a-onescope-module/)
- [Draw entity links in a replay](https://recursiveai.org/onescope/cookbook/draw-entity-links-in-replay/)
- [Overlay reference poses on a replay](https://recursiveai.org/onescope/cookbook/overlay-reference-pose-cache/)

## The short answer

Set `DrawStyle.Flags` to `DrawFlags.Wireframe` on the geometry you want to show as edges. Give those items their own overlay ID so you can turn them off without hiding the solid scene. Add `DrawFlags.OnTop` if the edges should remain visible through other objects in the 3D view.

## How do you draw a wireframe over a solid model?

Submit two draw items: one for the solid model and one for the geometry you want to outline. They don’t have to be the same shape. A wireframe box works well when you want to see the volume around a body without seeing every triangle of its mesh. To inspect how a mesh is triangulated instead, submit the mesh with `DrawFlags.Wireframe`. The [3D renderer’s mesh path](https://github.com/recursive-ai-oss/onescope-csharp/blob/d681be56420836ea0d8874416367bc8181235813/src/OneScope.App/Space3DRenderer.cs#L210-L221) draws all three edges of each triangle, so a face split into two triangles also shows the diagonal.

Build the overlay from the position and rotation of the frame you’re viewing, not from the newest state of the simulation. The viewer [clears and refills the draw list each frame](https://recursiveai.org/onescope/docs/module-authoring/#the-draw-list), so when you seek backward the outline follows the pose at that step. To keep the body pickable, set its `EntityId` on the solid item. The [picker](https://github.com/recursive-ai-oss/onescope-csharp/blob/d681be56420836ea0d8874416367bc8181235813/src/OneScope.App/Picker.cs#L111-L117) skips wireframe boxes rather than testing their edges.

## How do you draw debug lines on top of 3D geometry?

With `Wireframe` alone, another object can hide the edges behind it. That’s useful when you’re checking where the box sits relative to a wall. Combine `Wireframe` and `OnTop` when you need to trace the full outline even behind the wall. In the [3D renderer](https://github.com/recursive-ai-oss/onescope-csharp/blob/d681be56420836ea0d8874416367bc8181235813/src/OneScope.App/Space3DRenderer.cs#L181-L185), `OnTop` makes those debug lines ignore depth. Changing `Layer` is not the same thing: layer sets draw order, not depth. Keep `OnTop` for the diagnostic shapes that need it; otherwise the edges can make a hidden body look like it’s in front of the wall.
