Learn to Program using Alice

Setting the Stage

Learn about the eight separate sections of the Alice view that is used for setting the stage.  

Published:  March 26, 2007
Updated:  April 22, 2007
By Richard G. Baldwin

Alice Programming Notes # 105


Preface

Second in a series

This is the second lesson in a series of tutorial lessons designed to teach you how to program using the Alice programming environment under the assumption that you have no prior programming knowledge or experience.

My objective in writing this series of lessons is to make it possible for people who have no previous programming experience to learn programming fundamentals using Alice.  As such, I intend to discuss programming issues at a very fundamental level.

A lot of fun

Because Alice is an interactive graphic 3D programming environment, it is not only useful for learning how to program, Alice makes learning to program fun.  Therefore, you should be sure to explore the many possibilities for being creative provided by Alice while you are learning to program using these tutorials.  And above all, have fun in the process of learning.

Not especially difficult

Computer programming is not especially difficult.  However, it does require an aptitude for solving problems.  In fact, a computer program is usually a model for a solution to someone's problem.

One step at a time

If you can learn to program a VCR, you can probably also learn to program a computer.  Of course, a computer is somewhat more complicated than a VCR, so there is more to learn.  The important thing is to take the learning process in deliberate steps making certain that you understand each step before moving on to the next.

General

In the previous lesson titled "Learn to Program using Alice, Getting Started" (see Resources), I told you that creating and animating an Alice world consists of two very distinct steps.

The first step

The first step, which I refer to as setting the stage, has nothing to do with programming.  This step is similar to setting the stage for a stage play or a movie production.  It involves a manual process of painting scenery, selecting costume colors, putting the players, the scenery, and other objects in their correct positions on the stage, and getting ready for the curtain to rise, or the cameras to roll.

The second step

The second step is to write the program to animate the world causing the players to behave according to your plans.  While learning how to write the program to animate the players is the final objective of this series of tutorials, before we can get to that, you will need to learn how to set the stage.

Learning to set the stage

This and the following tutorials will teach you how to use the Alice development environment to set the stage for your animated worlds.  This will not be an exhaustive treatment.  Rather, in these early lessons, I will teach you just enough to get you started.  You will learn other tricks and techniques that you can use in setting the stage in future lessons, and in your own experimentation.

Figures

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures while you are reading about them.

Supplementary material

Once you have mastered Alice, I recommend that you also study the other lessons in my extensive collection of online programming tutorials.  You will find a consolidated index at www.DickBaldwin.com.

A description of the Alice environment

Probably the first thing that we need to do is to take a look at the Alice environment and to learn the purpose of each of the major sections of that environment.  I will explain the general purpose of each section of Figure 2 in this lesson and will do the same for Figure 1 in future lessons.

Two distinctly different views of the environment

Just as there are two distinct steps in creating and animating an Alice world, there are two distinctly different views of the Alice environment.  One view is used for writing the program to animate the world, while the other view is used mainly for setting the stage.

Alice view used to animate the world

Figure 1 shows a greatly reduced screen shot of the view that is used for writing the program to animate the world after you set the stage.  I will often refer to this as the program edit mode.

Figure 1. The program edit mode.

This seems to always be the view that is showing when you first start the Alice environment running, so I decided to place it in Figure 1.  We will not be using the view shown in Figure 1 in this lesson, but will use it extensively in future lessons.

Alice view used to set the stage

Figure 2 shows a greatly reduced screen shot of the view that is used for setting the stage.  This is often referred to as the scene edit mode.  We will be using the view shown in Figure 2 in this lesson.

Figure 2. The scene edit mode.

Exposing the scene edit mode screen

The view shown in Figure 2 is exposed by performing the following steps:

Returning to the program edit mode

Although we won't need to do it in this lesson, you can switch from the view shown in Figure 2 back to the view shown in Figure 1 by clicking the partially hidden green button with the red characters "DONE" near the center of the right side of Figure 2.

