
Until now its possible that you didn't have any problem running our exercices using another Croquet image in the same folder C:\Croquet_SDK_1.0_beta (a backup image ?) because all the Classes, models, textures and projects are available at your machine and in the two images. So: it's possible that you forgot some basic important principles we said at the lesson that is a overview of Croquet. It's possible also that you are a user of "Active Worlds" or "ATMO" (free software available at our site) where, when your avatar crosses a "Portal" the "world" linked is downloaded to your machine automaticaly. Croquet DO NOT download an island automaticaly!!! Pehaps in the future it will do this .
An specific island (a HosterX) OF ANOTHER MACHINE has many "components" that you need to have IN YOUR MACHINE.
TIP: Squeak has some tools to do this using only one compressed file. But these resources are not very well documented and not easy to use.
If you are comparing Croquet with a web browser you will be a little disapointed. The access to an island is not so easy like to access a webpage. An "eventual internaut" will need help to do these downloads and installations.
BUT, having all installed, the communication with the machine having the HosterX and the use of the resources of the island are easy like (OK, not so easy and no so like) to accces a web site and use its resources.
Making clear these ideas, we can begin a new phase of our tutorials serie.
Until now we have created static objects (the two cubes) over the Ground, beeing part of the Land. At this lesson we will have an exercice having a cube that is "independent" of the Land. And they can move, by example: rotate continuously. We will use the empty "land0".
The steps to create an independent object is similar. Create a new folder inside C:\Croquet_SDK_1.0_beta\Content having the name: redcube and a subfolder: Textures.
Open the BCG Blender, click Delete to erase the Ground and save all (nothing) in that folder like: redcube.blend
Click in the point (0,0,0) and add a Cube. Change the name of the mesh/object to "redcube"
Create a texture redcube.jpg. Copy to the Textures folder.
Do the "trianglization" (Ctrl+T) in Edit Mode! Return to Object Mode, hide the texture and Export to the correct folder. Close Blender.
Now this is new:
1 - Create a new Class:
TVehicle subclass: #RedCube instanceVariableNames: 'rc' classVariableNames: '' poolDictionaries: '' category: 'DMUcourse'
Note that it has an instanceVariableNames (a global variable).
The methods will be:
initialize super initialize. rc := (TLoad3DSMax new initializeWithFileName: (FileDirectory pathFromURI: 'Content/redcube/redcube.ase') scale:1) frame. rc translationX: 0 y:0 z:0. rc collapse. rc boundsDepth: 2. rc initBounds. rc transparency:0.50. self addChild: rc.
Pay attention that we are defining a "transparency" for our cube.
This other method creates a "time step loop". What is this? It's usual in games this resource: a loop that will run indefinitely at each timeframe. Inside the method we write things that need to occur like rotation or tests to see if something happened. Here we are adding 1 radian at each timeframe to the rotation of the cube.
stepAt: currentTime rc addRotationAroundY: 1.
We will modify the Class HosterWorld (so our island will be not the same we had before!! - only has the same name). Only the method "initialize":
initialize | space land rcOnBoard| Processor activeIsland id: self class islandID. space := TSpace new. space registerGlobal: #mainEntry. self makeLight: space. land := (TLoad3DSMax new initializeWithFileName: (FileDirectory pathFromURI: 'Content/land0/land0.ase') scale: 1) frame. land boundsDepth: 3. land initBounds. land translationX: 0 y:-50 z:0. TQuadTree new initializeWithSpace: space frame: land. "Install the red cube" rcOnBoard := RedCube new. rcOnBoard translationX: 0 y:-140 z:0. "May be you need these 2 lines. Or not. Try." rcOnBoard stepping: true. rcOnBoard startStepping. space addChild: rcOnBoard. ^ space.
NOTE OF THE BETA VERSION: The positioning of meshes (the Y value) is a little confuse. Both of our objects (the land and the cube) was creted at 0,0,0 in Blender and here we need to use very different numbers. Discovered by tentatives...
If you open the Hoster you will see the new red cube:
But if you open the backup image - do you have one ? - before to save the actual image like a backup, and try to open, from the Navigator, a Portal to the Hoster (modified now) you will receive an error:
You need, like all the eventual users of this new Hoster, to download and install the required files. Remember that we have here 2 new Classes: RedCube and the new HosterWorld. And all will be OK:
CURIOUS: It's a little misterious but if you have an old version of a Class (like HosterWorld) the new will work... (Tested in the backup image only).
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.
