Wonderland in Squeak
How to use the wonderful, Alice-based 3-D world in Squeak
— Mark Guzdial
What’s Wonderland?
An implementation of Alice (http://www.alice.org) for Squeak Alice is a project of Randy Pausch Randy’s PhD student, Jeff Pierce, did
Wonderland as an intern at Disney
At CMU, Alice is used to teach film classes, to develop animations with interdisciplinary groups, etc.
Wonderland
WonderlandCameraMorph
WonderlandEditor
Somegenericworkspace
Playing with Balloon 3-D
Starting With Wonderland
Wonderland new (In Squeak 3.1/3.2, from FileList, open a
model .mdl file)
Opens a WonderlandCameraMorph and Wonderland Editor Within editor: w is the current Wonderland camera is the current camera cameraWindow is the camera’s window
Filling a Wonderland
Wonderlands understand 3D Design Studio and VRML w makeActorFromVRML: ‘blah.vrml’ w makeActorFrom3DS: ‘blah.3ds’
But quality tends to be low. Best: w makeActorFrom: ‘blah.mdl’
Dealing with Wonderland Objects
Grab mdl files from: ftp://st.cs.uiuc.edu/pub/Smalltalk/Squeak/alice/Objects.zip
When you load the object, you have access to the overall objects and its hierarchy Messages are defined for you to make it easy
to walk the hierarchy
Basic commands: move:, turn:, moveTo:
All Transitions Animate
When you command something to happen in Wonderland, it does over time (unless you say otherwise). bunny head setColor: green bunny turn: right bunny turn: right turns: 2 bunny turn: right turns: 1/2 duration:
rightNow bunny head turn: right
Working with the Camera
camera move: back distance: 3camera turn: leftcameraWindow showCameraControls
Getting rid of things
Every Wonderland Actor understands destroy
They also understand hide and showBut don’t worry about it—infinite undo in
the WonderlandEditor
Animation Objects
Every action returns an Animation object. That’s why infinite undo is possible, and how actions can be easily chained
fd := snowman move: forward.rt := snowman turn: right.w doTogether: {fd. rt}.“w doInOrder: {fd. rt}.
Constructing New Objects
Can use Pooh (demo)Can construct from pieces
makeActor makeActorNamed: makePlaneNamed:
bunny head becomeFirstClass “Now changes don’t propagate from parent”
bunny head becomeChildOf: ground bunny move: backward bunny color: (Color red)
More basic commands
bunny resize: 2bunny roll: right. bunny standUp.moveTo: and turnTo: take a triplet {Left. Up.
Forward} in the parent’s reference frame bunny moveTo: {0. 2. 0}. bunny turn: left. bunny moveTo: camera. bunny alignWith: camera camera pointAt: bunny.
Manipulating the Light
light place: onTopOf object: bunny.light color: (Color red). “or gray or
white”“Can also set the background, e.g.
ground color: (Color gray)”
Controlling time
bunny move: forward distance: 5 speed: 1 bunny head pointAt: camera duration:
eachFrame. “bunny turn: right” bunny head doEachFrame: [ bunny head pointAt:
(camera transformScreenPointToScenePoint: (Sensor mousePoint) using: bunny) duration: rightNow ].
Using Alarms
myAlarm := Alarm do: [bunny turn: left turns: 1] in: 5 inScheduler: scheduler
scheduler getTime
Additional Cameras
(Beware of speed!)w makeCamera.camera1 moveTo: {0. 2. 0}
Responding to Events
bunny respondWith: [:event | bunny head turn: right ] to: rightMouseClick. “bunny stop”
Also understands leftMouseDown, leftMouseUp, (and right equivalents) and keyPress
WonderlandEvent is the input type
Blending 2-D and 3-D
camera turnBackgroundOff.ground hide.cameraWindow move: right distance:
50.bunny move: right distance: 5
Textures
Set textures, including active ones: bunny head setTextureFromUser
An ActiveTexture (try BouncingAtomsMorph): camera getMorph enableDragNDrop. bunny body hasActiveTexture. "printIt to Check" bunny body setProperty: #activeTexture toValue:
true. "enable it" bunny body setTexturePointer: (RectangleMorph
new openInWorld).
Getting rid of the editor
In workspace: w := Wonderland new. w getEditor hide.
(w getNameSpace at: ‘shark’) torso tail turn: #right