TOverlayButtons


Croquet-Teapot

Comment:

Main comment stating the purpose of this class and relevant relationship to other classes.

Possible useful expressions for doIt or printIt.

Structure:
 instVar1		type -- comment about the purpose of instVar1
 instVar2		type -- comment about the purpose of instVar2

Any further useful comments about the general approach of this implementation.

Hierarchy:

ProtoObject
Object
TObject
TOverlayButtons

Summary:

instance variables:

camLoc ctrl phone popup snapCamera space

methods:

instance class
initialize popups render no messages

Detail:

instance variables:

camLoc
ctrl
phone
popup
snapCamera
space

instance methods:

initialize
camera: camera

	phone target: camera action: #startChat:.
	phone target2: camera action2: #endChat:.
	snapCamera target: camera action: #snapshot:.
	ctrl target: camera action: #openHalo:.

frustumChanged: cam


	| bnds |
	bnds _ cam bounds.
	phone ifNotNil:[ 
		phone translationX: 2.5*bnds width/cam zScreen y: 0.0 * bnds height/cam zScreen z: -6.0.].
	snapCamera ifNotNil:[
		snapCamera translationX: 2.5*bnds width/cam zScreen y: 2.7 * bnds height/cam zScreen z: -6.0.].


	
initialize


	| tframe tframe2 receiver path light ctrlFrame |

	path _ {FileDirectory default pathName. 'Content'. 'Widgets'}.
	space _ TSpace new.
	camLoc _ TGroup new.

	space addChild: camLoc.
	light _ TLight new.
	light translationX: -10 y:0.0 z: 0.0.
	light rotationAroundZ: 110.
	light addRotationAroundY:-10.
	camLoc addChild: light.

	tframe _ TWidget createNewWithUrl:'http://www.reed.com/TeaLand/widgets/phone.tea'
		fileName:(path, { 'phone.ASE'}) scale: 1.0.
	tframe2 _ TWidget createNewWithUrl:'http://www.reed.com/TeaLand/widgets/phone.tea'
		fileName:(path, {  'phone.ASE'}) scale: 1.0.
	receiver _ (tframe2 find:[ :frm | frm objectName = 'receiver' ]) at: 2.
	receiver translationX:-0.125 y:0 z: -0.125.
	receiver rotationAroundY: 30.
	phone _ TButton new initializeSwitchWithFrame: tframe frame2: tframe2.
	phone translationX: -2 y: 0 z: -5.
	phone persist: true.
	phone spin: true.
	phone local: true.
	camLoc addChild: phone.
	phone fullBright: true.

	tframe _ TWidget createNewWithUrl:'http://www.reed.com/TeaLand/widgets/cameraSnap.tea'
		fileName:(path, {  'camera.ASE'}) scale:0.4.
	snapCamera _ TButton new initializeWithFrame: tframe.
"	cameraButton rotationAroundY:180."
	snapCamera persist: true.
	snapCamera translationX: -2 y: 0 z: -5.
	snapCamera fullBright: true.
	snapCamera spin: true.
	camLoc addChild: snapCamera.

	ctrlFrame _ TTorus new.
	ctrlFrame radius: 0.15.
	ctrlFrame innerRadius: 0.075.
	ctrlFrame segments: 10.
	ctrlFrame texture: (TTexture new initializeWithFileName: 'squeaklogo2.bmp').
	ctrl _ TButton new initializeWithFrame: ctrlFrame.
	ctrl persist: true.
	ctrl spin: false.
	ctrl fullBright: true.
	ctrl rotationAroundX: 140.
	ctrl translationX: -2.5 y: 1.8 z: -5.
	camLoc addChild: ctrl.

	camLoc addChild: TCrosshair new.

popups
killPopup

	popup killWindow.
	popup _ nil.
makeBoxButton

	| mesh cube pic bttn |
	mesh _ TGroup new.
	cube _ TCube new.
	cube extentX: 1.0 y:0.5 z:0.8.
	pic _ TTexture
				new initializeWithFileName: 'box.png'
				mipmap: true
				shrinkFit: false.
	cube texture: pic.
	mesh addChild: cube.
	bttn _ TButton new initializeWithFrame: mesh.
	bttn persist: true.
	bttn spin: true.
	^ bttn.
makeCADButton


	| pic mat bttn |
	pic _ TTexture new
				initializeWithFileName: 'gridIcon.png'
				mipmap: true
				shrinkFit: false.
	mat _ TMaterial new.
	mat ambientColor: TButton overColor.
	mat diffuseColor: TButton overColor.
	pic material: mat.
	pic translationX:0 y:0 z:0.1.
	bttn _ TButton new initializeWithFrame: pic.
	bttn persist: true.
	bttn target: self action: #makeCAD:.
	bttn spin: true.
	^ bttn.
makeEditBox


	self killPopup.
makeEditBoxButton


	|  cube pic bttn |
	cube _ TCube new.
	cube extentX: 1.0 y:1.0 z:0.5.
	pic _ TTexture new
				initializeWithFileName: 'editBox.png'
				mipmap: true
				shrinkFit: false.
	cube texture: pic.
