FooCAD Source Codeimport static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.*
class BikeShed : Model {
val size = Vector3( 1500, 600, 1000 )
val main = Lumber( "main", 67, 45 ).stockLength( 2400 )
val wheelSize = Vector2(230, 30)
@Piece
fun front() : Shape3d {
val upright = main.cut( size.z - main.width * 2 )
val across = main.cut( size.x ).rotateY(90).bottomTo(0).color("Green")
val uprights = upright.translateZ(main.width).rightTo(size.x).also()
val acrosses = across.topTo( size.z ).also()
return uprights + acrosses
}
@Piece
fun top() : Shape3d {
return Cube( size.x + main.thickness * 2, size.y, 20 )
}
@Piece
fun side() : Shape3d {
val upright = main.cut( size.z - main.width * 2 ).color("Yellow")
val across = main.cut( size.y - main.thickness ).rotateY(90).bottomTo(0).color("LightGreen")
val uprights = upright.translateZ(main.width).rightTo(across.right).also()
val acrosses = across.topTo( size.z ).also()
return uprights + acrosses
}
@Piece
fun tyre() : Shape3d {
val outside = Circle( wheelSize.x / 2 )
return outside.chamferedExtrude( wheelSize.y, 2 )
.center()
.color("DimGray") -
Cylinder( wheelSize.y + 2, wheelSize.x / 2 - 10 ).center()
}
@Piece
fun wheel() : Shape3d {
return tyre().rotateX(90).center() +
Cylinder( wheelSize.y, wheelSize.x / 2 - 10 )
.center()
.rotateX(90)
}
@Piece
fun wheels() : Shape3d {
val pair = wheel().rotateZ(90).center()
.frontTo(20)
.translateZ( main.width/2 )
.backTo(size.y - 20).also()
.leftTo( size.x / 2 + 5)
return pair
}
override fun build() : Shape3d {
val front : Shape3d = front()
.centerX()
val sides = side().rotateZ(90).leftTo(front.left)
.frontTo( front.back )
.mirrorX().also()
val top : Shape3d = top()
.centerX()
.bottomTo( sides.top )
.color("DarkGreen")
return sides + front + top + wheels()
}
}