add a bottom lol

This commit is contained in:
Octopus Octopus 2022-06-30 16:50:13 -05:00
parent a998e4dd67
commit 0df0762067
3 changed files with 26 additions and 14 deletions

View File

@ -8,7 +8,7 @@ import (
const ( const (
BODY_SIZE_X = 300 BODY_SIZE_X = 300
BODY_SIZE_Y = 215 BODY_SIZE_Y = 215
BODY_SIZE_Z = 2 + 45 + 0 //Top + Walls + Base BODY_SIZE_Z = 3 + 45 + 3 //Top + Walls + Base
BODY_CURVE = 10 BODY_CURVE = 10
WALL_THICKNESS = 6.9 WALL_THICKNESS = 6.9
) )
@ -61,6 +61,15 @@ func wallsPlane() sdf.SDF2 {
return walls return walls
} }
func bottomPlane() sdf.SDF2 {
bottom := sdf.Box2D(v2.Vec{X: BODY_SIZE_X, Y: BODY_SIZE_Y}, BODY_CURVE)
screws := screwHoles()
bottom = sdf.Difference2D(bottom, screws)
return bottom
}
// screwHoles produces m4 screwHoles along the sides of the piece. // screwHoles produces m4 screwHoles along the sides of the piece.
func screwHoles() sdf.SDF2 { func screwHoles() sdf.SDF2 {
hole, _ := sdf.Circle2D(M4_SCREW_DIAMETER / 2) hole, _ := sdf.Circle2D(M4_SCREW_DIAMETER / 2)

Binary file not shown.

View File

@ -1,24 +1,27 @@
package main package main
import ( import (
"strconv"
"github.com/deadsy/sdfx/render" "github.com/deadsy/sdfx/render"
"github.com/deadsy/sdfx/render/dc" "github.com/deadsy/sdfx/render/dc"
"github.com/deadsy/sdfx/sdf"
) )
func main() { func main() {
top := topPlane() tops := split2DPlane(topPlane())
walls := wallsPlane() walls := split2DPlane(wallsPlane())
parts := make(Parts) bottoms := split2DPlane(bottomPlane())
parts.add(split2DPlane("top", top, 2)) render.RenderDXF(topPlane(), 600, "top.dxf")
parts.add(split2DPlane("walls", walls, 45))
render.RenderDXF(top, 600, "top.dxf")
render.RenderDXF(wallsPlane(), 600, "walls.dxf") render.RenderDXF(wallsPlane(), 600, "walls.dxf")
for i, ele := range tops {
render.ToSTL(sdf.Extrude3D(ele, 3), 400, "top-"+strconv.Itoa(i)+".stl", dc.NewDualContouringDefault())
}
for i, ele := range walls {
render.ToSTL(sdf.Extrude3D(ele, 45), 400, "wall-"+strconv.Itoa(i)+".stl", dc.NewDualContouringDefault())
}
for i, ele := range bottoms {
render.ToSTL(sdf.Extrude3D(ele, 3), 400, "bottom-"+strconv.Itoa(i)+".stl", dc.NewDualContouringDefault())
}
// render.ToSTL(sdf.Extrude3D(walls, 2), 400, "walls.stl", dc.NewDualContouringDefault()) // render.ToSTL(sdf.Extrude3D(walls, 2), 400, "walls.stl", dc.NewDualContouringDefault())
for k, v := range parts {
render.RenderDXF(v.SDF2, 400, k+".dxf")
render.ToSTL(v.SDF3, 400, k+".stl", dc.NewDualContouringDefault())
}
} }