3D WINDOW FOR 2D PROJECT

When we save a project we have made, a file is created at the folder: C:/Croquet/Squeaklets

Verify if our first project (that having "Hello World!"): MyFirst is there.

At this lesson we will create, inside a Croquet space, a 3D window having this project inside. We will see how this can be useful.

Lets go! Begin creating a new morph-project.

Confirm again the existence of MyFirst project opening our old "World" window (click in any place) and clicking "open project from file". Select the folder "Squeaklets" and the file: MyFirst.001.pr. The project will open.

Go back to the previous empty project.

First we will create a new subclass. We can use the definition of BasicSpace and write over. The name of the Class will be: Project2D.

This Class is a subclass of TeapotMorph that has a function: makeProjectLink used to put a project inside a 3D window that can be "installed" inside a space.

We will first override this function creating one with the same name at our Class (like we did with initiatializeDefaultSpace in the previous lesson). The code will be:

makeProjectLink: sp

| win3D teaWorld tm |
tm := TMorphic new initializeOpaque: true extent: 400@400.
teaWorld := TMorphMonitor new initializeWithWorld: 'MyFirst' extent: 400@400.
teaWorld eventsTo: tm.
win3D := TWindow new.
win3D translationX: 8 y: 0  z:-20.
"win3D rotationAroundY: 135.0."
win3D contents: tm.
win3D closeContents.
sp addChild: win3D.
^ win3D.

CODE COMMENTS:

TIP: Some times, in the middle of the construction of a project, is recomended to open our old "World" window (click in any empty area) and do a "Save". You don't need to do a: "save project on file" at these intermediate saves. If the machine crashes - this occurs sometimes for me...- when you reopen Squeak-Croquet it will be at the desktop of the project having the last saved situation.

We need also to override that "constructor method": initiatializeDefaultSpace, because here it will have a new line adding our 3D window. The code will be:

initializeDefaultSpace 

| space  |
"Create a new space"
space := TSpace new.
"Make a light"
self makeLight: space.
"Make a floor"
self makeFloor: space fileName:'lawn.BMP'.
"Add the 3D window having MyFirst project"
self makeProjectLink: space.
 ^space.

CODE COMMENTS:

The script in the Workspace is :

p2D:= Project2D new. 
win:=   SystemWindow new.
lf:= LayoutFrame new.
lf leftFraction:0.
lf rightFraction:1.
lf topFraction:0.
lf bottomFraction:1.
win setLabel: '2D PROJECTS'.
win addMorph: p2D fullFrame:lf.
win openInWorldExtent: 400@400."The 2D window size equal 3D window"
p2D requestInitialSpace.

CODE COMMENTS:

IMPORTANT: Remember that you need to do many "accepts" in the creation of any new application.

Doing the "do it" at the workspace...

WOW! There are a "new kid in the block"!! Lets go near!

We recomend that you change the view to: first person - Ctrl+Shift+a.

When you are near the 3D window put the pointer over it. You will see a 3D ToolBar:

If your pointer is out the 3D window, the 3D ToolBar disappear.

If you "mouseover" any 3D object of the 3D ToolBar it change its color and the others disappear.

So: mouseover and click the "signal of plus" at right. It will change to be a "signal of minus" and: (unbelievable!) the MyFirst project will appear in the 3D window.

Mouseover again the 3D window and click the down arrow in the center of the 3D ToolBar. The camera will move, finding the better position for the 3D window in front of the camera (we are in 1st person view).

TIPS: Clicking the down arrow over the windows you automatically revert to first person until you leave the window again.

The 3D window can be enlarged draging their corners. It can be also dragged in the 3D space. To rotate it click-and-twist the lateral moldure. If you click the "open hand" it will "follow the avatar" until new click.

Talking again about the use of the Dock: It will have 2D representations - a tree - of 3D windows that are not too much useful for you to be always in the 3D space. When you need to use one of this, you drag its image to the space and it will be re-created there. You can close it when you don't need it more using the "X signal" in the "3D ToolBar" .

If all the auxiliary windows are erased and your 2D window is in fullscreen mode (if you have a powerfull machine) all will appear better.

The fabulous thing is: the 2D project could be an interactive application having buttons to click, fields to data-entry, animations etc. All will work like you are at the 2D interface of the project.

And better! You have more! (I am with the spirit of that ads of TVShop, today.) The application can be used by many users (their "avatares") at the same time!

Just imagine! Just imagine!

We could create a page of wiki only to receive sugestions of shared applications.

By example, a simple application like e-mail. Two executives of a company, one in New York and another in Tokio, could write together a letter for a client in Rio, using an application inside a 3D window of a shared space. And to send it, in the moment they finish to write it.

And many other commercial and administrative applications. Not only multiplayer games.


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.