Next: , Previous: Primitives, Up: Functions



12.10 Turtle

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 4)
          (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)))
     

12.10.1 (turtle-prim type-number)

Returns

void

Description

Starts building a new polygon primitive with the turtle. The type specifies the polygon face type and is one of the following: 0: triangle strip, 1: quad list, 2: triangle list, 3: triangle fan, 4: general polygon

Example
      (turtle-prim 0)
     

12.10.2 (turtle-vert)

Returns

void

Description

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

Example
      (turtle-vert)
     

12.10.3 (turtle-build)

Returns

primitiveid-number

Description

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))
     

12.10.4 (turtle-move distance-number)

Returns

void

Description

Moves the turtle forward in it's current orientation.

Example
      (turtle-move 1)
     

12.10.5 (turtle-push)

Returns

void

Description

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

Example
      (turtle-push)
     

12.10.6 (turtle-pop)

Returns

void

Description

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)
     

12.10.7 (turtle-turn rotation-vector)

Returns

void

Description

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

Example
      (turtle-turn (vector 45 0 0))
     

12.10.8 (turtle-reset)

Returns

void

Description

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

Example
      (turtle-reset)
     

12.10.9 (turtle-attach primitiveid-number)

Returns

void

Description

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)
     

12.10.10 (turtle-skip count-number)

Returns

void

Description

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)
     

12.10.11 (turtle-position)

Returns

count-number

Description

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

Example
      (display (turtle-position))(newline)
     

12.10.12 (turtle-seek position-number)

Returns

void

Description

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

Example
      (turtle-seek 0)