3D Turtle to write your own Turtle Scripts - aimed at kids

edited October 2017 in Share Your Work

Hello all,

I finished working on a 3D Turtle where you can write your own scripts to steer a turtle in a 3D space.

It's a Turtle program like the famous Turtle in LOGO but as a 3D Turtle.

The turtle carries a pen and walks on the screen, drawing shapes. Since it's 3D it can also dive like a water turtle and draw a cube etc.

The program is aimed at kids around 8 or 12 to learn programming in 3D. So when you are a teacher, please feel free to use it.

Highlights:

  • Write a Turtle Script in the sketch editor and have it executed (pressing the green Play Button). Save and load Turtle Scripts to hard drive

  • Look at the drawing of the Turtle from every angle using peasy cam or have a camera fly around (using letter c)

  • Steer the turtle directly with cursor keys and see the drawing immediately. Have the movement recorded as a Turtle Script that you can edit, save, load and run.

  • Browse through examples on the hard drive using cursor keys.

Please try the Turtle and give feedback.

Download:

https://github.com/Kango/3D-Turtle

Thanks to all who helped me with this.

Warmest Regards,

Chrisir

Tagged:

Comments

  • Here is a screenshot of the Editor Window

    screenshot

  • Here is a screenshot of one of the example Turtle Scripts that are included.

    It shows the Turtle that just draw a small 3D drawing:

    screenshotTurtle

  • Congratulations on completing this great project, @Chrisir -- I have really loved watching it develop.

  • Thank you so much, Jeremy. Your initial input made it possible. I owe you.

  • edited October 2017

    Small help here:

    Help for Turtle Script

    Imagine a turtle. You can tell it to go forward or turn left or right. Imagine it carries a pen so when it walks it draws a line behind it. You can now draw an image by telling the turtle where to go. To draw a rectangle you would say: repeat 4 ( forward 60 right 90 ). The rotation with right / left determines in which direction the Turtle draws next. You can write your Turtle Script in an Editorbox on the screen and run it by clicking the green > sign with the mouse. You can also steer the Turtle with Cursor keys directly to generate a Turtle Script. Here you see one text box where you see a help for the current line in the editor box. You see a ROLL with commands (use mouse wheel) to choose commands; attached is also a small help text. Hit Esc to go back. See status bar at bottom screen to see in which mode you are. You can save and load your Turtle Scripts. By the way: In edit mode leave your cursor on a screen button and see a yellow tool tip text.

    Major commands are

    • forward/backward(amount) to walk
    • left/right(amount) - to turn [amount is an angle in degrees from 0 to 360]. This only is visible after drawing the next line. For a plane this is the YAW axis
    • penUp so Turtle walks but does not draw.
    • penDown Turtle draws again You can use Learn Rect [...] to teach it a new command and then use that command Rect.
    • You can thus make your own turtle commands like turtleRectangle by writing a function and use it (see demos, use the yellow Load Icon). You can use Repeat 4 (...) to repeat a few lines 4 times (see demos).

    The turtle is also a 3D Turtle, imagine a water turtle that draws a line behind it. It can also dive into a aquarium and therefore can not only draw on a canvas but in free 3D space.

    • Thus you can connect four rectangles to a cube etc.
    • When you think of a plane, the terms for rotating in 3D are called pitch/roll/yaw. Major commands in 3D space are
    • noseDown/noseUp(degree) to turn down and up (for a plane this is the PITCH axis)
    • rollRight (or just roll)/rollLeft(degree) to roll sideways (for a plane this is the ROLL axis)
    • sink/rise(amount) to go up and down

    Additional commands to move without drawing (Turtle is jumping)

    • forwardJump/backwardJump(amount) to go forward and backward
    • sinkJump/riseJump(amount) to go up and down
    • sidewaysRightJump(or sidewaysJump)/sidewaysLeftJump(amount) to go sideways

    Variable Handling

    The Program knows a limited handling of variables. All variables are global.

    • Let N 21 (instead of N use any name you want)
    • add N 2 // adding 2 to N
    • mult N 2
    • sub N 2
    • div N 2

    Use N like: forward N or sink N or sphere N....

    • There are constants: PI; TWO_PI; HALF_PI; TAU

    Commands to change the Turtle appearance

    • showTurtle shows the standard Turtle; Example: showTurtle
    • You can change this standard Turtle's shape with showTurtleAsArrow / showTurtleAsPlane / showTurtleAsShape (you need to load a shape first, see below) and showTurtleAsTurtle (back to normal).
    • No matter what standard Turtle is, you can just say: Turtle/ Arrow/ Plane/ shapeLoaded (load shape first) to display it directly.
    • For the standard Turtle: You can change colors using "turtleBody leg1 color BLUE" You can use all colors ('BLUE', '144' or '255 0 255') and the keyWords head,body,eye1,eye2,leg1,leg2,leg3,leg4 with this command.
    • You can load a 3rd party shape (.obj file) with a texture (.png or .jpg file) and a scale; Example: LOADSHAPE biplane.obj diffuse_512.png 1.7
      You may change the rotation of the shape using ROTATESHAPE XRotate PI 0 // rotate the shape by x,y,z (radians)
      Examples see under the names "turtle...".

    Additional commands

    • Help to show this help
    • sidewaysRight(or sideways)/sidewaysLeft(amount) to go sideways
    • // make a comment with // comment
    • pushMatrix and popMatrix
    • background red green blue : set background color, e.g. blue is background 0 0 255
    • COLOR red green blue : set Turtle drawing color (Pen) color, eg. red is COLOR 255 0 0 OR use color RED etc.;
    • named Turtle Colors are White, Black, Gray, Lightgray, darkgray, RED, GREEN, BLUE, ROSE, MAGENTA, VIOLET, AZURE, CYAN, SPRINGGREEN, CHARTREUSE, YELLOW, ORANGE, PURPLE, PINK, NAVY, RED, GREEN, BLUE, ROSE, MAGENTA, VIOLET. For gray values from black (0) to white (255) use color with one parameter, e.g. color 122.
    • gridOn and gridOff : set grid on / off
    • GRIDCOLOR red green blue : set grid color.
    • showTurtle (or Arrow) to display a Turtle or Arrow with the current heading. You can use it multiple times.
    • point x y z draw a point (small sphere) at absolute coordinates
    • line x1 y1 z1 x2 y2 z2 draw a line with absolute coordinates

    Commands to store a Turtle Position

    • pushPos can store a Turtle Position (where the Turtle is and where it looks at). Use with a name you use: pushPos Home.
    • popPos can restore a Turtle Position (where the Turtle is and where it looks at). Use with a name you defined before: popPos Home.

    Recording a path to make a shape

    • startPath begins the recording. Use with a name you want to use for the shape: startPath Star.
    • fillPath ends the recording. All shapes are displayed automatically.
    • suppressPath suppresses the automatic display of all shapes.
    • showPath shows one shape: showPath Star.

    Credits

    • credits: Jeremy Douglass - thank you! https:// forum.processing.org/two/discussion/20706/how-3d-turtle-like-in-logo-but-3d-math-problem
    • Thanks to Jonathan (PeasyCam)
    • Thanks to GoToLoop for the text input area
    • Thanks for drawLine programmed by James Carruthers
    • Thanks to Calsign
    • Thanks to koogs
    • Thanks for the plane to https : // opengameart.org/content/low-poly-biplane
  • @Chrisir Really great you have created this post to summarize your efforts. It is an excellent idea what you have done.

    Kf

  • Thank you so much !

  • A small help for the Turtle Editor Window:

    screenshot Editor Help

  • @Chrisir Congratulations :)
    Very nice.
    cameyo

  • Thank you very much!

    ;-)

  • edited November 2017

    Here is a screen shot for a help on the buttons in the Turtle Editor - you can see the Editor above

    helpButtons

Sign In or Register to comment.