/Games/ChessPiece.foocad

A chess set, made mostly from "solids of revolution". (All except the knight, which is in the shape of a double G) Get the joke?
I've never printed it. The Knight needs to be taller.
Also, if I did print it, I'd make cylindical hollows in the bases to weight the pieces with coins.
import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
class ChessPiece : AbstractModel() {
var boardSize = 25
var profiles = SVGDocument("chessProfiles.svg")
fun revolve(name : String ) = profiles.shapes[name].toOrigin().translateX(0.1).revolve()
fun knight() : Shape3d {
val gP = profiles.shapes["g"].offset(-0.3).rotate(90)
val base = revolve( "knight" )
val cham = 0.6
val g = ExtrusionBuilder().apply {
joinStrategy = OneToOneJoinStrategy.instance
crossSection( gP )
forward( cham )
crossSection( cham )
forward( 3 )
crossSection( cham )
forward( cham )
crossSection( gP )
}.build().rotateY(90).toOriginZ()
//.rotateY(6)
.translateX(0.3)
.mirrorX().also()
.centerY()
.translateZ(base.size.z/2 )
return g + base
}
override fun build() : Shape3d {
println( "Profiles : ${profiles.shapes.keySet()}" )
return revolve("pawn").translateY(boardSize).repeatX( 5, boardSize ) +
revolve("rook") +
//knight().translateX(boardSize) +
revolve("bishop").translateX(boardSize*2) +
revolve("queen").translateX(boardSize*3) +
revolve("king").translateX(boardSize*4)
}
}

