CPSC 324: Computer Graphics
Fourth Lab
March 20, 2001

In today's lab, you will be working with blender. In this lab, we will concentrate on geometry, although you will want to add materials and lighting to your objects before rendering them. You can find the blender program on the "N" drive in the cpsc324 directory. You will also find there a program called "QuickRes". Run this program first, by double-clicking on it. It adds an icon to the Windows toolbar tray that you can use to increase the resolution of the screen. This will make it much more pleasant to use blender. Increase the screen resolution, and then start up blender.

The first section of the lab reviews some of the basics of the blender interface. I advise you to read through this section, maybe try some things out, and then use it as a reference.

The remainder of this lab worksheet consists of three little modeling projects. These are designed to illustrate some of blender's features and to introduce a number of new ideas. Your "lab report" for this lab will consist of at least one images from each of these three projects. You should do the planet, something with either text or curves or both, and either the rook or the pawn or both. These images should be on your Web site no later than Tuesday, March 27.

Basics

Although blender has its own unique interface, it's pretty comfortable once you get used to it. Remember that the interface is really meant to be used with a three button mouse. You can simulate the middle mouse button by clicking both buttons on the mouse or by ALT-clicking with the left mouse button (depending on the computer you are using.) Also, blender uses the older UNIX standard for determining where a keystroke is delivered: Any time you want a keystroke to affect a certain window, the mouse cursor must be over that window. Also, remember that buttons that display numbers can generally be changed by clicking, by clicking and dragging, or by SHIFT-clicking on the button with the left mouse button. After SHIFT-clicking a number-input button, you can edit the value using the keyboard, and you can't do anything else with blender until you press return (or hit ESC to restore the original value).

Windows: The default blender screen shows two windows: a 3D window and a Buttons window. Each window has a header, which is at the top of the Buttons window and at the bottom of the 3D window. There is also a separate, general header at the top of the screen. However, you can customize the screen extensively:

Basic Viewing: Your view of the 3D window can be controlled in several ways using the mouse and the keyboard.

Basic Editing: When you add an item to the blender scene, it is added at the position of the 3D cursor. You can position this cursor by clicking on the 3D window with the left mouse button. You generally need to look at the scene in several different views to get it positioned properly in 3D space. For more exact positioning of the cursor or any selected object, you can hit SHIFT-S to bring up the "Snap" menu. Choose "Curs -> Grid" to snap the cursor to the nearest grid point.

To add an item to the scene, hit SPACE or SHIFT-A to bring up the main blender menu. This strange menu has two parts. To add an item, point the mouse at the top item in the left part, then move the mouse to the right part of the menu and click a selection. If you select Mesh, Curve, or Surface, you will get another level of the menu, where you can select a particular type of object. In blender terminology, a "Mesh" is simply a surface made up of vertices and polygons, like those we've seen in OpenGL. A "Surface" is more like the Bezier curves that we saw in GIMP: The surface is determined by some control points, and you deform the surface by moving the control points. "Curves" are like surfaces in that they are determined by control points. For Bezier curves, the control points take the form of "handles" like those you saw in GIMP.

When an object is added, it is in "edit mode". In edit mode, you work on the modeling of the object itself. For a mesh, you can move vertices. For a surface, you can move control points. For text, you can type characters. In edit mode, vertices are shown in pink or yellow. Yellow vertices are "selected." To get out of edit mode, hit TAB. To edit an object, later, select it and hit TAB to enter edit mode for that object.

Here are some basic editing operations. For the most part, these apply to vertices or control points in edit mode and to complete objects when you are not in edit mode.

