CPSC 120: Principles of Computer Science
Fall 2002

Lab 11: Blender


BLENDER is a three-dimensional modeling and rendering program. This means that you can use it interactively to construct 3D "worlds" and you can render images of the worlds you create. Blender can make animations, and you will do some simple key-frame animation in this lab. Blender's interface has to be called unusual. You should not expect to be able to start up Blender and figure out what to do with it! Actually, the interface is pretty usable once you get experienced with it. But you will only use a very small part of the interface in this lab.

You can find a little gallery of images created with blender at http://www.elysiun.com/gallery.php. Blender is used in our computer graphics course, CS324. If you want to learn more about it, you could start by looking at some of the labs for that course on its home page, http://math.hws.edu/eck/cs324/. You could also look at The Blender Book, by Carsten Wartmann, a book about Blender that is on reserve for CS324 this term in the library. Blender is available for both Windows and Linux, with a buggy beta version for MacOS X. You can download it from http://www.blender.org; I have put a copy of a Windows installer for Blender 2.23 on the Windows network drive named \\math\public. You should be able to mount this drive and run the installer.


Running Blender

If you just start Blender, you will get a completely empty world, and you will have to add objects, colors, textures, and lights before you can render an image. To begin this lab, you will work with a Blender file that I have set up for you, objects.blend. This file already contains lights and colored objects on a stage, and it has several options set in a way that is appropriate for the lab. To open the file, just double-click on the icon named objects.blend in the lab11 directory. You will see a "stage" containing the objects. You are looking at a modeling window, where objects are ordinarily displayed as wireframe models. To see the rendered image, hit the F12 key. To make the rendered image go away, hit F11.

Viewing a Rendered Image
F12 Show a rendered image of the 3D scene
F11 Hide rendered image and return to modeling

basics In order to do modeling in Blender, you have to understand how to select objects, how to use the 3D cursor, and how to use the many "buttons" that control Blender. When Blender starts, most of the screen is filled with a "World Window" that gives a view of a three-dimensional world. Below the World Window is a Button Window, which will be discussed below. The World can contain objects, lights, and cameras. The view also contains a grid that lies in the xy-plane and a "3D cursor." These are not part of the world, just part of the user interface. The picture at the right shows part of the world after some modifications. At the top is an object, shown in pink. At the bottom is a camera. The view has been rotated to show that the camera appears as a pyramid with an arrow to show which direction is the top of the camera. The 3D cursor is the other object, on the right side of the image.



Modifying Objects

You can change a scene by transforming objects and by adding colors and textures to objects. To apply any operation to an object, you must first select it. Do this by right-clicking the object. You can transform an object by scaling, rotating, or translating it. Blender's interface is not obvious here! To scale the selected object, hit the "S" key, then move the mouse without holding down a button. The object changes size. To finish scaling the object, click the left mouse button. Clicking the right mouse button will return the object to its original size. Rotation and translation are similar: To rotate the selected object, hit the "R" key, then move the mouse and hit the left mouse button to finish. To translate, hit the "G" key (G stands for "grab"), move the mouse, and hit the left mouse button to finish. (Or, instead of moving the mouse, you can use the arrow keys, and instead of clicking the left mouse button to finish, you can hit return.) Try this on some of the objects in the sample scene.

Transformations
Translation Press the "G" key. (G stands for "grab".) Move the mouse without holding down any button. You can move the object in the plane of the screen only. Click with the left mouse button to finish. Click with the right mouse button to abort. If you click with the middle mouse button after starting the move, the motion will be constrained to vertical only or horizontal only. Clicking with the middle mouse button does not end the move.
Scaling Press the "S" key. Move the mouse towards or away from the object to change its size. The size changes in all three dimensions. Click with the left mouse button to finish. Click with the right mouse button to abort. If you click with the middle mouse button after starting the scaling operation, the object will be scaled in the vertical or horizontal direction only.
Rotation Press the "R" key. Move the mouse to rotate the object around a line perpendicular to the screen. Click with the left mouse button to finish. Click with the right mouse button to abort. If you click with the middle mouse button after starting the scaling operation, you can rotate the object freely in three dimensions.

Material Buttons To change the color of an object, first select the object. Then hit the F5 key to show the "Material Buttons" in the lower part of the screen. The left portion of the material buttons is shown at the right. To change the color of the object, just adjust the "R", "G", and "B" sliders. (Note that you won't even see the Material buttons unless a "material" has already been added to the object. The objects in the sample files in the sample objects already have materials, so you don't have to worry about this for now. If you have to add a material to a newly created object, it is similar to adding a texture, as described below, except that you are working in the material buttons instead of in the texture buttons.)

