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.
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:
- You can resize windows by dragging the border between windows with the left mouse button. Also, if you drag down the border at the top of the 3D window, you will reveal a set of buttons that can be used to set certain aspects of blender's behavior. (These buttons are actually an "info window", and the header at the top of the screen is the window header for the info window.) For example, there is a toggle button that you can use to turn "tool tips" on and off. More important, there is an option for "Auto Temp Save." If this option is on, blender will save a backup copy of your work periodically into the specified directory. (You could set this to be a directory on your "M" drive.) When you quit blender, this file is named "quit.blend". Also, there is a button for setting the number of "versions". If you set this to greater than 1, then blender will keep backups when you replace a file with the same name. For example, if you have a file named "file.blend" and you save another "file.blend", then the old file will be renamed "file.blend1".
- You can split and join windows. Typically, you might want to split the central 3D window so that you will have several views of your scene. To split or join windows, click on the border of a window with the middle mouse button. A pop-up will ask you whether you want to split or join. If you click on a border between two windows, and if you ask blender to split a window, which one it splits will depend on which window the mouse was in before you moved it over the border. When you ask to split a window, a divider will appear on the window. Move the mouse to position the divider, then click the left mouse button. (As will almost every operation in blender, you can abort the split operation by hitting the ESC key.)
- Right-click on the header of a window to get a pop up that will allow you to remove the header or switch it between top and bottom of the window.
- Blender has several different types of windows. You can change the type of a window at any time. (Sometimes the type is automatically changed temporarily, as when you open a file.) The type of a window is controlled by a pop-up menu at the left end of the window header. For now, you only need to recognize the icons for 3D window and Buttons window.
Basic Viewing: Your view of the 3D window can be controlled in several ways using the mouse and the keyboard.
- Click-and-drag with the middle mouse button to rotate the view in a 3D window. Shift-click-and-drag with the middle mouse button to pan the view (slide it left/right/up/down). Alternative, you can click-and-drag with the left mouse button on the icon of a four-headed arrow in the 3D window header. Control-click-and-drag with the middle mouse button to scale the view. In this case, rather unintuitively, the displacement of the mouse from its original position gives the rate of scaling rather than the amount of scaling. That is, if you just move the mouse a bit and hold it, your view will continue to zoom in or out. Alternatively, you can use the "+/-" icon in the 3D window header to zoom the view. Note that you can do zooming and panning in other windows besides the 3D window. Also, note that panning works in a window header, in case the entire header does not fit in the window.
- You can also zoom the view with the + and - keys on the keypad. The 2, 4, 6, and 8 keys on the keypad can be used to rotate the view.
- The 7, 1, and 3 keys on the keypad choose views onto the xy-plane, the xz-plane, and the yz-plane, respectively.
- The 5 key on the keypad switches between an orthogonal and a perspective view. Orthogonal is generally better for modeling.
- The 0 key on the keypad chooses the view from the camera. (Note that you can actually have several cameras, but only one can be active. To activate a camera, select it by right-clicking on it, and then hit CTRL-KEYPAD-0.)
- The Home key (above the arrows) will scale the view so that all objects are visible.
- The / key on the keypad will hide objects that are not selected and will scale the view to show the selected objects. This is useful for editing a subset of the objects in the scene.
- The . key on the keypad will scale the view in the same way as the / key on the keypad, without hiding the unselected objects.
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.
- To select an object (or vertex or control point), right-click on it. To select multiple objects, use SHIFT-right-click. The last object that you select in this way is the "active" object. (Certain operations apply to the active object, rather than to all selected objects.) You can also select multiple objects with a box-select. Hit the "b" key. Then use the left mouse button to draw a rectangle around the items you want to select.
- In edit mode, the "a" key is used to select/deselect all vertices. (Outside of edit mode, this applies to objects rather than vertices.) If any vertices are selected when you hit "a", then all the vertices are deselected. If no vertices are selected when you hit "a", then all the vertices will be selected. (By the way, besides vertices, each object has a center point which is used as the default center for rotation and scaling. It's possible to drag all the vertices away from this center point -- something you don't usually want to do.)
- The X key can be used to erase items. You will get a pop-up where you can confirm the erase, or clarify what it is you want to delete. You can use CTRL-X to erase everything and return to the start-up screen.
- Hit the "g" key for grab mode. Then you can move the selected items, within the plane of the screen, by moving the mouse. Press the left mouse button or hit return to finish. You can also press the right mouse button or hit ESC to abort and put the objects back where they started. A neat alternative way to initiate grab mode is to left-click and drag the mouse in a short straight line anywhere on the 3D window, but then don't forget to release the button.
- Hit the "s" key for scale mode. Then you can resize the selected items, in all three dimensions, by moving the mouse. Hit return or left-mouse-button to end; hit ESC or right-mouse-button to abort. It is the motion of the mouse towards or away from the center of scaling that matters.
- Hit the "r" key for rotation mode. You can rotate the selected items about a line through the center of rotation and perpendicular to the screen. Hit return or left-mouse-button to end; hit ESC or right-mouse-button to abort. A neat alternative way to initiate rotation is to left-click and drag the mouse in a circular motion, anywhere on the 3D window.
- After you start a grab, scale, or rotate, you can hold down the Control key to constrain the values to rounded values, such as increments of one unit in a drag or five degrees in a rotation. Note that the amount of change is shown at the left end of the 3D window header. You can also hit the arrow keys to move the mouse cursor by exactly one pixel.
- After you start a grab or scale, you can click the middle mouse button to constrain the motion/scaling to just one direction. Note that you should click and release the button. If you middle-click again, you will return to unconstrained mode.
- Hit the "n" key to view and/or edit the translation, scaling, and rotation that are being applied to the active object in numerical form. This does not work in edit mode.
- In edit mode for a mesh object, you can edit individual vertices and selected sets of vertices. Blender has a neat feature called "proportional editing" to make this more effective. When you are in edit mode for a mesh, you will see an icon in the 3D window header that looks like a little grid. Click this to turn on proportional editing. You will then see two other icons that can be used to select the style of proportional editing. Then select a vertex and drag it. You will see that nearby vertices, within a radius of influence, will be dragged along with it. While dragging, you can increase or decrease the radius of influence by hitting the keypad + and keypad - keys.
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
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:
- Start with a new scene. (Use CTRL-X, and press return to confirm the pop-up, to erase everything. If you still have the little square in your default scene, delete it.) Add a Mesh:UVSphere with about 20 segments and 10 rings. Exit from edit mode by hitting TAB. Scale the sphere to fill most of the camera view (Keypad-0). Assign it a nice blue material.
- Make sure that the sphere is still selected. Hit Shift-D to duplicate it. As soon as you do this, you will be in Grab mode, so you can move the new sphere to a new position. However, in this case, you want to leave it in exactly the same place as the original, so hit ESC to abort the drag operation. Assign a new material to the new sphere, and set it to be a deep brown. I found it useful to set the specular color to be a brownish color as well
- Go into edit mode by hitting TAB. Hit A to select all the vertices. Now, go to the Edit buttons. Click the "Fract Subd" button and then click "OK" in the pop-up. Repeat this four or five times. (This "fractal subdivide" command will subdivide all the faces of a mesh, and it will displace the new vertices by a random amount. The number in the pop-up determines the amount of displacement. The default value of 10 works OK here.) With the mouse cursor over the 3D-window, hit the Z-key. This will show you a colored, shaded preview, which should already look pretty good.
- Add a lamp to the light the scene. It's a good idea to go to the Lamp buttons and increase the "energy" of the lamp. You will now be able to render your scene.
- We will improve the scene by putting it into a "world". Go to the World buttons, and use the little pop-up in the header to add a new world. The default world shows a gradient from black to blue in the background. You can change the colors with the controls at the left end of the World buttons. Click the "Stars" button if you want to have stars in the sky. Also, you should turn on some "ambient lighting". Ambient light is sourceless light that illuminates everything in the scene. It will let you see parts of the scene that are not illuminated by the lamp. To get some ambient light, set each of the sliders labeled AmbR, AmbG, and AmbB to about 0.3.
- Save a rendering of your planet in JPEG format for use on your Web page. To make the final rendering, go to the Display buttons. Click on the JPEG button, near the lower right, to select the format. You can set SizeX and SizeY if you want a larger picture. To reduce the file size with only a small effect on appearance, change the value of "Quality" from 0.95 to something like 0.70. Turing on the "OSA" option will enable anti-aliasing, which can increase the quality of the rendered image, with some increase in rendering time. Hit the Render button, then hit F3 to bring up the file dialog and save the image. After selecting a directory, type in the file name and hit return twice. Use a name that ends in .jpg or .jpeg.
Text and Curves
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. 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.
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.
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