3D Geometry Builder at runtime

I’m looking for a library with which I can create 3d shapes at runtime and render them in MonoGame. These shapes cannot be pre-built and just loaded as an asset, they must be created dynamically. It should support basic operations like Merge, Intersect, Subtract.

Let’s say I want to create a cube with a spherical cut-out. Visual example

The code could look something like this (simplified):

builder.Add(new Cube(x, y, z, w, h, d))
builder.Subtract(new Sphere(x, y, z, r))
// ....
GraphicsDevice.DrawUserIndexedPrimitives(....) // use builder output as parameters

Performance is not a huge concern, I won’t create a million slightly different shapes, but rather a few specific visible shapes at a time that can only be known at runtime.

Can you recommend / do you have experience with a library which is suited for MonoGame? It doesn’t have to be MonoGame-specific as long as the “conversion” from its output to commands like .DrawUserIndexedPrimitives() is possible

1 Like

I have a nuget package for primatives. Im on my phone and cooking dinner so cant get the exact name, but search in the package manager for randomchaos.monogame. and you shoukd find it.

Just got the link to my package Randomchaos.MonoGame.Primitives3D

Hope it helps.

Also, just read the rest of your post, no merge, subtract etc functionality, but something i will probably now add later :slight_smile:

I found a good library for this in 2D (Clipper2), but I don’t know any offhand for 3D. I did some quick googling though and found these… maybe they will help?


Thanks, I didn’t know this technique was called CSG! Good resources, now I found some others as well which will be helpful.