Alice what is a method




















The internal joints of an object are part of a skeletal system. For this reason, a function is called to access an individual joint within the skeletal system. These functions return a link to the joint similar to a link that holds the address of a web page on the web. Functions that link to an internal joint of an object. It should be noted that these functions are dependent upon the design in the 3D Model for which the object is constructed.

For example, the X-ray view of the alien and hare shows that each has the same core set of biped joints but the hare also has a set of joints in its ears that are specific to the Hare class not available to other bipeds. X-ray view of alien and hare internal joints. These commonalities and differences are reflected in the functional methods that get access to an internal joint.

Common functional methods for biped joints. However, the hare has additional joints in its ears and tail. Functions to access these additional joints are provided immediately above those defined for bipeds, as shown. In Alice the three dimension width, height, and depth properties are of special importance and have their own getter functions. These getter functions for the alien are shown in the figure. The table summarizes these functions. Functions that return dimension property values.

Functions that return dimension value. Return type. Some functions do not neatly fit into the descriptive categories of the preceding paragraphs. Other functional methods. Returns true if this object is facing the other a 3D Model object or else returns false.

Returns the distance from the center point of this object to the center point of the other a 3D Model object. Returns the point of view of this object. Functions that ask the user to use the keyboard or mouse to enter a value of a specific type are provided for all objects in an Alice scene. The value entered by the user is returned by the function, to be stored in a variable or used as an argument in a call to another procedure or function.

Functions for User Input are shown. Functions for User Input. When a user input function is called, at runtime, a dialog box is displayed containing a prompt to ask the user to enter a value of a specific type. Of course, Alice does not automatically know what prompt to use in the dialog box. The programmer supplies a prompt that will be displayed.

The prompt is the argument to the function within an instruction statement. An important part of calling a function to get user input is that the value the user enters is expected to be of a specific type. For example, the value the user enters when the getIntegerFromUser function is called must be a whole number, not a number containing a decimal or a fraction. Likewise, a variable or a parameter that receives the returned value must be a compatible type with the type of value being returned by the function.

For example, if the user enters a String of alphabetic characters, the String cannot be stored in an Integer variable. For this reason, Alice will continue to display the user input dialog box until the user enters a value of the right type. To each row of the following table, we have attached an image depicting a sample dialog box containing a prompt appropriate as an argument for calling that function.

User input Table. Displays the dialog box with the TextString argument displayed as the prompt and True and False buttons for user input. Displays the dialog box with the TextString argument displayed as the prompt and a textbox for user input. Displays the dialog box with the TextString argument displayed as the prompt and a keypad with a decimal point for user input.

Displays the dialog box with the TextString argument displayed as the prompt and a keypad for user input. Currently in Alice 3, most setters and getters can be found in the Procedures and Functions tabs of the Methods Panel. For example, setVehiclec is in the Procedures tab, and getWidth is in the Functions tab. Some properties, however, are general purpose in that they are defined for the purpose of rendering an object in the scene.

Getters and setters for these properties are conveniently listed in the Properties tab of the Methods panel. Getters and setters for specialized properties. Setters and Getters for specialized properties. Sets the paint value of this object to the paint argument.

Used to set the transparency of this object by setting the opacity value of this object using a range of values from 0. Returns the paint value of this object. Returns the opacity value in the range of 0. Returns a link to another object in the scene that is serving as the vehicle for this object.

Almost all 3D model classes in the Gallery have a system of internal joints. The joints can be thought of as the pivot points of sub-parts of the object and can be used in the Scene editor to position sub-parts during scene setup. Procedures that can be used to animate joints are shown.

Procedural methods for an object's internal joints. These procedures perform the same actions that were described for the entire object, but the pivot point is at the joint.

For example, a statement can be created to tell the alien to turn its right shoulder joint backward , as shown. As the right shoulder joint turns, the right upper arm, lower arm, and hand also turn. That is, the arm parts are attached to the body through the shoulder joint. For this reason, the arms parts turn when the joint turns. A statement to turn the alien's right shoulder joint. Notice that the procedures in Figure A. In other words, a joint and its attached sub-part s cannot be separated from the body.

The only unique procedure for joints is setPivotVisible , as described in this table. Procedure specific to internal joints. Displays the pivot position and orientation of this joint in the animation if the argument is true, hides the pivot position and orientation of this joint in the animation if the argument is false. Almost all functional methods for an entire object are functions that access return a link to one of the joints belonging to that object.

However, there are only a few functions that can be called on an individual joint, as shown. Functional methods for a joint. The available functional methods have the same name and perform the same actions as the functions of the same name for the entire object. Refer back to Table A. The only function that is unique to joints is the isPivotVisible function, as summarized below.

A unique function for internal joints. Return Type. Returns true if the pivot position and orientation of this joint in the animation is being displayed, or else returns false if the pivot position and orientation of this joint in the animation is not being displayed.

Refer to the table for descriptions of these specialized methods. Properties methods for internal joints. Every Alice project has a scene this that is an instance of the Scene class and contains two other standard objects: the ground or water surface an instance of the Ground class , and the camera an instance of the Camera class , as shown.