Colors are fine, but objects that have textures are more exciting. A texture makes the surface properties of an object vary from one point to another. I have not added textures to any of the objects in the sample scene. To do this, you have to use the "Texture Buttons". Select an object and hit the F6 key to show the texture buttons for that object. There won't be much there right now, since none of the objects have textures. To add a texture, you have to find the "Add New" command in a menu that seems to have been very carefully hidden by the designers of Blender. Look for a small button at the top of the texture button area that displays nothing add button but a small white rectangle, as shown at the right. This is the menu for adding and selecting textures. Click-and-hold on this menu to see your choices. Right now, the only choice is "Add New". Select this option. (If there are other textures already in the scene, you can choose one of them to add to the object.)

When you add texture, a set of buttons will appear that can be used to select and edit the texture you want. Try the Clouds, Wood, or Marble textures . Click the "Clouds", "Wood", or "Marble" button to select one of these. When you do this, new buttons will appear that allow you to set some parameters of the texture. The Marble pattern, for example, usually looks better if its set to "Sharp" or "Shaper" rather than "Soft."

The Clouds, Wood, and Marble textures make patterns of two colors. The funny thing is that both colors are set using the Material Buttons. The Texture Buttons set the pattern that the colors make, but not the colors themselves. So, to adjust the colors, go back to the Material Buttons by pressing F5. One of the colors for the texture is the basic material color, as set by the RGB sliders on the left side of the Material Buttons. The other colors is set by another set of RGB sliders that can be found on the right side of the Material Buttons. The default is an ugly magenta, so you probably want to change it.

An "Image" texture is an image that is applied to the surface of an object. If you select the image texture type, you still have to select the particular image that you want to use. Click the "Load Image" Button. The modeling window will be replaced by a window where you can choose a texture. You can use just about any image -- I have provided a few images in a folder named "blender-textures". To get to these textures, you have to click on "cpsc120" in the list of directory names, then on "lab11", then on "blender-textures". You should see a collection of available images in the top part of the screen. To select one of these, left-click on it and then press return.

To make an image texture look really good, you sometimes have to change some of its parameters. I won't tell you how to do this here. If you want some help on it, please ask.

Color and Texture
F5 Show the material buttons for selected object.
F6 Show the texture buttons for selected object.

Simple Animations

