turtle

Description

The turtle polybuilder is an experimental way of building polygonal objects using a logo style turtle in 3D space. As you drive the turtle around you can place vertices and build shapes procedurally. The turtle can also be used to deform existing polygonal primitives, by attaching it to objects you have already created.

Example

 (define (build n)
     (turtle-reset)
     (turtle-prim 'polygon)
     (build-loop n n)
     (turtle-build))

 (define (build-loop n t)
     (turtle-turn (vector 0 (/ 360 t) 0))
     (turtle-move 1)
     (turtle-vert)
     (if (< n 1)
         0
         (build-loop (- n 1) t)))

(turtle-prim type-symbol)

Returns void

Starts building a new polygon primitive with the turtle. The type specifies the polygon face type and is one of the following: 'triangle-strip, 'quad-list, 'triangle-list, 'triangle-fan, 'polygon.

Example

 (turtle-prim 'triangle-strip)

(turtle-vert)

Returns void

Creates a new vertex in the current position, or sets the current vertex if the turtle builder is attached.

Example

 (turtle-vert)

(turtle-build)

Returns primitiveid-number

Builds the object with the vertex list defined and gives it to the renderer. Has no effect if the turtle builder is attached to a primitive.

Example

 (define mynewshape (turtle-build))

(turtle-move distance-number)

Returns void

Moves the turtle forward in it's current orientation.

Example

 (turtle-move 1)

(turtle-push)

Returns void

The turtle build has it's own transform stack. Push remembers the current position and orientation.

Example

 (turtle-push)

(turtle-pop)

Returns void

The turtle build has it's own transform stack. Pop forgets the current position and orientation, and goes back to the state at the last push.

Example

 (turtle-pop)

(turtle-turn rotation-vector)

Returns void

Rotates the turtle's orientation with the supplied euler angles (rotations in x, y and z).

Example

 (turtle-turn (vector 45 0 0))

(turtle-reset)

Returns void

Resets the current position and rotation of the turtle to the origin.

Example

 (turtle-reset)

(turtle-attach primitiveid-number)

Returns void

Attaches the turtle to an existing poly primitive. This means you are able to deform an existing objects points using the turtle builder.

Example

 (define myshape (build-sphere 10 10))
 (turtle-attach myshape)

(turtle-skip count-number)

Returns void

When attached, causes the turtle to skip vertices. This value may be negative, which will set the turtle to write to previous vertices.

Example

 (turtle-skip -1)

(turtle-position)

Returns count-number

When attached, returns the current pdata index the turtle is writing to.

Example

 (display (turtle-position))(newline)

(turtle-seek position-number)

Returns void

When attached, sets the absolute pdata index the turtle is writing to.

Example

 (turtle-seek 0)

(get-turtle-transform)

Returns matrix-vector

Returns a matrix representing the current turtle transform.

Example

 (clear)
 (hint-none)
 (hint-wire)
 (turtle-reset)
 (turtle-prim 4)
 (for ([i (in-range 9)])
   (turtle-turn (vector 0 0 36))
   (turtle-move 1)
   (turtle-vert))
 (turtle-build)
 (with-primitive (build-locator)
   (hint-origin)
   (concat (get-turtle-transform)))