SDF Mesh Library

thumb
Identfacepunch.libsdf
Typelibrary
Created
Updated
Latest Version 121787 167.3 KB ~9
Tags procgen mesh 3d 2d
Links s&box
SummaryMarching cubes & squares mesh generation
Description
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( "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 );
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( "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 );
Votes 25 0 29
Error Rate0%
Reviews
3 reviews
66.7% Recommended (2) 33.3% Promise (1) 0% Needs Work (0)
Usage
6,523 players 16,980 sessions 4,208 hours playtime 15 minutes avg session
Totals captured
Data
{}