Blender uses key-frame animation. You set the properties of an object in selected key frames, and the computer fills in the animation for the frames between the key frames. The current frame number is displayed in a small button below the modeling window, on the right. (Ask for help if you can't find it.) You can change the current frame by hitting the arrow keys or by shift-clicking the frame number button and typing the new frame number. (The left and right arrow keys move you one frame at a time; the up and down arrow keys move you 10 frames at a time.)

To animate an object, you have to set its properties in two or more key frames. Start by going to frame 1. Set the size, position, and rotation that you want the object to have in frame 1. Then hit the "I" key. "I" stands for Inserting a key frame value. A menu will pop up which asks you what values you want to insert. For this lab, always click the entry labeled "LocRotSize", which makes it possible to animate the location, rotation, and size.

Now, go to the frame number that will be used as the second key frame. Set up the object as you want it to appear in that frame. Now, hit the "I" key again and click on "LocRotSize". You can repeat this for more key frames if you want.

Once you have set up at least two key frames, you can use the arrow keys to move from frame to frame. You should see the object animate as you do this.

To play a preview of the animation in the modeling window, go to frame 1 and hit "ALT-A". To stop the animation, hit the ESC key.

Animation
"I" key Insert key frame data for selected object
Arrow keys Move from frame to frame
ALT-A Play a preview of the animation

Exercise

Before you leave lab, show me a rendered image in which you have placed textures on several of the objects in the sample scene. Also show me that you have set up some kind of animation. This exercise will count for up to 10 points. If you complete one part, you get 8 points. If you do both parts, you get 10 points.



Extra Information

The rest of this lab contains some extra information that you might not have time to look at in class. This is what you need to know if you want to add new objects to the scene, or if you want to be able to do modeling effectively, or if you want to save an image that you have created. Most of this is taken from one of the CS324 labs. You can read this part if you want...


Changing Your View of the World

The World Window shows you a two-dimensional projection of a three-dimensional world. You need to be able to change the view, to look at the world from a different viewpoint. This can be done using the mouse or using the keys on the numeric keypad. This table tells you how. Note that this only changes the view you see in the modeling window, not the view that will be produced when you render the image -- to change that, you have to move the camera. Note that keyboard commands are sent to the currently selected window. To make sure they are sent to the World Window, click on the World Window.

Changing the View with the Keypad
Keypad 0 View from the camera. (This is the original view in the sample scene.)
Keypad 1 View from "above", along z-axis.
Keypad 3 View from "front", along y-axis.
Keypad 7 View from "side", along x-axis.
Keypad 2,4,6,8 Rotate the view.
Keypad +,- Zoom in and out.
Keypad 5 Switches between "orthogonal" and "perspective" projection. (Orthogonal, the default, is generally best for modeling, but perspective is closer to what to you would actually see.)
Changing the View with the Mouse
Drag with middle mouse button -- Rotate the view. (A rotated view might look cool, but it's not necessarily best for modeling.) The "middle mouse button" refers to the little wheel on the mouse.
Hold down Shift, and drag with middle mouse button -- Translate the view (up, down, left, right).
Hold down Control, and drag with middle mouse button -- Zoom the view. Move mouse up to zoom in, down to zoom out. (Position of mouse affects zoom speed.)

Adding and Deleting Objects

Suppose that you want to add a new object to the world. This is where the 3D cursor comes in. A newly added object is always added to the world at the position of the 3D cursor. You have to position the 3D cursor before adding the object. The 3D cursor is positioned by clicking, with the left mouse button, on the world window. The 3D cursor is positioned in three-dimensional space. You can't tell where it is by looking at the world from one point of view. Typically, you would check the position of the 3D cursor from several viewpoints by using the Keypad 0, 1, 3, and 7 keys to switch between viewpoints.

The ADD menu Once you have the 3D cursor in position, use the "Add" menu to add an object to the world. Click on "Add" in the menu bar, then click on "Mesh" in the menu. This gives a sub-menu containing various mesh objects. ("Mesh" just means that it's made up of polygons.) The picture at the right shows the "Add" menu being used to add a "UVsphere." A UVsphere is a sphere divided by lines of latitude and longitude. A ICOsphere is divided into triangles. A Plane is actually just a rectangle. (When you first start Blender without using the sample file, the default world that you see contains a Plane as its only object.) A Tube is a cylinder without the top and bottom face filled in.

Vertex dialog When adding certain types of objects, you will have to answer a question or two. For a Cylinder, for example, you have to specify the number of vertices. The image at the left shows the little dialog box that shows up when you use the Add/Mesh/Cylinder command. To accept the default value of 32, just press return or click OK. The button that says "Vertices: 32" is one of Blender's funny input buttons. To change the value on such a button, click and drag on the button or else shift-click the button, type a new value, and press return.

After adding an object, you should immediately press the TAB key. Objects are added in something called "Edit Mode," which I will not discuss here. Edit Mode is a little strange! The TAB key gets you out of Edit Mode. This is important since you can get confused if you work in Edit Mode without understanding it.

Remember that you must select an object in order to work with it in any way. Select an object by right-clicking on it.

To delete the selected object, just hit the X key. You will be asked to confirm the deletion. For these and all keyboard commands, the command is sent to the selected window. You can make sure that the World Window is selected by left-clicking it. (If that window not selected, the X key will be ignored.) Instead of the keyboard, you can use the "Delete" command in the "Edit" menu. You'll see menu equivalents for many keyboard commands, but it's worth learning the keyboard.


Saving Files

Working with files is my least favorite part of blender, but you have to know how to do it if you want to save your work. The "Save" and "Save As" commands in the "File" menu are used to save complete Blender projects. This allows you to come back later, open the file, and continue work in Blender on the same project.

file saving When you save or open a file, the World Window changes into a File Browser window. There are two lines at the top of the window that show the directory where the file is to be saved and the name that is to be given to the file. You can enter these by clicking and typing. Press return to finish typing a line. The image shows the directory and file names, just after I have typed the file name, before pressing return. To actually create the file, you have to press return again, or click the "Save File" button at the top-right of the window.

You can also browse the list of files to select the directory. Similarly for the file name, if you are opening a file or if you are saving and want to replace an existing file.

The "Save Image" command can save a rendered image in a variety of image formats. Don't forget to render the image before you try to save it. In the sample file, the defaults are set up to save a 640-by-480 pixel image in JPEG format. That is probably OK, so you can just go ahead and save the rendered image with a name that ends with the extension ".jpg". A JPEG image is suitable, for example, for placement on your web page.

If you are not using my sample, scene, then before saving an image, you have to set the image size and file format. To set the size and format, you need to use the Display Buttons. Click the little scene icon at the top of the Button Window (or hit F10). Here is some of what you should see:

display buttons

The button labeled "Jpeg" at the lower right of this image is a pop-up menu that is used to set the file format of saved images. Make sure that this is set to Jpeg. Just above that button are numeric buttons called SizeX and SizeY that are used to set the size of a rendered image. Shift-click on one of these buttons if you want to type in the size. Clicking the Render button is equivalent to hitting F12. The button labeled "OSA" is a toggle button that can be either on or off. Here, it has been set to on. Turing OSA on increases the quality of the image, at the expense of a little more rendering time.

Remember that to save an image, you should set up the Display Buttons, render the image, and then use the "Save Image" command to save the rendered image to a file. For Jpeg images, you should use a file name that ends with .jpg or .jpeg.

I have not described how to save rendered animations. If you are interested, you can look it up. Note, however, that a rendered animation can use a lot of hard disk space.


David Eck, November 2002