Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Squeak Wonderland: Creating 3D Animation Projects with Squeak and Alice, Papers of Computer Science

This essay provides a step-by-step guide for programmers on how to use the squeak wonderland and alice actors in their own projects. It covers creating a wonderland object, manipulating actors, and implementing animations using squeak code instead of wonderland's script. The focus is on encapsulating wonderland animations into the programmer's animations.

Typology: Papers

Pre 2010

Uploaded on 08/04/2009

koofers-user-fnb-1
koofers-user-fnb-1 🇺🇸

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Team LXG: Squeak Wonderland Tutorial Essay
Members: Suiyang Li (gtg623e)
Hang Yin (gte261z)
Ayite Ayite (gtg901f)
Han Lu (gtg900f)
Creating your own 3-D Squeak Project using the Squeak Wonderland.
Wonderland is a class in squeak that is created for 3-D animations in squeak. Squeak
Alice provides numerous actors, with each one of them capable of doing a set of
animations. To manipulate the actors, Wonderland provides its own editor, whose script
is different from the squeak syntax. However, the focus of this essay is to be of assistance
to programmers who intend to make use of the Squeak Wonderland and the Alice actors
in their own projects. In other words, this essay is about encapsulating the Wonderland
animations into the programmer’s animations, using Squeak code rather than
Wonderland’s script.
First of all, we will start with creating a Wonderland Object. To create a Wonderland,
the following code should be typed into the workspace: “ w _ Wonderland new.”.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Squeak Wonderland: Creating 3D Animation Projects with Squeak and Alice and more Papers Computer Science in PDF only on Docsity!

Team LXG: Squeak Wonderland Tutorial Essay

Members: Suiyang Li (gtg623e)

Hang Yin (gte261z)

Ayite Ayite (gtg901f)

Han Lu (gtg900f)

Creating your own 3-D Squeak Project using the Squeak Wonderland.

Wonderland is a class in squeak that is created for 3-D animations in squeak. Squeak Alice provides numerous actors, with each one of them capable of doing a set of animations. To manipulate the actors, Wonderland provides its own editor, whose script is different from the squeak syntax. However, the focus of this essay is to be of assistance to programmers who intend to make use of the Squeak Wonderland and the Alice actors in their own projects. In other words, this essay is about encapsulating the Wonderland animations into the programmer’s animations, using Squeak code rather than Wonderland’s script. First of all, we will start with creating a Wonderland Object. To create a Wonderland, the following code should be typed into the workspace: “ w _ Wonderland new.”.

When this code is executed, a Squeak Wonderland should appear, together with its editor for the 3-D actors.

execute it , an actor is created. Note that the code that can be executed in the workspace can also be written into methods of a certain class. For example, the author wrote a class called Avator3D, which uses the actor in a Wonderland object and makes it do a set of actions. One of the method is initializing the Avator3D object : initialize " initializing the instances that the object shall contain, all that the avatar needs" | t1 t2 t3 | timer isNil ifTrue: [timer _ 15]. w _ Wonderland new. (w getScene getAllChildren detect: [:t4 | t4 getName = 'camera']) turnBackgroundOff. (w getScene getAllChildren detect: [:t4 | t4 getName = 'ground']) hide.

w getEditor hide. w getLights first hide. w makeActorFrom: 'actor\AliceLiddell.mdl'. alice _ w getScene getAllChildren detect: [:t4 | t4 getName = 'aliceLiddell']. cam _ w getScene getAllChildren detect: [:t4 | t4 getName = 'camera']. ground _ w getScene getAllChildren detect: [:t4 | t4 getName = 'ground']. camWin _ w getCameraList first getMorph. cam pointAt: alice. idleState _ 0. pauseRequested _ 0. resumeRequested _ 0. alarm _ Alarm new. alice respondWith: [:t5 | self createMenu] to: 'rightMouseUp'. self aliceHandleMouse. "t2 _ Guide new. gui _ t2 mainGui." alarm setTask: self alarmAction. t1 _ Time new. scheduler _ w getScheduler. demoString := ''. demoMorph := MenuMorph new. The methods starts by creating a Wonderland instance—“ w _ Wonderland new.”. Then both background and editor of the Wonderland is set to be invisible, so that only the actor can be seen by the user. The code to achieve this is “(w getScene getAllChildren detect: [:t4 | t4 getName = 'camera']) turnBackgroundOff. (w getScene getAllChildren detect: [:t4 | t4 getName = 'ground']) hide. w getEditor hide.” Note that the list of actors of the Wonderland can be retrieved using “ w getScence getAllChildren” The actors are then differentiated by checking their names: “alice _ w getScene getAllChildren detect: [:t4 | t4 getName = 'aliceLiddell'].” This way, Avator3D