"	bttn _ TSpellBox initializeWithFrame: cube class: TEditBox3D.
	bttn target: self action: #makeEditBox.
	bttn persist: true.
	bttn spin: true."

	bttn _ TButton new initializeWithFrame: cube.
	bttn persist: true.
	bttn spin: true.

	^ bttn.
makeExit


	WorldState addDeferredUIMessage: (MessageSend receiver: Croquet world morph selector: #delete arguments: #()).
	self killPopup.
makeExit: ptr


	WorldState addDeferredUIMessage: (MessageSend receiver: Croquet world morph selector: #delete arguments: #()).
	self killPopup.
makeExitButton


	| pic mat bttn |
	pic _ TTexture
				new initializeWithFileName: 'exit.png'
				mipmap: true
				shrinkFit: false.
	mat _ TMaterial new.
	mat ambientColor: TButton overColor.
	mat diffuseColor: TButton overColor.
	pic scale: 0.6.
	pic material: mat.
	pic translationX:0 y:0 z:0.1.
	bttn _ TButton new initializeWithFrame: pic.
	bttn persist: true.
	bttn target: self action: #makeExit:.
	bttn spin: true.
	^ bttn.
makePopup


	| tframe |
	popup ifNotNil:[
		(popup isChild: camLoc) ifTrue:[ self killPopup. popup _ nil. ^self.].
		].

	tframe _ TButtonHolder new.
	tframe addChild: self makeEditBoxButton.
	tframe addChild: self makeBoxButton.
	tframe addChild: self makeXTerminalButton.
	tframe addChild: self makePortalButton.
	tframe addChild: self makePortal3DButton.
	tframe addChild: self makeWireFilterButton.
	tframe addChild: self makeExitButton.
	popup _ TWindow new.
	popup translationX: 0 y: 0.0 z: -6.0.
	popup contents3D: tframe.
	popup radius: 0.1.
	popup fullBright: true.
	camLoc addChild: popup.
	popup grabButton: true.
makePortal

	| p1 win p2 trans ac tp spc |

	ac _ Croquet world activeCamera.
	spc _ ac root.
	tp _ spc teaParty.
	ac transparency: 0.0.
	trans _ ac globalTransform translation + (ac globalTransform orientation localPointToGlobal: (0@0@-8)).
	trans _ ac globalTransform copy translation: trans.

	p2 _ (tp global: TSpaceImposter name) new initializeWithSpace: spc transform: trans.
	p1 _ (tp global: TPortal name) new.

	win _ ac makeWindowInFront.
	win contents: p1.

	p1 linkPortal: p2.
	ac transparency: 1.0.
	self killPopup.
makePortal3D


	| win portal scroller ac tp |
	ac _ Croquet world activeCamera.
	tp _ ac root teaParty.
	portal_ (tp global: TPortal3D name) new initializeWithSpace: ac root.
	scroller _ (tp global: TScrollBox3D name) new initializeWithContents: portal.

	win _ ac makeWindowInFront.
	win contents3D: scroller.

	self killPopup.
makePortal3D: ptr


	| win portal scroller tp root |
	root _ ptr avatar root.
	tp _ root teaParty.
	portal_ (tp global: TPortal3D name) new initializeWithSpace: root.
	scroller _ (tp global: TScrollBox3D name) new initializeWithContents: portal.

	win _ ptr avatar makeWindowInFront.
	win contents3D: scroller.

	self killPopup.
makePortal3DButton


	| mesh winFrame rect pic mat pyramid bttn |
	mesh _ TGroup new.
	winFrame _ (TWindowFrame new).
	winFrame doInside: true.
	mesh addChild: winFrame.
	mat _ TMaterial new.
	mat ambientColor: TButton overColor.
	mat diffuseColor: TButton overColor.
	pic _ TTexture
				new initializeWithFileName: 'box.png'
				mipmap: true
				shrinkFit: false.
	rect _ TRectangle new.
	rect texture: pic.
	rect material: mat.
	rect extent: winFrame extent.
	rect translationX: 0 y: -1.0 z:0.
	rect rotationAroundX: -90.
	mesh addChild: rect.
	rect _ TRectangle new.
	rect texture: pic.
	rect material: mat.
	rect extent: winFrame extent.
	mesh addChild: rect.
	
	pyramid _ TCylinder new.
	pyramid height: 1.
	pyramid baseRadius: 0.5.
	pyramid topRadius: 0.0.
	pyramid translationX: -1.0 y: -1.0 z: 1.0.
	pyramid material: mat.
	mesh addChild: pyramid.
	bttn _ TButton new initializeWithFrame: mesh.
	bttn target: self action: #makePortal3D:.
	bttn persist: true.
	bttn spin: true.
	^ bttn.
makePortal: ptr

	| p1 win p2 trans tp spc ac |
	
	ac _ Croquet world activeCamera.
	spc _ ac avatar root.
	tp _ spc teaParty.
	trans _ ac avatar globalTransform translation + (ac avatar globalTransform orientation localPointToGlobal: (0@0@-8)).
	trans _ ac avatar globalTransform copy translation: trans.

	p2 _ (tp global: TSpaceImposter name) new initializeWithSpace: spc transform: trans.
	p1 _ (tp global: TPortal name) new.

	win _ ac avatar makeWindowInFront.
	win contents: p1.

	p1 linkPortal: p2.
	self killPopup.
makePortalButton


	| mesh winFrame pic mat bttn |
	mesh _ TGroup new.
	winFrame _ (TWindowFrame new).
	mesh addChild: winFrame.
	pic _ TTexture
				new initializeWithFileName: 'box.png'
				mipmap: true
				shrinkFit: false.
	pic translationX: 0 y: 0 z: 0.25.
	mat _ TMaterial new.
	mat ambientColor: TButton overColor.
	mat diffuseColor: TButton overColor.
	pic material: mat.
	pic extent: winFrame extent.
	winFrame extent: pic extent.
	mesh addChild: pic.
	bttn _ TButton new initializeWithFrame: mesh.
	bttn persist: true.
	bttn spin: true.
	bttn target: self action: #makePortal:.
	^ bttn.
makeWireFilter: ptr

	| win p |

	p _ TWirePortal new.

	win _ Croquet world activeCamera makeWindowInFront.
	win contents: p.

	p linkPortal: win rectBack.
	self killPopup.
makeWireFilterButton


	| mesh winFrame pic mat bttn |
	mesh _ TGroup new.
	winFrame _ (TWindowFrame new).
	mesh addChild: winFrame.
	pic _ (TTexture new initializeWithFileName: 'box.png'
				mipmap: true
				shrinkFit: false) copy.
	pic translationX: 0 y: 0 z: 0.25.
	mat _ TMaterial new.
	mat ambientColor: TButton overColor.
	mat diffuseColor: TButton overColor.
	pic material: mat.
	pic extent: winFrame extent.
	winFrame extent: pic extent.
	mesh addChild: pic.
	bttn _ TButton new initializeWithFrame: mesh.
	bttn persist: true.
	bttn spin: true.
	bttn target: self action: #makeWireFilter:.
	^ bttn.
makeX: ptr display: displayName

	self makeX: ptr display: displayName window: nil.
makeX: ptr display: displayName window: windowName

	| win htp txwin xlightpipe tp |

	"start a monitor using lightpipe in the home tea party of this machine"
	htp _ Croquet world homeTeaParty.
	tp _ ptr avatar root tp.
	xlightpipe _ (htp global: #TXLightPipe) new.
	txwin _ (tp global: TXWindow name) new initializeOpaque: true extent: 512@512.
	xlightpipe monitorXDisplay: displayName window: windowName eventsTo: txwin.

	win _ ptr avatar makeWindowInFront.
	win contents:txwin.
makeXDisplay: displayName

	self makeXDisplay: displayName window: nil.
makeXDisplay: displayName window: windowName

	| win htp txwin xlightpipe ac tp |

	"start a monitor using lightpipe in the home tea party of this machine"
	htp _ Croquet world homeTeaParty.
	ac _ Croquet world activeCamera.
	tp _ ac root tp.
	xlightpipe _ (htp global: #TXLightPipe) new.
	txwin _ (tp global: TXWindow name) new initializeOpaque: true extent: 512@512.
	xlightpipe monitorXDisplay: displayName window: windowName eventsTo: txwin.

	win _ ac makeWindowInFront.
	win contents:txwin.
makeXTerminal

	"here we need to make an X terminal that can be opened"
	"since this user is the one who must connect it up, we can use a regular Morph
	to capture the display id, eventually.  For now, just assume a display ID of :1"
	self makeXDisplay: ':1'.
	self killPopup.
makeXTerminal: ptr

	"here we need to make an X terminal that can be opened"
	"since this user is the one who must connect it up, we can use a regular Morph
	to capture the display id, eventually.  For now, just assume a display ID of :1"
	self makeX: ptr display: ':1'.
	self killPopup.
makeXTerminalButton


	| pic bttn mesh cube |
	mesh _ TGroup new.
	cube _ TCube new.
	cube extentX: 1.0 y:1.0 z:0.5.
	pic _ TTexture
				new initializeWithFileName: 'xwin.png'
				mipmap: true
				shrinkFit: false.
	cube texture: pic.
	mesh addChild: cube.
	bttn _ TButton new initializeWithFrame: mesh.
	bttn persist: true.
	bttn target: self action: #makeXTerminal:.
	bttn spin: true.
	^ bttn.

render
renderOverlay: ogl


	| ac currentFrame currentDistance |
	ac _ ogl camera.
	camLoc localTransform: ac globalTransform.
" Save the current frame and current distance if we don't find one of the buttons."
	currentFrame _ ac pointer selectedFrame.
	currentDistance _ ac pointer selectedDistance.
	ac pointer selectedDistance: Float infinity.
	space renderSpace: ogl.
"If this is still the same frame as before, restore the distance value."
	ac pointer selectedFrame = currentFrame ifTrue:[
		ac pointer selectedDistance: currentDistance].

class methods:

^top


- made by Dandelion -