Layers: You can use layers to organize your work in blender. These are not layers in the sense of being stacked up to make the final view. Objects in different layers are all mixed together in the final image. Layers in blender are used to organize your work. You might set up your lights in one layer and your objects in another layer, for example. You can turn layers on and off using the group of 20 little buttons near the left end of a 3D Window. Use a SHIFT-click to activate more than one layer at a time. You can also activate layers with CTRL-1, CTRL-2, etc -- or with SHIFT-CTRL-1, SHIFT-CTRL-2, etc to activate multiple layers. To move an object to a particular layer, select the object and hit the "m" key. (I mention this partly because I "lost" my work a couple of times by accidently activating a different layer, before I realized how layers work.)

Buttons, Buttons: Much of the power of blender is hidden in the buttons that are displayed in the Buttons window. This window can display many different sets of buttons, depending on which icon is selected in the Button window header, on which object is active, and on other things. The number of options can be very intimidating, but you don't need to understand everything to get useful work done. For this lab, you will only use the Material buttons, the Edit buttons, the World buttons, and the Display buttons. You might also want to use the Lamp and Texture buttons to improve your scenes. You should identify the icons in the Buttons window header that select these sets of buttons. (If tool tips are turned on, this will be easy.)

When you select one of the icons to choose a set of buttons, you might just see an empty window. For example, with the Lamp buttons, you won't see any buttons unless a lamp is selected in the scene. If a lamp is selected, you will see a set of buttons that allow you to set all the properties of the lamp. For the Material buttons, an object must be selected, or you won't see any buttons. Furthermore, the selected object must have a material assigned to it. You do this with the deceptively unimportant looking button in the window header that just shows a small white rectangle. Click-and-hold to see a list of materials that already exist, plus an entry that let's you "Add New" to create a new material. Note that several objects can share the same material. You have to use the same sort of pop-up menu to create a "world" in the World buttons or a texture in the Texture buttons. Technically, a texture is applied to a material, not to an object, so you have to assign a material to an object before you can add a texture.

The Edit buttons are the worst. You get a different set of Edit buttons for each type of object. Which set you see depends on which object is selected. For example, if you select a camera object, the buttons will let you set the lens angle and the near and far values for OpenGL's viewing setup.

I will mention other buttons -- and other aspects of blender -- as they come up in the following sections of this lab and in future labs.


Your Own Planet

My Planet In this exercise, you will make a "planet" something like the one shown at the right. In doing this, you will see how to duplicate objects, subdivide a mesh, set up a "world" with stars, background, and ambient light.

Here are the steps for making the image:



Text and Curves

