Island Constructor/Project and implementation

From Croquet Consortium

Jump to: navigation, search

Before the construction of anything, an engineer needs to make a project, a design, a blueprint, specifying the positions of anything: walls, doors, stairs etc.

You will do the same. Please, access this webpage and print our :

grid30x30

You need to place a design of the blocks in the blueprint, defining their positions:


Fig.3-1
Enlarge
Fig.3-1

The position of a block is the position of its "Positional Point" (in red).

The position is defined by 3 numbers, in the usual Cartesian System.

You need to define also the rotation of the block, in the usual degrees, not radians.

IMPORTANT: For the adequate positioning of the avatar, the floor is at Y=-6

When the project (design) is finished, lets go to the implementation. Step by step:

1 - Look again the files inside the .zip file of the Level. Anotate if there are any .st file. This means that there are one or more "inteligent blocks". At our case there are the file: DMUcbb1Door.st. It needs to be inSTalled.

2 - Open the "Coblocks Browser and Constructor" (do not drag the Browser Window). Drag the "Tools" palette. And drag the tool "File List". Find, in the list, the file DMUcbb1Door.st. Click it.

Fig.3-2
Enlarge
Fig.3-2

TIP: You can click the figure to have an amplified version of it.

3 - Will change the Menu. Click in "install"

Fig.3-3
Enlarge
Fig.3-3

4 - Now that the "inteligent block" is installed, we need to do the positioning of all the blocks of our island. Drag the tool: System Browser and try to find, in the first column the name: CobaltMorph-Worlds. Click it. In the second column click: CobaltWorld. In the fourth column click: initialize. In the inferior division of the System Browser appears the script of the island.

Fig.3-4
Enlarge
Fig.3-4

You do not need to understand anything of its logic. You only need to erase the two lines that define the default floor:

floor := self makeFloor: space fileName: 'lawn.bmp'.
floor extentX: 30 y: 0 z: 30.

Drag over and press the space bar to erase.

Now you need to type the lines that will install the blocks. For each block you will have 4 lines. By example, for the installation of the wall having a door (wallDoor12x7x1):


wall1:= (OBJImporter parseFile: (FileDirectory pathFrom: {FileDirectory default pathName. 'DMUcbb1CT'.'wallDoor12x7x1_Scene.obj'} )scale:1) asTMesh.

wall1 translationX: 17 y:-6 z:-9.

wall1 addRotationAroundY: 0.

space addChild: wall1.


We said that there are 4 lines, because a "line" only ends at the final "point".

It appears complicate but you need to understand only a few things:

  • You need to define a "nickname" for each block (here is: wall1) and use it at each line.
  • Replace the values in red: the name of the block (wallDoor12x7x1) and the 3 values for the position of the "Positional Point" and the angle for the rotation around the "Positional Axis" - here is zero.

If you like to understand a little more: the block is in the file wallDoor12x7x1 _Scene.obj that is in the folder downloaded with the Level: DMUcbb1CT. It's being "imported" at the first line. And added to the 3D space at the last line.

5 - For an "inteligent block", the lines are a little different. Here, the name of the "inteligent block is: DMUcbb1Door and we need to add the lines:

door1:= DMUcbb1Door new.

door1 translationX: 19 y:-6 z:-10.

door1 addRotationAroundY: 0.

space addChild: door1.

Look how all the script for our island (the "sugestion for construction") will be:

initialize

| space floor1 floor2 floor3 floor4 wall1 wall2 wall3 wall4 ceiling1 door1 |

space := TSpace new.
space registerGlobal: #mainEntry.
self makeLight: space.

floor1:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'street30x30_Scene.obj'})scale:1) asTMesh.
floor1  translationX: 30  y:-6 z:-30. 
floor1 addRotationAroundY: 180. 
space addChild: floor1. 

floor2:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'street30x30_Scene.obj'})scale:1) asTMesh.
floor2  translationX: 0  y:-6 z:-30. 
floor2 addRotationAroundY: 180. 
space addChild: floor2. 

floor3:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'street30x30_Scene.obj'})scale:1) asTMesh.
floor3  translationX: -30  y:-6 z:30. 
floor3 addRotationAroundY: 0. 
space addChild: floor3.
 
floor4:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'street30x30_Scene.obj'})scale:1) asTMesh.
floor4  translationX: 0  y:-6 z:30. 
floor4 addRotationAroundY: 0. 
space addChild: floor4. 

wall1:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'wallDoor12x7x1_Scene.obj'})scale:1) asTMesh.
wall1  translationX: 17  y:-6 z:-9. 
wall1 addRotationAroundY: 0.     
space addChild: wall1.  

wall2:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'wallWindow12x7x1_Scene.obj'})scale:1) asTMesh.
wall2  translationX: 17  y:-6 z:-22. 
wall2 addRotationAroundY: 0.     
space addChild: wall2. 

wall3:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'wallWindow12x7x1_Scene.obj'})scale:1) asTMesh.
wall3  translationX: 18  y:-6 z:-10. 
wall3 addRotationAroundY: 90.     
space addChild: wall3. 

wall4:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'wall12x7x1_Scene.obj'})scale:1) asTMesh. 
wall4  translationX: 29  y:-6 z:-10. 
wall4 addRotationAroundY: 90.     
space addChild: wall4. 

ceiling1:= (OBJImporter parseFile:  
  (FileDirectory pathFrom:
            {FileDirectory default pathName.  'DMUcbb1CT'.'plate14x033x14_Scene.obj'})scale:1) asTMesh.
ceiling1  translationX: 16  y:1 z:-9. 
ceiling1 addRotationAroundY: 0.     
space addChild: ceiling1. 

door1:= DMUcbb1Door new.
door1  translationX: 19  y:-6 z:-10. 
door1 addRotationAroundY: 0.     
space addChild: door1.

^space.

IMPORTANT: Each "nickname" needs to be included at the second line, like you can see.

After defined the position of all the blocks of your island, right-click over the script area and, in the new window, click: accept.

Fig.3-5
Enlarge
Fig.3-5

If you didn't have any error, your script is Ok and you can close the 2 "tools" and drag the "Cobalt Ball" to see your island in the Browser Window.

If your island is OK, after play with it, close the Browser Window using "Cobalt | Quit" in the Menu. Click in the free area and select "Save" in the new window.

Fig.3-6
Enlarge
Fig.3-6


Now, when you load your "CoBlocks Browser and Constructor", your island will be there (if you open the Browser Window.

You can modify it, including or excluding blocks and doing a new "accept" in the script and a final "Save". Usually, if you did not any change, you can go out of the "CoBlocks Browser and Constructor" without any "Save".



RELATED LINKS: Previous lesson<...>Next Lesson
Table of Content <...> Cobalt Wiki Main Page
Views
Personal tools