
We hope that you understood all the concepts of the "Basic Tutorial for Beginners because they are pre-requirements for this new course, about 3D programming using Squeak-Croquet.
We made, at that course, the sugestion for creation - in the official Squeak-Croquet image - of 3 classes/areas: Private, Solo and Multi. Downloaded, by the internet, we would have "make-functions" and "initializes" for the creation/atualization of spaces and subspaces - re-runing automaticaly the "script-for-Workspace". The creation of a 3D 1st tier for applications would be the main reason of the use of Squeak-Croquet.
Now, at this new course, we will talk about creation of animated and interactive 3D models inside an space. Please, remember: Croquet IS NOT A GAME ENGINE! Don't try to create a Half-Life3 using it. But, like Croquet is an easy "layer" over the OpenGL API - one of the main APIs for game creation - if you like to have fun, you can use Croquet for creation of some funny sceneries for your Private area. You can create houses having doors that open/close, cars that you can drive, helicopters to fly, elevators, weapons to kill "bad guys" etc. etc.
The ideal would be that you have the software 3ds max for the creation of YOUR .ASE files - the files used for 3D models by Croquet. But, like I know that many of we are members of the community "3dsmax-less", DMU (our site/company) will try to put available many .ASE files to be used at this course and in general.
We hope that soon someone will create a free 3D modeler for Croquet...
The first thing we will do, different from what we did in the "Basic Tutorial for Beginners, is: now each "piece" - we will talk better about the concept of "piece" soon - will be defined at a new Class created in the Package Browser. We will now to have many new Classes in our "image". If you don't know how to create new Classes read that course. By example: for the creation of an empty room for a house, we will use basically 5 "pieces": 2 walls, 1 "wall having a door" and 1 "wall having a window" and 1 "ceiling". You can think about "pieces" being like parts of some "construction kits" for kids.
To do the exercices of this course you will need, for each piece, to create an structure of folders inside the Croquet folder. Look in the figure the structure for the piece :BasePlate70x3x70 - the numbers define the 3 dimensions of the piece. A piece can have one or more .ASE and .JPG files.
So: lets go to do a real exercice! Under the path: C:\Croquet\Content - or the equivalent at your system - create the folder: BasePlate70x3x70 and, inside it, the folder Textures. Download these files right-clicking the names:
These files will be used for the creation of a base where, over it, we will create all our exercices.
Open your Croquet and a new Morphic Project. Open the Package Browser and one Workspace - like we did in the previous course.
Create a new Class: BasePlate70x3x70 - Classes names need to be capitalized.
IMPORTANT: This Class will be subclass of TGroup.
Create for this new Class 3 methods - we call them the "3-basic-methods" :
handlesKeyboard: pointer ^ true.
The 2nd method:
handlesPointerDown: pointer ^ true.
The 3th method:
isComponent ^ true.
CODE COMMENTS:
After the "accepts" etc. you will have the "3-basic-methods" in your Class:
I imagine that you remember that each Class needs to have a "constructor method" having the name: initialize, that will run when we create an object of (instantialize) the Class.
The constructor of our Class will be:
initialize
| tframe1 tframe2 tframe3 |
super initialize.
tframe1 := (TLoad3DSMax new initializeWithFileName:
(FileDirectory pathFrom:
{FileDirectory default pathName. 'Content'. 'BasePlate70x3x70'. 'basePlate70x3x70.ase'})
scale: 0.084 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe1 translationX: 0 y: -3 z: 0.
tframe1 collapse.
tframe1 boundsDepth: 3.
tframe1 initBounds.
self addChild: tframe1.
tframe1 objectOwner: self.
tframe2 := (TLoad3DSMax new initializeWithFileName:
(FileDirectory pathFrom:
{FileDirectory default pathName. 'Content'. 'BasePlate70x3x70'. 'axes.ase'})
scale: 0.1 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe2 translationX: 0 y:0 z: 0.
tframe2 collapse.
tframe2 boundsDepth: 3.
tframe2 initBounds.
self addChild: tframe2.
tframe2 objectOwner: self.
tframe3 := (TLoad3DSMax new initializeWithFileName:
(FileDirectory pathFrom:
{FileDirectory default pathName. 'Content'. 'BasePlate70x3x70'. 'sphere1.ase'})
scale: 0.1 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe3 translationX:0 y: 0 z: 0.
tframe3 collapse.
tframe3 boundsDepth: 3.
tframe3 initBounds.
self addChild: tframe3.
tframe3 objectOwner: self.
CODE COMMENTS
We are trying to create a base, having a floor that is squared, for orientation of the positioning of the "pieces" we will use.
The dimensions of our base are:
70 croq-feet x 70 croq-feet 1 croq-foot = 0.1 3dsmax-foot 1 croq-foot = 30.4 croq-centimeters
In universal units our base has aprox. 21x21 croq-meters.
In the center of our base we have an sphere and part of the axes X and Z.
ATTENTION: The "normal floor" of Croquet is at Y= -3. Our base try to fix this curious definition (a bug?).
But, don't forget this, our code is not finished. We need to instantiate this base inside a 2D window that presents the Private space/area.
We will define, in the Class Private, the:
initializeDefaultSpace | space base | "Create a new space" space := TSpace new. "Make a light" self makeLight: space. "Create the base:" base := BasePlate70x3x70 new. space addChild: base. ^space.
CODE COMMENTS
We need to "do-itize" the script for Workspace, creating the 2D window etc.:
pV:= Private new. win:= SystemWindow new. lf:= LayoutFrame new. lf leftFraction:0. lf rightFraction:1. lf topFraction:0. lf bottomFraction:1. win setLabel: 'PRIVE'. win addMorph: pV fullFrame:lf. win openInWorldExtent: 500@500. pV requestInitialSpace.
CODE COMMENTS
Try to understand the important conceps of this first lesson doing the exercice. In the next lesson we will begin to "populate" our space.
NEXT LESSON T. CONTENTS HOMEPAGE