Pic with text Blender supports two types of curves: Bezier curves and NURBS curves. For now, we will stick with Bezier curves. Blender fills in the interiors of closed curves. It is also possible, as we will see, to give the curve object a thickness in the third dimension. Blender also has text objects. A text object is similar to a curve. In fact, you can convert a text object into a curve and then edit it the same way you would any curve. (However, you can't convert it back to a text object.) In this exercise, you will do some work with text and curves.

Start with a new scene. Add a Bezier curve. You will get a short curve with a control point on each end. Each control point has two attached handles. You can select and drag the control point to move the point itself`. You can also select and drag a handle to change the shape of the curve. (You only see the control points and handles when the curve is in edit mode.)

To extend the curve, select one of the control points at the end of the curve. You can then Control-click with the left mouse button to add new points. Add a few points to the curve, then hit the "c" key to close the curve by connecting the endpoints. Now, try moving the control points and adjusting the handles. Control points come in several styles. Select a control point and hit the "h" key. You will now be able to drag each handle separately. Hit "h" again to return to the default mode, in which the two handles are forced to make a straight line. If you select a control point and hit the "v" key, it will turn into a corner vertex, where the handles always point along a line to the next control point. If you select two or more control points in a row, and go to the edit buttons, you will find a "Subdivide" button that will add new control points between the selected points.

If you have a closed curve and hit the "z" key for a shaded view, you will see that the curve is filled in. You also have to leave edit mode to see the shading. Now, while you are in edit mode, add a Bezier circle to the scene. When you add a curve while you are in edit mode for another curve, it is not added as a separate curve. Instead, it becomes part of a single, multipart curve. Position the circle so that it lies entirely within (or outside of) your original curve. Scale it if necessary. Now, when you leave edit mode and hit the z key, you will see that blender only fills in the area between the curves. So, using multipart curves, it's possible to create fancy shapes with holes in them.

This gets really cool when you add a third dimension to your curve. Leave edit mode. Make sure that the curve is selected. Go to the Edit buttons. Look for the buttons, near the left end, named "Ext1", "Ext2", and "BevResolv". Ext1 controls the extent in the third dimension. Set it to about 0.2 and rotate the view to make sure you see the effect. Ext2 adds a rounded edge along the border of the curve. Try it. Setting BevResolv to a value greater than 0 will smoothen the edge produced by Ext2. It has no effect unless Ext2 is non-zero. You can see the effect in the 3D window wireframe view. Some Curves The picture at the right shows two curves that have been made three dimensional and have been assigned some materials.

Next try adding a text object to your scene. When a text object is in edit mode. you can only edit the text by typing characters or by using the backspace and arrow keys. You can also make multiline text by pressing return. When you've edited the text, leave edit mode. Go to the edit buttons. You will find the same Ext1, Ext2, and BevResolv options that you had for curves, so you can make 3D text with rounded edges. Right in the middle of the Edit buttons, you will find a button that you can click to use a different font. Blender can use any Type-1 postscript font. I have put a directory of such fonts in the cpsc324 folder on the "N" drive. (These came with one of my blender books.) You can try using different fonts for your text. Just above the Load Fonts button is a pop-up menu that you can use to select from fonts that have already been loaded.

Below the Load Font button is a set of buttons for setting the justification of multi-line text. Below that is the "Text on Curve" button. If you enter the name of a curve here, the line of text will be shaped to follow the curve. The text won't be moved to the position of the curve. It will only take its shape from the curve. You can see an example of this in the above image. To apply this effect, you need a curve and you need to know the name of the curve. Add a Bezier curve and edit it into a nice shape and size. Go to the edit buttons. The name of the curve is shown in the Edit window header. It is labeled "OB:". You can change the name if you want. Now select the text object. Go to the Edit buttons and enter the name of the curve in the "Text on Curve" button. The text will actually be reshaped when you click back on the 3D window.

Although text is not a curve, you can convert it to a curve. Select a text object in your scene and hit ALT-C. You will get a pop-up that lets you convert the text to a curve. One reason for doing this is that you can then enter edit mode and edit the vertices on the individual letters. Also in Edit mode, you can add more curves that become part of the same multipart curve object. For example, to make the "Computer Graphics!" logo shown above, I added a scaled circle around the text, after converting the text to a curve.



Rook and Pawn

We finish with two useful techniques for modeling: extrusion and lathing. As examples, I will show you how to make two chess pieces.

Rook and Pawn Before we do that, though, let's try a simple extrusion. Start with a new scene and add a cube. In edit mode, select all the vertices on onc face of the cube. Hit the "e" key. You will get a pop-up where you can confirm that you want to extrude. When you do this, the selected vertices are duplicated, and you will find yourself in grab mode. Move the mouse to position the new vertices, then left-click or hit return to end grab mode. At this point, use the "s" key to scale the selected vertices. Then hit the "e" key to extrude again. Move the new vertices and scale them. You might want to rotate the view and use shaded mode ("z" key) to see the full effect. Now, you could go back and select a different set of four vertices and extrude them once or twice. If you do this a few times, you can get an interesting branching structure. (Aside: For a cool effect, select this object, go to the Edit buttons and click the S-Mesh option. Now, the mesh you have created is used to establish the basic shape for a more nicely curved surface inside the mesh. In effect, the mesh acts as a set of control points for this surface, and it's only the surface that is drawn.)

Now that you've had some experience with extrusion, let's try to make a rook. Start with a Mesh circle with 18 vertices. (The number is important.) In edit mode, make sure all the vertices are selected, and do an extrude by hitting "e". But then hit ESC immediately, since you don't want to move the vertices. Instead, hit the "s" key and scale the new vertices to get a flat ring shape made up of 18 little quadrilaterals. We will first use this ring to make the six blocks on the top of the rook. (At first, I tried doing this as the last step, but I had trouble selecting the right vertices after the rest of the rook was made.)

Deselect all the vertices, then select the vertices that will be extruded to make the six blocks: Select four vertices around one of the quadrilaterals. Then skip the next two vertices in the ring. Then select another four vertices. And so on. Switch to a side view (Keypad-3) and do the extrude. Move the new vertices upwards about 1 unit. (Hold down the control key or click the middle mouse button to make sure the vertices are moved directly upwards, with no sideways displacement. Rotate the view to see what you've made, if you want.

Now, you should select just the original vertices in the ring. (This is easy to do with a box select in the side view.) Still working in the side view, extrude them directly downwards five times. After the second extrude, scale the vertices down a bit, and after the fourth extrude scale them back up to make a shape like the one shown in the image on this page. You have your rook!

Now, you might wonder why my rook has nice smooth sides while yours is faceted. If you use the "Set Smooth" button on the rook, it will look really terrible, because blender will try to smooth edges that should really look sharp. For my rook, I first turned on the "Autosmooth" option in the Edit buttons and then hit "Set Smooth". Blender will then smooth only those faces that meet at a relatively small angle, without trying to smooth the sharp edges between faces that meet at a large angle. Unfortunately, you will only see this smoothing in the final rendered image, not in the preview, and whether it works well depends on the exact shape of your rook.

Curve for Pawn Next, let's try to model a pawn. Start working in the top view (Keypad-7). Hit SHIFT-C, which will move the 3D cursor to (0,0,0). It's important that the 3D cursor lie in the xy-plane, since we need to draw a curve that lies exactly in that plane. Add a Bezier curve. Extend it (with CTRL-left-mouse) and shape it half of the outline of a pawn -- something like the picture. I used snap-to-grid (SHIFT-S) to get the two endpoints exactly on the y-axis. (This is also important!) To make the sharp corner at the bottom right, I selected a control point there and hit the "v" key to make it into a corner. You don't have to use exactly the shape that I used. We are going to spin this curve around the y-axis to make the pawn. This process is known as "lathing".

Exit from edit mode. Select the curve and hit ALT-C. You will be asked if you want to convert the curve into a mesh. Confirm this. This is important, since lathing only works on meshes.

Now, left-click near the y-axis and use snap-cursor-to-grid (SHIFT-S again) to make sure that the 3D cursor is exactly on the y-axis. The 3D cursor specifies the line that we will spin the curve around.

Select the curve and go back into edit mode. Select all the vertices in the curve. Switch to a front view (Keypad-1) so that the y-axis will be perpendicular to the screen, and go to the Edit buttons. Find the button labeled "Spin". In the row of buttons beneath the Spin button, change the Degr to 360 and steps to 20. (The 360 says you want to spin the curve in a complete circle. The 20 says you want to make 20 copies of the curve as it spins.) Now you are ready to do the lathing: Click the spin button. If all has gone well, you will now have a nicely shaped 3D pawn. (If you have more than one window, then when you click the "Spin" button, the cursor will change to a question mark and you will have to click on the 3D window where you want to do the lathing.)

There is one problem with lathing in blender: You get an extra set of vertices at the final position, and this can make an unsightly seam in the object. To eliminate this, in edit mode, select all the vertices in the pawn. Then click the "Rem Doubles" button in the Edit buttons. This will remove the extra vertices by combining any pair of vertices that are very close together.

As a final step, hit the "Set Smooth" button to give the pawn a smooth rather than faceted appearance. That should do it. As you can see, lathing is a complicated affair, but the results can be very nice.



David Eck, March 2001