'From Squeak3.1alpha of 28 February 2001 [latest update: #4015] on 11 May 2001 at 12:50:14 pm'! "Change Set: WnldCamDist-ar Date: 10 May 2001 Author: Andreas Raab Introduces a virtual slot for the distance of the actor to the (default) camera."! !CategoryViewer methodsFor: 'support' stamp: 'ar 5/10/2001 12:41'! booleanPhraseFromPhrase: phrase | retrieverOp retrieverTile | phrase isBoolean ifTrue: [^ phrase]. ((scriptedPlayer respondsTo: #costume) and:[scriptedPlayer costume isInWorld not]) ifTrue:[^Array new]. ((retrieverTile _ phrase submorphs last) isKindOf: TileMorph) ifFalse: [^ phrase]. retrieverOp _ retrieverTile operatorOrExpression. (#(color number player) includes: phrase resultType) ifTrue: [^ self booleanPhraseForRetrieverOfType: phrase resultType retrieverOp: retrieverOp player: phrase actualObject]. ^ phrase! ! !Vocabulary class methodsFor: 'testing and demo' stamp: 'ar 5/10/2001 12:42'! newWonderlandVocabulary "Answer a Wonderland vocabulary -- highly experimental" | aVocabulary | aVocabulary _ Vocabulary new vocabularyName: #WonderlandVocabulary. aVocabulary documentation: 'A simple vocabulary for scripting Alice objects'. aVocabulary initializeFromTable: #( (color color: () color (basic color) 'The color of the object' unused updating) "--" (getX setX: () number (basic geometry) 'The x position' unused updating) (getY setY: () number (basic geometry) 'The y position' unused updating) (getZ setZ: () number (basic geometry) 'The z position' unused updating) "--" (width setWidth: () number (geometry) 'The width of the object' unused updating) (height setHeight: () number (geometry) 'The height of the object' unused updating) (depth setDepth: () number (geometry) 'The depth of the object' unused updating) "--" (heading setHeading: () number (basic geometry) 'The heading of the object' unused updating) (forwardBy: unused ((distance number)) none (basic motion) 'Moves the object by the specified distance' 'forward by') (turnBy: unused ((angle number)) none (basic motion) 'Turns the object by the specified number of degrees' 'turn by') (graphic setGraphic: () graphic (basic graphics) 'The picture currently being worn' unused updating) (animationIndex setAnimationIndex: () number (graphics) 'The index in the object''s animation chain' unused updating) (emptyScript unused () none (scripts) 'The empty script') (distanceToCamera setDistanceToCamera: () number (geometry) 'The distance of the object from the camera' unused updating) ). ^ aVocabulary "Vocabulary initialize" ! ! !WonderlandActor methodsFor: 'eToy-basic' stamp: 'ar 5/10/2001 14:12'! distanceToCamera ^(self distanceTo: myWonderland getDefaultCamera) * 100! ! !WonderlandActor methodsFor: 'eToy-basic' stamp: 'ar 5/10/2001 14:12'! setDistanceToCamera: distance | pos oldDistance oldPos | oldPos _ self getPosition: myWonderland getDefaultCamera. pos _ B3DVector3 x: oldPos first y: 0 z: oldPos third. oldDistance _ pos length. oldDistance abs < 1.0e-5 ifTrue:[ pos _ 0@0@1. oldDistance _ 1]. pos _ pos * (distance * 0.01 / oldDistance). self moveToRightNow: {pos x. oldPos second. pos z} asSeenBy: myWonderland getDefaultCamera undoable: false.! ! !WonderlandActor methodsFor: 'eToy-fake' stamp: 'ar 5/10/2001 12:42'! getDistanceToCamera "Why does eToy system send #getXyz instead of #xyz???" ^self distanceToCamera! ! "Postscript: Dump old Wonderland vocabulary" Vocabulary removeVocabularyNamed: #WonderlandVocabulary.!