FooCAD Source Codeimport static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
include PlantPot.foocad
class HighRise : Model {
val height = 100
val stemSize = Vector2(15, 200)
val baseSize = Vector2( 115, 30 )
val thickness = 2.0
fun twist(d : double, extra : bool ) : Shape3d {
val steps = 30
val wiggle = Path3dBuilder().apply {
if (extra) {
moveTo( 0,0,-1)
lineTo( 0,0,0 )
} else {
moveTo( 0,0,0 )
}
val foo = 15
for (i in 0..steps) {
val angle = i/steps * 720
val offset = Degrees.cos(i/steps * 360) * foo - foo
lineTo(
Degrees.sin(angle)*offset,
Degrees.cos(angle)*offset,
i/steps * stemSize.y
)
}
if (extra) {
lineTo(0,0,stemSize.y+10)
}
}.build()
// Extrude the rounded square along the 3D path.
return ExtrusionBuilder
.followPath( wiggle, Circle( d/2 ) )
}
override fun build() : Shape3d {
val path = PolygonBuilder().apply {
moveTo(0,0)
lineBy( baseSize.x/2, 0 )
lineBy( 0, thickness/2 )
bezierBy(
Vector2( 0, baseSize.y * 0.5 ),
Vector2( 0, baseSize.y * 0.3 ),
Vector2( -baseSize.x/2 + stemSize.x/2 - thickness/2, baseSize.y )
)
}.buildPath()
val base = path.thickness( thickness ).revolve().bottomTo(0).color("Green")
val third = twist( stemSize.x, false ).color("Green")
val stem = third.bottomTo( base.top ) //.repeatAroundZ(3).bottomTo( base.top )
return stem
}
}