THE ALICE'S PARADIGMA

And here we are at the final lesson of our course. We will learn how to transform our "single-player application" to be a "multiplayer application".

You need to understand well the main principle of Cobalt: to go from one space to other (having projects installed) the two spaces need to be equal. You don't go from A to B; you go from A in the computer 1 to a copy of A in the computer 2. So: you need to install in both computers similar copies of the "Cobalt Studio & Navigator" having the system you have developed. This "paradigma" is the reason because we have Alice beeing the default avatar of Cobalt. "Through the Looking-Glass, and What Alice Found There." is a novel written by English author Charles Lutwidge Dodgson under the pseudonym Lewis Carroll. It tells the story of a girl named Alice who goes through a mirror to a similar space.

But, before to do any magic travel, we need to install our application in the 3D space.

To do it, lets go step by step:

1 - Open the "Tool palette" and drag the tool: Browser:

2 - In the first column of the Browser you need to found and click: "CobaltMorph-Worlds". Click "CobaltWorld" in the second column and "initialize" in the last column. The script "initialize" appears in the botton window of the Browser:

Like our project in the Squeaklet folder has the name: readstudents121.001.pr we will add to the "initialize" script the lines:

project1 := self makeMorphic: (MessageSend
   receiver: MorphicWorldHost
   selector: #makeProjectLink:extent:from:
   argument: 'readstudents121')
   extent: 875@626. 
win := TWindow new.
win translationX: 15 y: 0 z: -15.
win  rotationAroundY: 0. 
win scale: 2.
win contents: project1.
win closeContents.
space addChild: win.

In the first command we define that the project to be presented inside a 3D window is readstudents121.

In the second command we create the 3D window: win. We define its position and rotation and its contents: the "project1" defined before.

In the final line we add this 3D window in the space.

The complete "initialize" will be (you don't need to understand all the code):

initialize
       | space sky floor   project1 win |

       "define the space and turn on the lights"
	space := TSpace new.
	space registerGlobal: #mainEntry.
	self makeLight: space.

	"set fog characteristics "
	space color: (VectorColor r: 0.50 g: 0.50 b: 0.50 a: 0.0).
	space fogOn: true.
	space fogDensity: 0.005.
	space fogStart: 413.0.
	space fogEnd: 500.0.

	"define the floor and its texture"
	floor := self makeFloor: space fileName: (FileDirectory fullPathForURI: 'resources/textures/groundplane/', 'startup.bmp').
	floor extentX: 1200 y:0.5 z: 1200.

	"place a skybox around the scene."
	sky := TSkyBox new initializeWithFileName: 'startup-'.
	
	"start the skybox rotating"
	"sky step." 

	space horizon: sky.

	"place a fractal pyramid in the space."
	"self makePyramid: space."

	"place a mirror in the space."
	self makeMirror: space.

	"place a fractal terrain in the space"
	self makeTerrain: space.

	self makeDemos: space.

        project1 := self makeMorphic: (MessageSend
           receiver: MorphicWorldHost
           selector: #makeProjectLink:extent:from:
           argument: 'readstudents121')
           extent: 875@626. 
        win := TWindow new.
        win translationX: 15 y: 0 z: -15.
        win scale: 2.
        win contents: project1.
        win closeContents.
        space addChild: win.

	space objectName: 'Start Space'.
	space spaceDescription: 'Standard Open Cobalt starting Space'.
	space spaceCreator: ''.
	space keyWords: 'start initial space'.

	^space.

You need to do an "accept" to save the new "initialize." And a "big save" of the Cobalt image.

3 - Openning the 3D space you will see the 3D window. Click the "cross" to open it. If you click the arrow, the window will go near the camera.

Lets go to imagine that we have two copies of Cobalt, having our system, in the USER1's and in the USER2's computers . How USER2 goes to the USER1's space ?

1 - USER1 opens his 3D space and clicks "Space" and "Space Info...". Copy the "External Link":

Something like:

<joinme><routerAddress>200.207.167.61:6900</routerAddress><routerId>d2332f136b818009766c8a725a545343</routerId>
<routerName></routerName><vpn>mainEntry</vpn></joinme>

2 - Send this code to USER2.

3 - USER2 clicks "Space" and "Link With Local" and, in the new window, paste the code received and select the "Portal type: Two-Way". Clicking "OK" he will need to enter with his userID and password.

4 - If all is OK, will appear a new 3D window on his 3D space. The avatar, going through this "portal", will be at the USER 1's similar space (through the looking-glass).

In our final video, you will see first the USER1 walking in his space. After this, you will see USER2 walking in HIS space and openning a "portal" to go to USER1's space. USER1 uses (not in the 3D space) the "single-user application" to add a new student. Back to his 3D space he "refreshes" the list of students and can see the new one.

IMPORTANT: Only the owner of an space can act over the applications inside it.

The video shows what happens, in the same moments, for the USER2. Take a look:




PREVIOUS LESSON
TABLE OF CONTENTS HOMEPAGE