Eight sections to explain

Figure 2 contains eight major sections.  I will provide a general description of each section in this lesson.  I will show larger views of most of the sections and illustrate their use in subsequent lessons.

The menus

A line of typical menu headers is shown across the top of Figure 2.  These menus have generally the same purpose as the menus in most other Windows programs.  We will be using some of the items on those menus in subsequent lessons.  (The menus don't change when you switch between views.)

The button bar

Immediately below the menus in Figure 2, you see a button bar containing three buttons, a trash can, and a clip board.  (The items on the button bar don't change when you switch between views.)  Although you can't read the labels on the faces of the buttons in Figure 2, they are:

The Play button is used to execute the Alice program and play the animation, much as you would press the Play button on a VCR recorder to play a VCR video tape.  The Undo and Redo buttons have generally the same meaning as similar buttons in other Windows programs.

The trash can is used to dispose of things that you no longer need.  The clip board is used for generally the same purpose as clip boards in other Windows programs.  (You can use one of the menu selections to add more clip boards if you need them.)

The object tree

The large white section shown in the upper left of Figure 2 is often referred to as the object tree.

When you create a world, you begin with a background scene (such as the green grass and the blue sky shown in Figure 2) and add various objects to that scene.  As you add each object to the world, an item appears in the object tree that represents that object.  Later on, you can click on an item in the object tree to select that object for a variety of purposes.  (This section of the Alice environment doesn't change as you switch between the two views.)

The details section

The large white area in the bottom left of Figure 2 is often referred to as the details section.  (This section also doesn't change as you switch between views.)  When you select an object in either the object tree or in the visual view of the world (the part showing the green grass), this section provides a variety of different types of detailed information about that object.  This includes information about the properties, the methods, and the functions belonging to the object.  That statement probably doesn't mean much to you at this point, and if so, don't worry about it.  You will learn all about properties, methods, and functions later.

For the most part, the details section is used when writing the program to animate the world.  However, sometimes an object's properties are set when setting the stage.  A property is an attribute of an object such as its color or its opacity (the inverse of transparency).

The gallery

The section with all of the pictures that covers the bottom center and bottom right in Figure 2 is called the gallery.  As you can see, it has a horizontal scroll bar and therefore extends far to the right of what you see in Figure 2.

The gallery is where you go to get objects to populate your world.  For example, if you wanted your world to contain a penguin, you would click on the tan rectangle (sometimes called a thumbnail) containing the picture of the penguin shown in Figure 2.  This would cause a subsection of the gallery named Animals to open up, in which you would find about 25 fully three-dimensional (3D) animals.  The Animals subsection also contains another subsection named Bugs which contains a large number of 3D insects.

 
Classes, not objects
Technically, the gallery doesn't contain objects.  Rather, it contains classes, which are the blueprints from which objects are constructed when needed.

Hundreds and perhaps thousands of objects

I haven't counted them, but the local gallery contains several hundred 3D objects that you can use to populate your world.  And, if that isn't enough, there is a link to an online Gallery at Carnegie Mellon that contains several hundred more objects.  I will show you how to use the local gallery to populate a new world in the next lesson.

 
Three objects initially
Technically, when you first create a new world, it contains the following three objects:
  1. camera
  2. light
  3. ground

The world section

I'm going to skip over the funny looking blue arrows in the center of Figure 2 and go to the section near the top that looks like a freshly mowed lawn.  This is a picture of a world that is to be populated.  In this case, the world contains only the background scenery consisting of a grassy field and a blue sky.  One way to populate the world is to drag objects from the gallery at the bottom and drop them on the world near the top.

The camera controls

You can think of your animated world as consisting of animated objects on a stage that are being photographed by a movie camera or a TV camera.  There are two sets of camera controls.  The blue arrows near the center of Figure 2 are used to control the location and the orientation of the camera relative to the objects in the world.  I will explain how to use these controls later.

The second set of camera controls consists of a text field, a slider, and some buttons on the right in Figure 2 immediately above the green button.  These controls deal with things like the aspect ratio, the camera lens angle, etc.  I will also explain how to use these controls in a subsequent lesson.

The object manipulator buttons

For want of a better name, I will refer to the set of seven buttons in a row near the upper-right corner as object manipulator buttons.  Once you place an object in the world, you can select that object and manipulate it in a variety of ways using the mouse.  For example, you can make it larger or smaller.  You can move it to the right, to the left, toward the viewer, away from the viewer, up, or down.  You can rotate it about any of three different axes.  By selecting one of the object manipulator buttons near the upper right, you select a family of behaviors that will result when you select an object and drag the mouse pointer in its proximity.

Summary

In this lesson, I have provided an overall description of the Alice environment that is used to create and animate worlds.

Two distinctly different views

I explained that there are two distinctly different views of the Alice environment where one view is used to set the stage (often called the scene edit mode) and the other view is used to animate the world (often called the program edit mode).  I told you that I will defer an explanation of the program edit mode until a future lesson.

I showed you how to switch back and forth between the two modes.

The eight section of the stage-setting view

I explained that the scene edit view that is used to set the stage is divided into the following eight major sections:

  1. The menus
  2. The button bar
  3. The object tree
  4. The world's details section
  5. The gallery
  6. The world that is to be populated and animated
  7. The camera controls
  8. The object manipulator buttons

I provided an overall description of the purpose and use of each of the eight sections.  Along the way, I identified those sections that don't change as you switch between the two views.

What's next?

In the next section, I will begin the process of drilling down into more detail and start showing you how to use the eight sections in the above list to set the stage for a simple world.  In future lessons, I will also explain and illustrate the use of features such as camera controls, object manipulator buttons, etc.

Resources

Lab projects

The lab projects for this lesson continue the theme from the previous lesson titled "Getting Started."  That theme is to familiarize you with the Alice development environment.

If you haven't completed the two projects for the previous lesson, you should complete them before embarking on the projects for this lesson.

As before, if you are unable to complete these projects during the scheduled laboratory period for the course, you should complete them as a homework assignment before the next class.

Project 1:  Object manipulator buttons

Create a new world.  Select the template of your choice and click the Open button.  Switch into scene edit mode by clicking the ADD OBJECTS button and drag an object from the Gallery into your world.  Click on the object in the world to make certain that it is selected.

Select the leftmost button in the line of seven buttons in the upper right area of the screen in Figure 2.  Drag the mouse on the object and observe the behavior.  Try to understand that behavior.  Continue this process for each button in the line going from left to right.  (If you allow the mouse pointer to hover over a button, the text above the line of buttons will provide a brief description of the purpose of each button.)

To improve your understanding of the behavior, you may find it useful to read ahead in the lesson titled "Setting the Stage Manually, Part 1" for information on the behavior imparted by each of the seven buttons.

Project 2:  Camera controls

Using the world that you created in Project 1 above, click and drag your mouse pointer on each of the ten arrow heads of the three sets of blue arrows that appear below the world in Figure 2.  Observe and try to understand the resulting behavior.  (If you allow the mouse pointer to hover over a blue arrow head, a tooltip will appear that explains the purpose of each set of blue arrows.)

You may also find it useful to read ahead in the lesson titled "Setting the Stage Manually, Part 1" for information on the behavior imparted by each of the blue arrow heads.


Copyright

Copyright 2007, Richard G. Baldwin.  Faculty and staff of public and private non-profit educational institutions are granted a license to reproduce and to use this material for purposes consistent with the teaching process.  This license does not extend to commercial ventures.  Otherwise, reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

About the author

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java, C#, and XML. In addition to the many platform and/or language independent benefits of Java and C# applications, he believes that a combination of Java, C#, and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers. He has also published articles in JavaPro magazine.

In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP).  His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments.  (TI is still a world leader in DSP.)  In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

-end-