add innerWall, move wallcorner to body3d, rerotate walls

This commit is contained in:
Octopus Octopus 2022-07-03 18:06:22 -05:00
parent 7c6b731feb
commit 6134fadcc9
2 changed files with 61 additions and 17 deletions

View File

@ -6,11 +6,12 @@ import (
) )
const ( const (
BODY_SIZE_X = 300 BODY_SIZE_X = 300
BODY_SIZE_Y = 215 BODY_SIZE_Y = 215
BODY_SIZE_Z = 3 + 45 + 3 //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
INNER_WALL_WIDTH = 12.0
) )
// topPlane produces a 2D top-down image of the fightstick's top panel. // topPlane produces a 2D top-down image of the fightstick's top panel.
@ -68,7 +69,7 @@ func bottomPlane() sdf.SDF2 {
} }
func innerWallPlane() sdf.SDF2 { func innerWallPlane() sdf.SDF2 {
wall := sdf.Box2D(v2.Vec{X: 12, Y: BODY_SIZE_Y}, 0) wall := sdf.Box2D(v2.Vec{X: INNER_WALL_WIDTH, Y: BODY_SIZE_Y}, 0)
wall = sdf.Difference2D(wall, screwHoles()) wall = sdf.Difference2D(wall, screwHoles())
@ -102,7 +103,7 @@ func screwHoles() sdf.SDF2 {
} }
// wallCorner returns one corner of the wall. // wallCorner returns one corner of the wall.
func wallCorner() sdf.SDF2 { func wallCornerPlane() sdf.SDF2 {
segmentPlane := wallsPlane() segmentPlane := wallsPlane()
segmentPlane = split2DPlane(segmentPlane)[0] segmentPlane = split2DPlane(segmentPlane)[0]
segmentPlane = sdf.Center2D(segmentPlane) segmentPlane = sdf.Center2D(segmentPlane)

View File

@ -12,13 +12,21 @@ const (
TOP_HEIGHT = 3.0 TOP_HEIGHT = 3.0
WALLS_HEIGHT = 45.0 WALLS_HEIGHT = 45.0
BOTTOM_HEIGHT = 3.0 BOTTOM_HEIGHT = 3.0
WALL_NOTCH = 5.0
) )
func wallCorner() sdf.SDF3 {
corner := sdf.Extrude3D(wallCornerPlane(), WALLS_HEIGHT)
cutout, _ := sdf.Box3D(v3.Vec{X: 12, Y: INNER_WALL_WIDTH, Z: WALLS_HEIGHT - WALL_NOTCH*2}, 0) //X is arbitrary
corner = sdf.Difference3D(corner, sdf.Transform3D(cutout, sdf.Translate3d(v3.Vec{X: BODY_SIZE_X/3 + cutout.BoundingBox().Max.X, Y: 0, Z: 0})))
return corner
}
// wallFrontRight is the front right wall. This houses the neutrik connector. // wallFrontRight is the front right wall. This houses the neutrik connector.
// TODO: Test that measurement because this shit will be infuriating if i print it wrong // TODO: Test that measurement because this shit will be infuriating if i print it wrong
func wallFrontRight() sdf.SDF3 { func wallFrontRight() sdf.SDF3 {
corner2D := wallCorner() corner := wallCorner()
corner := sdf.Extrude3D(corner2D, WALLS_HEIGHT)
neutrik2D, err := sdf.Circle2D(BUTTON24_DIAMETER / 2) neutrik2D, err := sdf.Circle2D(BUTTON24_DIAMETER / 2)
if err != nil { if err != nil {
@ -43,10 +51,11 @@ func wallFrontRight() sdf.SDF3 {
} }
//wallFrontLeft is the front left wall. This houses 4 24mm buttons. //wallFrontLeft is the front left wall. This houses 4 24mm buttons.
// TODO: Rotate this properly
func wallFrontLeft() sdf.SDF3 { func wallFrontLeft() sdf.SDF3 {
corner2D := wallCorner() corner := wallCorner()
corner2D = sdf.Transform2D(corner2D, sdf.Rotate2d(sdf.DtoR(270))) // Could be removed, just need to modify how functionButtons move
corner := sdf.Extrude3D(corner2D, WALLS_HEIGHT) corner = sdf.Transform3D(corner, sdf.Rotate3d(v3.Vec{X: 0, Y: 0, Z: 1}, sdf.DtoR(270)))
functionButtons := sdf.Extrude3D(functionRow(), WALL_THICKNESS) functionButtons := sdf.Extrude3D(functionRow(), WALL_THICKNESS)
functionButtons = sdf.Transform3D(functionButtons, sdf.RotateX(sdf.DtoR(90))) functionButtons = sdf.Transform3D(functionButtons, sdf.RotateX(sdf.DtoR(90)))
@ -61,14 +70,48 @@ func wallFrontLeft() sdf.SDF3 {
//wallBackRight is the back right wall. //wallBackRight is the back right wall.
func wallBackRight() sdf.SDF3 { func wallBackRight() sdf.SDF3 {
corner := wallCorner() corner := wallCorner()
corner = sdf.Transform2D(corner, sdf.Rotate2d(sdf.DtoR(270))) corner = sdf.Transform3D(corner, sdf.RotateZ(sdf.DtoR(270)))
return sdf.Extrude3D(corner, WALLS_HEIGHT) return corner
} }
//wallBackLeft is the back left wall. //wallBackLeft is the back left wall.
func wallBackLeft() sdf.SDF3 { func wallBackLeft() sdf.SDF3 {
corner := wallCorner() corner := wallCorner()
corner = sdf.Transform2D(corner, sdf.Rotate2d(sdf.DtoR(270))) corner = sdf.Transform3D(corner, sdf.RotateZ(sdf.DtoR(270)))
corner = sdf.Transform2D(corner, sdf.MirrorY()) corner = sdf.Transform3D(corner, sdf.MirrorYZ())
return sdf.Extrude3D(corner, WALLS_HEIGHT) return corner
}
func innerWall() sdf.SDF3 {
wall := sdf.Extrude3D(innerWallPlane(), WALLS_HEIGHT)
// cut off edges
edgeCutout, _ := sdf.Box3D(v3.Vec{X: INNER_WALL_WIDTH, Y: WALL_THICKNESS, Z: WALL_NOTCH}, 0)
wall = sdf.Difference3D(wall, sdf.Transform3D(edgeCutout, sdf.Translate3d(v3.Vec{X: 0, Y: BODY_SIZE_Y/2 - WALL_THICKNESS/2, Z: WALLS_HEIGHT/2 - (5 / 2)})))
wall = sdf.Difference3D(wall, sdf.Transform3D(edgeCutout, sdf.Translate3d(v3.Vec{X: 0, Y: BODY_SIZE_Y/2 - WALL_THICKNESS/2, Z: -WALLS_HEIGHT/2 - -(5 / 2)})))
wall = sdf.Difference3D(wall, sdf.Transform3D(edgeCutout, sdf.Translate3d(v3.Vec{X: 0, Y: -BODY_SIZE_Y/2 - -WALL_THICKNESS/2, Z: WALLS_HEIGHT/2 - (5 / 2)})))
wall = sdf.Difference3D(wall, sdf.Transform3D(edgeCutout, sdf.Translate3d(v3.Vec{X: 0, Y: -BODY_SIZE_Y/2 - -WALL_THICKNESS/2, Z: -WALLS_HEIGHT/2 - -(5 / 2)})))
//fill the center holes
filler, _ := sdf.Box3D(v3.Vec{X: INNER_WALL_WIDTH, Y: WALL_THICKNESS, Z: 10}, 0) // Z is arbitrary, bigger than center portion
wall = sdf.Union3D(wall, filler)
// create holes for wires to pass through
centerCutout := sdf.Extrude3D(trapezoid(v2.Vec{X: BODY_SIZE_Y / 3, Y: WALLS_HEIGHT / 3}, -WALLS_HEIGHT/3), INNER_WALL_WIDTH)
centerCutout = sdf.Transform3D(centerCutout, sdf.RotateX(sdf.DtoR(90)))
centerCutout = sdf.Transform3D(centerCutout, sdf.RotateZ(sdf.DtoR(90)))
rotatedCenterCutout := sdf.Transform3D(centerCutout, sdf.RotateX(sdf.DtoR(180)))
// here comes the ugly bit
wall = sdf.Difference3D(wall, sdf.Transform3D(centerCutout, sdf.Translate3d(v3.Vec{X: 0, Y: BODY_SIZE_Y/2 - centerCutout.BoundingBox().Max.Y*1.3, Z: -WALLS_HEIGHT/2 - -centerCutout.BoundingBox().Max.Z*1.5})))
wall = sdf.Difference3D(wall, sdf.Transform3D(rotatedCenterCutout, sdf.Translate3d(v3.Vec{X: 0, Y: 0, Z: -WALLS_HEIGHT/2 - -centerCutout.BoundingBox().Max.Z*1.5})))
wall = sdf.Difference3D(wall, sdf.Transform3D(centerCutout, sdf.Translate3d(v3.Vec{X: 0, Y: -BODY_SIZE_Y/2 - -centerCutout.BoundingBox().Max.Y*1.3, Z: -WALLS_HEIGHT/2 - -centerCutout.BoundingBox().Max.Z*1.5})))
// FLIP IT TURNWAYS
wall = sdf.Difference3D(wall, sdf.Transform3D(rotatedCenterCutout, sdf.Translate3d(v3.Vec{X: 0, Y: BODY_SIZE_Y/2 - centerCutout.BoundingBox().Max.Y*1.3, Z: WALLS_HEIGHT/2 - centerCutout.BoundingBox().Max.Z*1.5})))
wall = sdf.Difference3D(wall, sdf.Transform3D(centerCutout, sdf.Translate3d(v3.Vec{X: 0, Y: 0, Z: WALLS_HEIGHT/2 - centerCutout.BoundingBox().Max.Z*1.5})))
wall = sdf.Difference3D(wall, sdf.Transform3D(rotatedCenterCutout, sdf.Translate3d(v3.Vec{X: 0, Y: -BODY_SIZE_Y/2 - -centerCutout.BoundingBox().Max.Y*1.3, Z: WALLS_HEIGHT/2 - centerCutout.BoundingBox().Max.Z*1.5})))
return wall
} }