#down, #left and #right. If we just use the non-symbol variables in our actual squeak code, Squeak won’t recognize them. However, there is a good way to figure out what they “ really are” is to high-light the corresponding lines in the Wonderland editor and use ‘Alt-p’ to see their actual values. For example, typing in “up” in the Wonderland editor and use ‘Alt-p’, the editor will show “#up” on the same line. A very good example of creating animations in squeak using Wonderland’s actor will be the following method: aliceKicking " this method will make the avatar do a complicated series of actions with her legs and arms, very artistic" | t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 | t9 _ alice larm turn: #up. t10 _ alice rarm turn: #up. t11 _ alice larm turn: #left.

t12 _ alice rarm turn: #right. t13 _ alice larm turn: #right. t14 _ alice rarm turn: #left. t15 _ alice larm turn: #down. t16 _ alice rarm turn: #down. t8 _ alice dress rthigh turn: #up. t1 _ alice dress rthigh rleg turn: #up. t5 _ alice dress rthigh turn: #down. t2 _ alice dress rthigh rleg turn: #down. t6 _ alice dress lthigh turn: #up. t7 _ alice dress lthigh turn: #down. t3 _ alice dress lthigh lleg turn: #up. t4 _ alice dress lthigh lleg turn: #down. kick _ w doInOrder: {t9. t10. t11. t12. t13. t14. t15. t16. t2. t8. t1. t5. t4. t6. t3. t7}. kick loop: 1. Transcript show: 'kicking'; cr This method will cause the actor to kick her legs one after the other.

Now we have all our animations as instance variables. We can manipulate them. Different animations may need different start time. They may also occur in some particular sequences. We can use the “Alarm” class to give each animation an specific start time. If we want them to occur in sequences, we can check their states. The following method does both: alarmAction "This will notify action to the whole class. It calls itself recursively. The actor will be doing different actions after a specified ceratin amount of time" (((kick isNil or: [kick isDone]) and: [spin isNil or: [spin isDone]]) and: [hop isNil or: [hop isDone]]) ifTrue: [pauseRequested = 0 ifTrue: [idleState = 0 ifTrue: [self aliceHopping. idleState _ 1]. (idleState = 1 and: [hop isDone]) ifTrue: [self aliceKicking. idleState _ 2]. (idleState = 2 and: [kick isDone]) ifTrue: [self aliceSpinning. idleState _ 3]. (idleState = 3 and: [spin isDone]) ifTrue: [self aliceHopping. idleState _ 1]. scheduler _ w getScheduler. Alarm “calls itself” do: [self alarmAction] in: timer inScheduler: scheduler] ifFalse: [(spin isNil = false and: [spin isDone] and: [hop isNil = false

and: [false = hop isDone]] and: [kick isNil = false and: [false = kick isDone]]) ifTrue: [w getScheduler pause. pauseRequested _ 0]]] There are 3 animations in this method. They are “kick”, “spin”, and “hop”. Each animations will not start until the previous one is done. The code “(((kick isNil or: [kick isDone]) and: [spin isNil or: [spin isDone]]) and: [hop isNil or: [hop isDone]])” checks if all of the animations are done or nil. If it is, the method initiates new animations. After that, it calls itself recursively. Note that every time this function is called, it checks if any animations are left. If there are none, new animations will be started. The Alarm is called every time the timer has passed, despite the states of the animations. Now, with the ability to control our animations, we can create complete 3-D animation projects that we desire using the Squeak Wonderland. The purpose of this essay is an introductory on how to use the Squeak Wonderland and Alice in our own Squeak projects. The examples in here are brief. And their codes are far from optimized. The reader can find complete information on the topic by digging into related squeak classes. They include “Wonderland”, “AbstractAnimation” and its subclasses, Alarm, and different Wonderland actor classes.