Tutorial 2.8

Simple 3D Construction

Introduction

Moho is primarily a 2D program, although it does have some 3D tools for positioning the camera and individual layers. Still, even if you position layers in a 3D landscape and fly around them with the camera, each vector layer is really just a 2D plane in a 3D space. There is no way in Moho to model general 3D objects, but it is possible to fake out some simple ones. This tutorial will show you how to build a simple cube in Moho. If you need a more complex 3D shape, you can import a 3D object file created in a separate 3D modeling program (described in another tutorial).

Start With a Blank File

For this tutorial, start with a new, blank project in Moho. The completed file is also available for you to examine if you wish. It's named "Tutorial 2.8" and it's located in the "Tutorials/2 - Draw" subfolder within the main Moho folder.

Creating The Faces

Rectangle

The first step is to create the faces of the cube. In the initial, empty layer of your new project, use the Rectangle tool to draw a square. The square must be centered at the layer origin, must be truly square (not a rectangle), and should touch the top and bottom of the viewable area exactly. It's important that the square be precise - turning on the grid will help you draw this square.

What's important for this square is that the corners are at (-1, 1), (1, 1), (1, -1), and (-1, -1). Don't worry too much about the coordinates - if you use the grid, center the square at the origin, and make sure the top and bottom touch the top and bottom of the viewable area, the corners will be correct. Fill the square with a color of your choice and set its line width to 2.

Start with a square.

Next, create a group layer, name it "Cube", and put the layer with the square inside it. Duplicate the square layer five times and you should have a setup that looks like this:

Arranging the layers.

Positioning Faces

Translate Layer

Select the lowest layer in the group, "Layer 1", and make the Translate Layer tool active. We're not going to actually use the Translate Layer tool, but making it active allows us to position a layer numerically. At the top of the main Moho window, in the tool options area, set the value of "Z" to 1. This changes the depth of the layer, bringing it forward toward the camera.

Layer 1 depth setting.


Rotate Layer Y

Now select "Layer 2", and set its Z value to -1. You've just positioned the front and back faces of the cube. The settings get a little more complex from here on out. Select "Layer 3", and set its X and Y values to 1 and 0. Next, activate the Rotate Layer Y tool. The tool area will reflect the rotation of the layer around the Y axis. Set this value to 90:

Layer 3 rotated.


Next up is "Layer 4" - adjust it similarly to Layer 3. Set X and Y to -1 and 0, and set the layer Y rotation to 90. You'll need to activate the Translate Layer tool to set X and Y, and the Rotate Layer Y tool to set the rotation angle.

Rotate Layer X

"Layer 5" is next - set its X and Y position to 0 and 1. Next, activate the Rotate Layer X tool and set the rotation angle to 90 degrees. Note: Be sure to rotate this layer around the X axis, not the Y axis.

Finally, the last layer, "Layer 6" - adjust it similarly to Layer 5. Set X and Y to 0 and -1, and set the layer X rotation to 90. You'll need to activate the Translate Layer tool to set X and Y, and the Rotate Layer X tool to set the rotation angle.

Scale Layer

At this point the cube is basically finished, but it's a little too big to see in the workspace. Use the Scale Layer tool on the "Cube" group layer to make the entire thing a bit smaller. It should look something like this:


The finished cube.

Depth Sorting

The final step required to finish the cube is to turn on depth sorting. Double-click the "Cube" layer to bring up the Layer Settings dialog. In the "Depth Sort" tab, turn on the checkboxes marked "Sort layers by depth" and "Sort by true distance" and click OK. The first checkbox tells Moho to draw the back faces of the cube first, then the front ones. The second checkbox is a different way of sorting the layers that is mostly used for 3D constructions like this cube.

Orbit Workspace

Try using the Orbit Workspace tool to view the cube from different angles. It should appear as a true 3D object. You could now use the cube in a scene - using the Translate Layer and Rotate Layer tools to position it at an interesting angle, or to move it around during the animation.

The finished cube, with depth sorting.