Turtle Script

Turtle Script creates custom 2D shapes

  • Scripts are parsed within the Logic of 2D shape Geometry.
  • Use a new line for each turtle command.
  • Node parameters and math functions can replace script values
  • The turtle can only read/set parameters on its own node.

Turtle commands fall into a few general categories

  • explicit coordinates: mov, drw, dir, bezier…
  • relative coordinates: rmov, rdrw, arc…
  • self-steering: fwd, back, left, right, turn…
  • logic: let, set, loop, if…
mov x y (a)move to x y (degrees)
teleport turtle to location (face direction)
drw x ydraw to location x y
dir adirection angle in degrees
dir 0 is east, dir 90 is north
bezier ax ay ahx ahy bhx bhy bx by segmentscubic bezier with 2 handles
startXY handle1 handle2 endXY segments
bezier 0 0 0 1 1 1 1 0 16
molding type ax ay bx by segments tensionpoint-to-point tension curves
type* start end segments tension
tension is normalized 0-1
*types: cove, ovolo, cymarecta, cymareversa, dome
molding 0 1 1 0 16 .5
newpnew point
creates a vertex in-situ
restarts the UV map
rmov dx dyrelative move offset-x offset-y
teleport to offset
restarts the UV map
*shape must be OPEN
rdrw dx dyrelative draw offset-x offset-y
arcl angle radius segmentsdraw an arc forward and to the left
angle of the full arc, in degrees
of the arc, centered to the left
arcl 90 1 8
arcr angle radius segmentsdraw an arc forward and to the right
angle of the full arc, in degrees
radius of the arc, centered to the right
segments (int)
arcr 90 1 8
movfwd c (d)move forward value (offset)
teleport in the facing direction
*shape must be OPEN
fwd c (d)forward value (offset)
back c (d)back value (offset)
right c (d)right value (offset)
left c (d)left value (offset)
turnl arotate counter-clockwise degrees
turnr arotate clockwise degrees
closed true
closed false
adds a segment connecting the last point to the first
removes overlapped/enclosed vertices
*required for ‘manifold topology’
*changes options under Shape Output
*also a bool switch under Shape Output
letcreate a temporary variable (float)
let var value
let myTemp 80
setset value on a parameter or variable
set parameter value
set var value
set myParam 16
loop repeat (count) (step)open a loop and repeat (int) until done
(count) create temp var (int) = the loop value
(step) steps through the count by (int)
loop 360 rotate 90
dir rotate
// rotate = 0, 90, 180, 270

endloopterminate loop
if conditionalopen a conditional directive when true
if parameter GT value

var GT value
var LT value
var GE value
var LE value
var EQ value
var NE value
greater than
less than
greater or equal
lesser or equal
not equal
if boolrun conditional when bool is true
if !boolrun conditional when bool is false
endifterminate conditional
//comment line

subtract (negative)
order of operations
mathf functionsfunction returns a value
let hypotenuse sqrt(pow(width,2)+pow(height,2))
parameterthe value of a parameter
mov width 0
set width value
DetailLevelread-only parameter from graph: 0-1
*reduces segments on all nodes: 0.5 is 50%
*generates LOD models by reducing vertices
if DetailLevel LT .67
Values inside () are optional (do not use the brackets)


Each line the turtle draws, creates a new edge and vertex.

When 2D shapes combine into a 3D mesh, the turtle defines how the texture will wrap the model. On the generated mesh U follows the Plan shape and direction, V follows the Section.

‘Steering’ the turtle (ie: fwd, turnl/r) creates clean UV wrapping – easiest method to follow details on a texture map, or create specific vertices on a mesh without stretching the texture.

Unity removes unnecessary vertices to optimize the mesh – which is bad if the mesh needs to deform around a plan. A row of tiny offset points can force vertices in an apparently straight line segment.

Example scripts

The best way to learn AX Turtle Script is to open the Logic panel on any 2D shape to see how it was made.

mov width/2 0 90
drw 0 height/2
drw –width/2 0
drw 0 –height/2

closed true
if shift_origin
molding cove –width height 0 0 segs tension

if !shift_origin
molding cove 0 height width 0 segs tension

closed false
if inputHypotenuse
if solveWidth
set width Sqrt(hypotenuse*hypotenuseheight*height)
set height Sqrt(hypotenuse*hypotenusewidth*width)

set hypotenuse Sqrt(width*width+height*height)
set theta Atan2(height,width)
mov 0 0 90
right width
fwd height

closed true
if bX GE aX
let mdX abs(bXaX)/(segs-1)
if bX LT aX
let mdX -abs(bXaX)/(segs-1)
if bY GE aY
let mdY abs(bYaY)/(segs-1)
if bY LT aY
let mdY -abs(bYaY)/(segs-1)
if cX GE bX
let ndX abs(cXbX)/(segs-1)
if cX LT bX
let ndX -abs(cXbX)/(segs-1)
if cY GE bY
let ndY abs(cYbY)/(segs-1)
if cY LT bY
let ndY -abs(cYbY)/(segs-1)

mov aX aY
loop segs i
mov aX+mdX*i aY+mdY*i
drw bX+ndX*i bY+ndY*i

Output Shape: open

Comments are closed.