Libraries

s&box libraries

SDF Mesh Library

facepunch.libsdf

Marching cubes & squares mesh generation

About

About SDF Mesh Library

Allows you to define a 2D / 3D field of signed distances to a virtual surface, perform operations with primitive shapes, and then generate a 3D mesh of the surface in real-time.

Create a world

using Sandbox.Sdf;

// ...

var sdfWorld = new Sdf2DWorld
{
// Rotate so that Y is up
LocalRotation = Rotation.FromRoll( 90f )
};

In this example we've rotated it by 90 degrees, so that the Y axis when doing 2D operations becomes the Z (up) axis in world space.

Draw some shapes

Still in server-side code, you can modify the SDF world like this:

// Shape that we want to add
var circle = new CircleSdf( new Vector2( localPos.x, localPos.y ), radius );

// Load the material to use
var material = ResourceLibrary.Get<Sdf2DLayer>( "layers/sdf2d/checkerboard.sdflayer" );

// Draw the circle!
sdfWorld.Add( circle, material );

// Move the circle to the right, then subtract it!
sdfWorld.Subtract( circle.Translate( new Vector2( 32f, 0f ) ), baseMat );

procgenmesh3d2d

Media

More by Facepunch

01
Player Controller thumbnail
Player Controller facepunch.playercontroller

Components for player controller

playercontrollerfirstpersonshooterhalflifequake
+0 24h
98favorites
74upvotes
95%Wilson score
02
Sprite Tools (OBSOLETE) thumbnail
Sprite Tools (OBSOLETE) facepunch.spritetools

Do not use anymore, SpriteRenderer and Sprite Resource are built-in now.

2dartpixelspritetools
+0 24h
19favorites
22upvotes
79%Wilson score
03
Game Events thumbnail
Game Events facepunch.libevents

Strongly typed game events

eventeventsfsm
+0 24h
15favorites
13upvotes
77%Wilson score
04
Wheel Collider thumbnail
Wheel Collider facepunch.libwheel

No summary provided.

+0 24h
12favorites
7upvotes
32%Wilson score
05
State Machines thumbnail
State Machines facepunch.libstates

State machines using Action Graph.

fsmstatesactiongraphstatemachine
+0 24h
11favorites
14upvotes
78%Wilson score
06
Spline Tools thumbnail
Spline Tools facepunch.splinetools

Work In Progress Spline Tools.

+0 24h
10favorites
17upvotes
82%Wilson score