'From Squeak3.1alpha of 28 February 2001 [latest update: #4009] on 11 May 2001 at 12:08:55 am'! "Change Set: WnldCamTweaks Date: 11 May 2001 Author: Andreas Raab A magic little tweak that allows us to use the stop/go buttons from a wonderland for disabling this camera's update. Extremely useful if one wants to write a larger script."! !Wonderland methodsFor: 'creating' stamp: 'ar 5/10/2001 22:53'! makeActorFrom3DS: filename "Creates a new actor using the specification from the given file" | parent name baseActor newActor actorClass scene globals hierarchy meshSize materials material textureName cameras newCamera | myUndoStack closeStack. scene _ ThreeDSParser parseFileNamed: filename. scene ifNil:[^nil]. globals _ scene at: #globals. materials _ globals at: #materials ifAbsent:[Dictionary new]. "The remaining objects are the actual named meshes," scene removeKey: #globals. hierarchy _ self createHierarchyFrom3DS: globals. baseActor _ self makeBaseActorFrom: filename. "Now create the actors" scene associationsDo:[:assoc| name _ assoc key. actorClass _ WonderlandActor newUniqueClassInstVars: '' classInstVars: ''. newActor _ actorClass createFor: self. actorClassList addLast: actorClass. newActor setName: (self fixNameFrom: name). "newActor setTexture: texture." newActor setMesh: (B3DSTriangleMesh from3DS: assoc value). material _ materials at: (assoc value at: #triList) last ifAbsent:[nil]. (material isKindOf: Association) ifTrue:[ "Note: In this case the name of the texture is the key" textureName _ material key. material _ material value]. newActor setMaterial: material. "newActor setComposite: matrix." assoc value: newActor. ]. "Create hierarchy" scene associationsDo:[:assoc| name _ assoc key. newActor _ assoc value. newActor setName: (self uniqueNameFrom: name). parent _ hierarchy at: name ifAbsent:[nil]. parent == nil ifFalse:[parent _ scene at: parent ifAbsent:[nil]]. parent == nil ifTrue:[parent _ baseActor]. newActor reparentTo: parent. newActor becomePart. ]. "Create the cameras" cameras _ globals at: #cameras. cameras associationsDo:[:assoc| name _ assoc key. newCamera _ WonderlandCamera createFor: self. newCamera getMorph openInWorld. newCamera setName: (self fixNameFrom: name). newCamera copySettingsFrom: assoc value. newCamera reparentTo: baseActor. newCamera becomePart. ]. meshSize _ baseActor getBoundingBox extent length. meshSize > 100.0 ifTrue:[ (self inform:'This actor is huge!! You should rescale it to a reasonable size.')]. meshSize < 0.01 ifTrue:[ self inform:'This actor is tiny!! You should rescale it to a reasonable size.']. myUndoStack openStack. "Ensure that the new actor's name is unique" myNamespace at: baseActor getName put: baseActor. scriptEditor updateActorBrowser. "Add an undo item to undo the creation of this object" myUndoStack push: (UndoAction new: [ baseActor removeFromScene. myNamespace removeKey: baseActor getName ifAbsent: []. scriptEditor updateActorBrowser. ] ). ^ baseActor. ! ! !Wonderland methodsFor: 'creating' stamp: 'ar 5/10/2001 22:53'! makeCameraNamed: aString "Add a new camera to the Wonderland" | newClass newCamera name windowName | newClass _ WonderlandCamera newUniqueClassInstVars: '' classInstVars: ''. newCamera _ newClass createFor: self. newCamera getMorph openInWorld. actorClassList addLast: newClass. name _ self uniqueNameFrom: aString. newCamera setName: name. myNamespace at: name put: newCamera. windowName _ self uniqueNameFrom: aString,'Window'. myNamespace at: windowName put: (newCamera getMorph). cameraList addLast: newCamera. scriptEditor updateActorBrowser. "Add an undo action to remove this camera" myUndoStack push: (UndoAction new: [ cameraList remove: newCamera. newCamera removeFromScene. myNamespace removeKey: name ifAbsent: []. myNamespace removeKey: windowName. newCamera release. scriptEditor updateActorBrowser ]). ^ newCamera. ! ! !WonderlandCamera methodsFor: 'initialize-release' stamp: 'ar 5/10/2001 22:54'! initializeFor: aWonderland "Initializes the camera." super initializeFor: aWonderland. "Set the camera's mesh and geometry" self setMesh: (WonderlandConstants at: 'cameraMesh'). self setTexturePointer: (WonderlandConstants at: 'cameraTexture'). "Set the camera initial position" composite translation: (B3DVector3 x: -1.5 y: 0.5 z: 2.6). self turnTo: #(180 -30 180) duration: #rightNow. "Initialize the camera viewing parameters" perspective _ B3DCameraPerspective new. self setFieldOfView: 40.0. self setAspectRatio: 1.0. self setNearClippingPlane: 0.1. self setFarClippingPlane: 10000.0. viewMatrix _ B3DMatrix4x4 new. "Create a WonderlandCameraMorph for the camera to render into" myMorph _ WonderlandCameraMorph new. myMorph initializeWithCamera: self. "Initially draw the scene background" drawSceneBackground _ true. ! ! !WonderlandCameraMorph methodsFor: 'stepping' stamp: 'ar 5/10/2001 22:51'! step "*** hack ***" pickedPoint _ nil. "*** hack ***" myWonderland getEditor isInWorld ifTrue:[self changed] ifFalse:[(self hasProperty: #keepStepping) ifTrue:[ self changed. myWonderland getScheduler tick]]! ! !WonderlandStillCamera methodsFor: 'initialize-release' stamp: 'ar 5/10/2001 22:54'! initializeFor: aWonderland "Initializes the camera." super initializeFor: aWonderland. "Set the camera's mesh and geometry" self setMesh: nil. self setTexturePointer: nil. "Delete the WonderlandCameraMorph our superclass created" myMorph delete. "Create a WonderlandStillCameraMorph for the camera to render into" myMorph _ WonderlandStillCameraMorph new. myMorph initializeWithCamera: self. "Initially we aren't focusing on any particular object" focusObject _ nil. "Initially draw the scene background" drawSceneBackground _ true. ! !