View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

M4 - Our Animated Avatar

Here were the goals and requirements for this milestone:



To embody your Guide, create a 3D character that you can programmatically move around the screen and cause to refer to things. Your Guide (referring now to the 3D character) must be able to:

We randomly named our avatar "Barney".

The Avatar:

We used a pre-created model for our avatar instead of creating one from scratch. Other models can be found on the Squeak cds that come with the book. Here is some basic info about our avatar:

The avatar was implemented in a Wonderland in which the background and editor were hidden:

wonderland := Wonderland new.
wonderland getEditor hide.

(wonderland getNamespace at: 'ground') hide.

camera := (wonderland getNamespace at: 'camera').
cameraWindow := (wonderland getNamespace at: 'cameraWindow').
camera turnBackgroundOff.

The avatar is added to the Wonderland like so:

wonderland makeActorFrom: 'PurpleDinosaur.mdl'.
barney _ (wonderland getNamespace at: 'purpleDinosaur').

The animation is just a series of calls to the functions that make the various parts of Barney's body move. Two important methods of the Wonderland are: doInOrder: and doTogether: which take in an array of Animations. Most of the time, we stored animations in blocks and used their values when actually calling doInOrder or doTogether. For example:

rightLegForward _ [barney rightleg turn: #forward turns: 1/3 duration: 1/2.].
rightLegBackwards _ [barney rightleg turn: #backward turns: 1/3 duration: 1/2.].

leftLegForward _ [barney leftleg turn: #forward turns: 1/3 duration: 1/2.].
leftLegBackwards _ [barney leftleg turn: #backward turns: 1/3 duration: 1/2.].

rlMove := [wonderland doInOrder: { rightLegBackwards value. leftLegBackwards value.}.].
llMove := [wonderland doInOrder: { leftLegForward value. rightLegForward value.}.].

rlMoveBack := [barney rightleg turn: #backward turns: 1/6 duration: 1/2.].
llMoveBack := [barney leftleg turn: #forward turns: 1/6 duration: 1/2.].

bothMove := [wonderland doTogether: {rlMove value. llMove value}.].
moveBack := [wonderland doTogether: {rlMoveBack value. llMoveBack value}.].

walk := [wonderland doTogether: {
"You will also want to move the camera window across
the screen so it looks like barney is moving"
wonderland doInOrder: { (bothMove value) loop: 10. moveBack value.}. }.].

Here is another simple example that will make Barney follow the mouse with his head:

barney head doEachFrame: [ barney head pointAt:
(camera transformScreenPointToScenePoint: (Sensor mousePoint) using: barney) duration: #rightNow ].

The 2D Interface:

Our interfaces were made with the help of Bob's UI:

One of the requirements was that the 2D Interface must always follow the avatar around. This was very simple to do, we just added the 2D Interface's window to the camera's morph:

((avatar camera) getMorph) addMorph: (speechV window).

Link to this Page