LOCAL PORTALS

We will repeat this many times: it's very important that you understand very well the general concept of Squeak-Croquet or you will think that Croquet is another 3D game engine or something totally useless for commercial or administractive applications.

Squeak-Croquet defines a new paradigma for the visual interface of workstations (Windows, Mac, Linux, UNIX etc.). And this "new thing" can coexist in paralel with the existent traditional interface.

Because it's important, go to take a look again to our sugestion for a possible "main page" for Squeak-Croquet applications (to appear inside a normal window of your system) :

Like we are creating a new 2D window at each lesson you can think that there will be many of them. No! At our sugestion, by example, we have only three. One for each type of application.

Let's go ahead with this idea:

Inside the 2D window "Private", for the group of applications off-line , we have many 3D windows thar are: Local Portals. We will learn how to create a Local Portal at this lesson.

We can have Remote Portals at the "Solo area". We are not talking about Remote Portals now but some concepts are the same.

A Portal is a link to another space. The avatar can go, walking, through a Portal, having access to a new space.

At this new space we have many 3D windows that are 3D-windows-with-2D-Squeak-projects (we learned how to create this kind of thing in previous lesson) that can be used.

But we can have also some 3D/Windows that are Portals to go to another level. And so on.

OBSERVATION: Something that can be very confuse for a Squeak-Croquet newbie is that, in the "normal world", we have IDEs (Interface Development Environment) like Delphi or Visual .NET for creation of applications that will be launched at the GUIs (Graphic User Interface) like the Windows interface or Gnome interface. For Squeak-Croquet IDE and GUI are the same. You need to show or hide all the tools for development at different times.

Your first impression about the Croquet architecture can be:


This kind of thing is very confuse. 
A 2D solution is better. It exist since the 80's and it's working well.
I am not a boy to play with this little dolls. 
I love my icons...And my wallpaper...

I am an old programer, an old application's developer. I remember when the Cobol language appeared in the 60's and we said that it would be totaly insane to use it , a waste of performance, machine cicles. We were in love with our Assembler...

When IBM+Microsoft, partners at that time, launched Windows we thought that, that thing would be used only by idiots, a waste of time, productivity. We were in love with or "comand line" execution of applications.

The time is a good teacher and, beeing older and more experient, I changed my mind, and begun trying to be a little more "over to the new".

I wrote one of the first books in the world about Java, in late 1995.Was a best-seller but many programers said that an interpretered language would be a disaster. Microsoft tried to ridicularize it, etc. etc. They were in love with C++...

Another day I read, at the Croquet wiki, an emotional agression against this good idea, that tries to create an easy and intuitive interface for multiuser application (the future is communication, little boys!) and extent this standard, this patern, for the other types of applications. Some people have long route ahead...

I am not saying that Squeak-Croquet will be a guaranted success (I hope it will). But we need to give to it a chance.

OK. OK. It's time to go back to our lesson and our Portals...

Like ever, we will create a new Class: SpaceWithPortal that will have 2 of that "make-functions": makeLegoicM (our yellow boy is back) and: makePortalToSp2. Take a look to the code of this one:

makePortalToSp2: sp

| win win2 sp2 p1 p2 |

"Creating a portal to  the main  space"  
p1 := TPortal new.

"Creating a new space"
sp2 := TSpace new.
self makeLight: sp2.
sp2 color:(Color r: 1  g: 1  b: 1 )."Defining the color of atmosphere"	 
self makeFloor: sp2 fileName:'StoneFloor.BMP'.

"Creating a 3D window to be in the main space"	
win := TWindow new.
win translationX: -5 y: 0  z: -8 .
win contents: p1."This window will contain  the portal"
sp addChild: win."The space sp will be defined at initializeDefaultSpace"

"Creating a twin-portal"
p2 := TPortal new.

"Creating a twin-3D window to be in the space sp2"
win2 := TWindow new.
win2 translationX: 0  y:0 z: 3 . "don't need to be the same position than its twin"
win2 rotationAroundY: 180.
win2 contents: p2."This window will contain  the Portal2"
sp2 addChild: win2.

"The more important! A virtual mariage of the twins. Oops!"
p1 linkPortal: p2.

CODE COMMENTS

The function to make the "default legoic" - our boy - is similar we have seeing in the previous lesson:

makeLegoicM: sp
  
| tframe |

tframe := (TLoad3DSMax new initializeWithFileName: 
	   (FileDirectory pathFrom:
             {FileDirectory default pathName. 'Content'.
              'LegoicM'. 'avatarM.ASE'}) 
	   scale: 0.1 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe translationX: 0 y: -3 z: 0.
tframe rotationAroundY: 180. 
tframe boundsDepth: 3.
tframe initBounds.
sp  addChild: tframe.

CODE COMMENTS

And here, the usual code for:

 
initializeDefaultSpace 

| space  |
"Create a new space"
space := TSpace new.
"Make a light"
self makeLight: space.
"Make a floor"
self makeFloor: space fileName:'lawn.BMP'.
 
self makeLegoicM: space. 
self makePortalToSp2: space.
 
^space.

CODE COMMENTS

And the "script for Workspace":

sP:= SpaceWithPortal new. 
win2D:=   SystemWindow new.
lf:= LayoutFrame new.
lf leftFraction:0.
lf rightFraction:1.
lf topFraction:0.
lf bottomFraction:1.
win2D setLabel: 'LOCAL PORTAL'.
win2D addMorph: sP fullFrame:lf.
win2D openInWorldExtent: 300@150. 
sP requestInitialSpace.

CODE COMMENTS

After all the hard work of "development time"... and many "accepts"... the final "do it"... and you will have something similar to our "photo-album" of a nice trip:

Mr. Rabbit looking the "legoic" and the Portal far off

The two friends talking near the Portal

Look to the nice "white sky" and the floor of black stones.

Mr. Rabbit in the new space looking to the other space he comes from

Going back home.

TIP: If a portal is not visible from a particular position and orientation, none of the objects inside the portal are rendered. To have a better performance avoid to put portals in places very visibles any time. By example: don't put 3 portals side by side. If the avatar is in front of then, the viewed objects inside the 3 worlds will be rendered and this can be useless and to spend too much of your resources.


PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE

DISCLAIMER: This material can be translated for any language, and reproduced total or partially by anybody using any type of media. But, please, don't put your name like author. And let me know if it was useful (americo@dmu.com).The use of any code, 3D model or technique published is free and doesn't need to have any reference about this source.The author is not responsible for any damage that the material can cause to your professional or sexual life.