Each of these objects has their own procedures, functions, and properties, as defined in their respective classes. The standard components of every Alice project. The Scene class has a few procedures, functions and property methods that are exactly the same as in other classes, as shown in the next three figures.

See previous descriptions of these procedures, functions, and properties earlier in this section. Procedural methods in common with other classes. Functional methods in common with other classes. Properties methods in common with other classes. For this reason, a scene object has need of many special methods that perform unique operations for creating the scene and animating the characters in the story or game. Unique procedures that are used for setting up a scene and managing the animation are shown.

Unique procedural methods defined in Scene. The Alice environment automatically calls the performGeneratedSetUp, performCustomSetup, and initializeEventListeners procedures in order when the user clicks on the Run button. When performGeneratedSetUp is executed, these instructions are used by the Alice system to re-create the scene in the runtime window. The performCustomSetup procedure contains instructions that may have been written to adjust the scene in a way not available in the Scene editor.

The initializeEventListeners procedure contains instructions to start listeners for events such as key presses and mouse clicks while the animation is running. Specific events and listeners are described below in the Scene Listeners section.

Th following table provides further information regarding these unique procedural methods. Procedures for thi s scene. Allows the programmer to make adjustments to the starting scene; adjustments that could not be easily made in the Scene Editor.

Add program statements to this procedure as is done in any method in Alice. However, all statements here will be executed after the Run… button is clicked, but before the runtime window is displayed. When the Run… button is clicked, Alice inspects the scene built in the Scene Editor and generates the appropriate code necessary to display the scene created by the user in the runtime window.

NOTE: the programmer should not attempt to add or modify code in this procedure, as it is always rewritten whenever the Run… button is clicked. This procedure of the Scene class is the preferred location in an Alice project for the implementation of event listeners. When the Run… button is clicked, Alice inspects this procedure and generates the appropriate code necessary to implement the listeners for the project.

See section below on listener procedures. This is where an Alice animation starts, once the runtime window is displayed. Normally this is the method where the programmer creates program statements that control the overall execution of the animation. A possible exception is performCustomSetUp, as described above.

Properties methods for Scene class. The setters and getters of the Scene class are used to adjust the sky color, the lighting, and the amount of fog in a scene as an animation program is running, as summarized in the next table. These methods are useful for changing the appearance of the scene while the animation is being performed not for setting up the scene in the Scene editor.

For example, to change the scene from a daytime to a nighttime setting, the color of the sky could be made darker and the light in the scene could be decreased. Properties setters and getters for Scene class.

Sets the color of the sky in this scene. Sets the color of the primary light source in this scene. Think of it as the color of sunlight in an outdoor scene. Used to set the density of the fog in this scene by setting the density value in the range of values from 0. Sets the color of a secondary light source from above in this scene. Sets the color of a secondary light source from below in this scene. Returns the color of the sky in this scene. Returns the color of the primary light source in this scene; tyou might think of it as the color of sunlight in an outdoor scene.

Returns the value of the density of the fog in this scene by getting the density value with a range of values from 0. Returns the color of a secondary light source from above in this scene. Returns the color of a secondary light source from below in this scene.

Listeners are used for creating interactive programs, especially games. Interactive means that the user is expected to use the keyboard, mouse, or some other input device to control the actions that occur as the program is running. For example, a mouse-click on object listener will listen for a user to mouse-click on an object in the scene. In Alice, to create an interactive program, a Listener object must be added to the scene. A listener object is added to the scene by calling an addListener procedure, where Listener is a targeted event.

For example, addDefaultModeManipulation creates a listener object that targets a mouse-click on any object in the scene and responds by allowing the user to drag that object around the scene while the animation is running. This figure shows a list of addListener procedural methods. The table summarizes details about the addListener methods, in terms of what event is targeted and how the listener responds. Allows the use the mouse to reposition an object in the virtual world as a program is executing.

Ctrl-click turns the object, shift-click raises and lowers the object. Able to differentiate between Letter, Number, and Arrow keys.

The Ground class has only a limited number of procedural, functional, and property methods, all of which behave exactly the same as those defined by other classes. The following three figures show the methods for the Ground class. These methods were summarized previously. Procedural methods for Ground class.

Functional method for Ground class. Specialized property methods for Ground class. The camera has many procedural methods that behave exactly the same as those defined by other classes, as shown in in this figure and summarized previously. Camera's procedural methods in common with other classes. One of the procedural methods shown above in Figure A. Unique Procedural method for Camera class. Animates the reposition and reorientation of the camera from its current position to the vantage point of the entity.

Examples A person. Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess. World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin. Construction of a programs usually requires:. Programming in Alice Chapter 2 Part 2. Classes, Objects, and World-level Methods Alice.

Collect Pre-Lab 4 2. Alice Programming Assignment Storyboards 3. Classes 4. Objects 5. Methods 6. Assign pair programming teams and meet upstairs. Similar presentations. Upload Log in. My presentations Profile Feedback Log out. Log in. Auth with social network: Registration Forgot your password?

Download presentation. Cancel Download. Presentation is loading. Please wait. Copy to clipboard. Presentation on theme: "Class-level Methods Alice.



0コメント

  • 1000 / 1000