+ All Categories
Home > Documents > Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Date post: 02-Jan-2016
Category:
Upload: ira-butler
View: 220 times
Download: 0 times
Share this document with a friend
Popular Tags:
21
Wonderland in Squeak How to use the wonderful, Alice-based 3-D world in Squeak Mark Guzdial
Transcript
Page 1: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Wonderland in Squeak

How to use the wonderful, Alice-based 3-D world in Squeak

— Mark Guzdial

Page 2: 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.

Page 3: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Wonderland

WonderlandCameraMorph

WonderlandEditor

Somegenericworkspace

Page 4: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Playing with Balloon 3-D

Page 5: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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

Page 6: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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’

Page 7: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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:

Page 8: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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

Page 9: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Working with the Camera

camera move: back distance: 3camera turn: leftcameraWindow showCameraControls

Page 10: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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

Page 11: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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}.

Page 12: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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)

Page 13: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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.

Page 14: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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)”

Page 15: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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 ].

Page 16: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Using Alarms

myAlarm := Alarm do: [bunny turn: left turns: 1] in: 5 inScheduler: scheduler

scheduler getTime

Page 17: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Additional Cameras

(Beware of speed!)w makeCamera.camera1 moveTo: {0. 2. 0}

Page 18: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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

Page 19: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Blending 2-D and 3-D

camera turnBackgroundOff.ground hide.cameraWindow move: right distance:

50.bunny move: right distance: 5

Page 20: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

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).

Page 21: Wonderland in Squeak How to use the wonderful, Alice- based 3-D world in Squeak — Mark Guzdial.

Getting rid of the editor

In workspace: w := Wonderland new. w getEditor hide.

(w getNameSpace at: ‘shark’) torso tail turn: #right


Recommended