Hammer Gizmos
Posted one year ago
Think of gizmos like IMGUI but for the 3d world. You can use them to draw lines, shapes, models, sprites or particles.

Our main use case here is for adding development gizmos, like position and rotate.. but you could totally use them to render effects and other client-side 3d interactions in your actual game.

Example

Each banana in this scene is rendered using the Gizmo API. Every frame a function is called which is saying "render a banana here". The gizmo library does all the optimizing work on the backend saying "this is the same banana object as the last one, so don't change anything" to keep things running nice.

The code for rendering one of these bananas is simply this:

// make the next section clickable Gizmo.Hitbox.Sphere( new Sphere( 0.0f, 4.0f ) ); // draw a different color if the hitbox above is hovered Gizmo.Draw.Color = Gizmo.IsHovered ? Color.Green : Color.White; // change the size if the hitbox above is pressed down if ( Gizmo.IsPressed ) Gizmo.Transform = Gizmo.Transform.WithScale( 2.0f ); // draw the banana model Gizmo.Draw.Model( "models/rust_props/small_junk/banana.vmdl" );