One of the first things you will notice when you open NetLogo 3D is that the world is a cube instead of a square.
You can open up the Model Settings, by clicking on the "Settings..." button at the top of the 3D View. You'll notice in addition to max-pxcor, min-pxcor, max-pycor, and min-pycor, there is also max-pzcor and min-pzcor.
The z-axis is perpendicular to both the x-axis and the y-axis, when you reset-perspective it is the axis that comes straight out of the screen. In the default position max-pzcor is the face of the cube nearest to you and min-pzcor is the face farthest from you. As always min-pxcor is on the left, max-pxcor on the right, min-pycor on the bottom and max-pycor on the top. You'll also notice on the left side of the Model Settings that there are options for wrapping in all three directions, however, they are all checked and grayed out. Topologies are not yet functional in 3D NetLogo so all worlds wrap in all three directions.
- Move to the Command Center and type print count patches.
Is the number smaller or larger than you expected?
In a 3D World the number of patches grows very quickly since count patches = world-width * world-height * world-depth. It's important to keep this in mind when you are building your model. Lots of patches can slow your model down or even cause NetLogo to run out of memory.
- Type ask patch 1 2 3 [ set pcolor red ] into the Command Center.
- Use the mouse in the 3D view to rotate the world.
Notice the shape of the patch and its position in relation to the edges of the world. You'll also notice that you now need three coordinates to address patches in a 3D world.
- Open the Models Library in the File Menu, (if you are on a Mac and you don't have a File Menu click on the NetLogo window and it should reappear)
- Open Turtle and Observer Motion Example 3D in 3D/Code Examples
Take a moment to look for the controls and monitors. In the bottom left you'll notice a group of monitors that describe the location and orientation of the turtle, though until you press the SETUP button they'll all say "N/A".
- Press the "setup" button
Heading, pitch, and roll are turtle variables that describe the orientation of the turtle. Heading is absolute in relation to the xy-plane, it is the rotation of the turtle around the z-axis.
Pitch is the angle between the nose of the turtle and the xy-plane, it is relative to heading.
Roll is the rotation around the turtle's forward vector, it is relative to heading and pitch.
When a group of turtles are created (using crt 10 for example) the heading will be evenly spaced around the 360 degrees as in 2D NetLogo, however, pitch and roll will always be zero.
Take a look at the "Turtle Movement" buttons.
- Press the "left 1" button.
How does the turtle move? Is is the same or different from 2D NetLogo? Which of the turtle variables change?
- Press the "pitch-down 1" button.
How does the turtle move? Which of the turtle variables change?
- Press the "left 1" button again.
How does the turtle move? Is it different than the last time you pressed the "left 1" button?
- Take a little time to play with the Turtle Movement buttons, watching both how the turtle moves and which of the turtle variables change.
You probably noticed that often more than one of the turtle variables change for a single turn; for this reason we suggest that you use the turtle commands rather than setting the orientation variables directly.
At the bottom of the interface you will see a group of buttons labeled "Observer (point of view)". If you have ever used the 3D view in NetLogo 2D or if you have been using the mouse controls in the 3D view through this tutorial you have been moving the Observer. Changing the point of view in the 3D is actually moving and changing the orientation of the Observer. The Observer has x, y and z coordinates, just like a turtle or patch, while turtles and patches are constrained to be inside the world the Observer can be anywhere. Like a turtle the Observer has a heading, pitch and roll, these variables control where the Observer is looking, that is, what you see in the View.
- Move to the 3D View, and make sure "Orbit" is selected in the bottom left corner of the view.
- Click and hold the mouse button in the middle of the view, move the mouse left, right, up, and down.
How does the position and orientation of the Observer change?
- Press the reset-perspective button in the lower right corner of the view and select "Zoom" in the lower left corner.
- Click and hold the mouse button in the middle of the view and move the mouse up and down.
Which of the Observer variables change? Which stay the same?
- Try rotating the world a bit and then zoom again.
- Press the "Move" button in the lower left corner of the view.
- Click and hold the mouse button in the middle of the view and move the mouse up, down, left and right.
How does the view change? How do the Observer variables change?
After you are done exploring the world using the mouse controls you can take a look at the Observer control buttons in the lower left portion of the interface.
If you are familiar the latest versions of NetLogo you should be familiar with the first three buttons in the Observer group. Watch, follow, and ride, are special modes that automatically update the position and orientation of the Observer. When in follow or ride mode, the observer position and orientation are the same as the turtle's. Note that follow and ride are functionally exactly the same, the difference is only visual in the 3D view. When in watch mode the Observer does not move but updates to face the target agent.
- Press the "setup" button again so you are back to the default orientation.
- Press the "orbit-right" button.
How did the view change? Was it what you expected? How is it similar or different from using the mouse controls?
- Take a little time to experiment with orbit, roll and zoom buttons; notice similarities and differences to the mouse controls.
The direction of the the orbit commands refer to the direction that the Observer moves. That is, imagine that the Observer is on the surface of a sphere, the center of the sphere is the point that the Observer is facing represented by the blue cross, by default (0,0,0). The Observer will always face the center of the sphere and the radius of the sphere will remain constant. The directions, up, down, left, and right, refer to moving along the lines of latitude and the lines of longitude of the sphere. When you zoom the radius of the sphere changes but the center and the Observer's orientation in relation to the center of the sphere will remain the same.
- Press one of the "setxyz" buttons.
How does the view change? How do the Observer variables change?
- Press the "facexyz" button.
How does the view change? How do the Observer variables change?
When you setxyz the center of the sphere remains the same (so the Observer automatically keeps that point in the center of the view.) However, the radius of the sphere may change as well as the Observer's orientation in relation to the center. When you facexyz or face, the center of the sphere changes but the Observer does not move. The radius of the sphere may change, as well as the orientation of the Observer.