Introducing NetLogo 3D

NetLogo 3D Preview 5 is a preview release of NetLogo 3D, based on NetLogo 4.0. NetLogo 3D allows you to create 3D worlds.

Caution! NetLogo's support for 3D is experimental. Models created with this release may not be compatible with future versions. While we've made every effort to ensure a quality product, this special preview has not been subject to the same rigorous quality-control processes as our regular NetLogo releases. For a list of the known bugs see Known Issues.

Getting Started

To get started using NetLogo 3D Preview 5, check out the Sample Models in the 3D section of the Models Library.

When you're ready to write your own 3D model, look at the Code Examples in the 3D section of the Models Library. "Turtle Perspective Example 3D" helps you learn about the different perspectives. "Turtle and Observer Motion Example 3D" helps you understand how turtles and the Observer move in 3D. You can also step through this model with the 3D Movement and Orientation tutorial.

How it works

3D Worlds

An unspeakable horror seized me. There was a darkness; then a dizzy, sickening sensation of sight that was not like seeing; I saw a Line that was no Line; Space that was not Space: I was myself, and not myself. When I could find voice, I shrieked loud in agony, "Either this is madness or it is Hell."

"It is neither," calmly replied the voice of the Sphere, "it is Knowledge; it is Three Dimensions: open your eye once again and try to look steadily."
-- Edwin A. Abbott from Flatland: A romance in many dimensions

In 3D the NetLogo world has width, height and depth. In addition to pxcor and pycor, patches have pzcor.

Turtles have three Cartesian coordinates, instead of two, to describe position. In addition to xcor and ycor, turtles have zcor.

A turtle's orientation is defined by three turtle variables, heading, pitch and roll. You can imagine the turtle as having two vectors to define its orientation in 3D space. One vector comes straight out of the nose of the turtle, this is the direction the turtle will travel when it moves forward. The second vector is perpendicular to the forward vector and comes out of the right side of the turtle (as if the turtle were to stick its right arm straight out from its body). Heading is the angle between the forward vector of the turtle projected onto the xy-plane and the vector [0 1 0]. Pitch is the angle between the forward vector of the turtle and the xy-plane and finally roll is the angle between the right vector of the turtle and the xy-plane. When turtle turns right or left in 3D space it rotates around the down vector, that is the vector that is perpendicular to both the forward and right vectors. Depending on the orientation of the turtle more than one of the internal turtle variables may change as the result of a turn.

The Observer and the 3D view

The point of view that you see the world from is considered the location and orientation of the observer. This is similar to the 3D view in NetLogo 2D. However, there are a few more ways to control the observer. You can set the point that the observer is facing by using face and facexyz which work the same way as the turtle commands, the Observer turns so the center of the view is on the given point or the location of the given agent at the time it is called. You can change the location of the Observer using setxyz. The Observer will move to view the world as if standing on the given location, the point the observer faces will stay the same. For example create a new model and Observer will be located at (0, 0, 49.5), that is, on the z-axis 49.5 patch units away from the origin and the Observer is facing the origin, (0, 0, 0). If you setxyz 0 49.5 0 the Observer will move so it is on the positive y-axis but it will keep the origin at the center of the view. You can also move the observer using the rotation primitives that will allow you to move the observer around the world as if on the surface of a sphere where the center is the location the Observer is facing. You may notice from the above examples that the Observer is not constrained to be within the bounds of the world.

Custom Shapes

You can load your own shapes using the load-shapes-3d primitive, which takes a text file as an input. Once you have loaded the shapes into the model you can use them just like the built-in shapes. The input file may contain any number of shapes with any number of rectangular or triangular surfaces. The format of the input file should be as follows:

number of shapes in file
name of first shape 
type of surface ( quads or tris )
surface1
surface2
.
.
.
stop
type of surface
surfaceA
.
.
.
stop
end-shape

Each surface is defined by a unit normal vector and the vertices listed in clockwise order, tris should have three vertices and quads should have four.

normal: xn yn zn
x1 y1 z1 
x2 y2 z2
x3 y3 z3
x4 y4 z4

A file declaring just a two dimensional, patch-sized, square in the xy-plane centered at the origin would look like this:

1
square
quads
normal: 0 0 1
0.15 0.15 0
-0.15 0.15 0
-0.15 -0.15 0
0.15 -0.15 0
normal: 0 0 -1
0.15 0.15 0
0.15 -0.15 0
-0.15 -0.15 0
-0.15 0.15 0
stop
end-shape

Feedback

If you find any bugs in NetLogo 3D, please let us know at bugs@ccl.northwestern.edu.

We'd like to hear from you about what additional features would be useful to you in your work. If you have questions, comments, or suggestions, please write us at feedback@ccl.northwestern.edu.