255 aaa00000fb05fe0080333fff70f ^2********************************************************************* ^3 P r o g r a m P a r l o u r ^2 T w o ^3 b y B e n A s h l e y ^2********************************************************************* ^1 Last time, we looked at PROGRAM PROTECTION. This issue though, I`ll ^1be giving you a tutorial on AMOS 3D. Yes, I know its been done ^1rather badly, and many people have binned it and ripped it off their ^1AMOS program disks. But for those of us, who have for some reason or ^1another, KEPT it on, then you might find this tutorial rather nice. ^1 Firstly, I`ll give you a full blown program, and explain each ^1section bit-by-bit. After that, I`ll tell you about the uses of ^1other 3D commands which are not exploited in the 3D demo. ^1 Ok, so lets go. Load up AMOS, and MAKE SURE you have the 3D ^1extension loaded in. ^2Now I`ll explain it all, bit by bit. So, I always start my ^2programs`s with REM`s, the following can be ommited.. ^2 ' AMOS 3D Tutorial Program ^2 ' ======================== ^2 ' Written for TOTALLY AMOS, by Ben Ashley of Odyssey Software ^2 ' Please note: Requires the OBJECTS directory, to be in the ROOT ^2 ' directory, and the file, WB.IFF, to also be in the root directory. ^1 No Problem. So now I`ll create a simple, 16 colour LOW RES screen^1^1. ^2 Screen Open 0,320,256,16,Lowres ^1 And I`ll do a simple setup procedure, of setting colour 1 to white, ^1setting the PEN and PAPER colours, turning the cursor and flash off, ^1and finally hiding the Mouse and clearing the screen. ^2 Colour 1,$FFF : Pen 1 : Paper 0 : Curs Off : Flash Off : ^2 Hide On : Cls 0 ^1 Now, to prevent flicker when displaying the 3D screen, we'll double ^1buffer and autoback it. ^2 Double Buffer : Autoback 0 ^1 If you don`t have AMOS LIBS on the disk with which you are working, ^1you need a routine to find the AMOS: disk, and set the drive... ^2 If Not Exist("AMOS:") ^2 Centre At(,10)+"Please insert volume AMOS:" ^2 Centre At(,11)+"into any drive" ^2 Repeat ^2 Curs Off ^2 Until Exist("AMOS:") ^2 End If ^1 So, I clear the screen, set the directory to `AMOS:', and load the ^13D extension by using the command, TD KEEP ON. ^2 Cls 0 ^2 Dir$="AMOS:" ^2 Td Keep On ^1 Now, I need to set the directory path, BACK to my 3D work disk. As ^1I have a directory, called `Objects', I`ll ask AMOS to find that ^1disk, and on finding it, set the directory... ^2 If Not Exist("Df0:Objects") ^2 Centre At(,10)+"Please insert TA in drive Df0:" ^2 Repeat ^2 Curs Off ^2 Until Exist("Df0:Objects") ^2 Cls 0 ^2 End If ^1 This program assumes that the 3D work disk is in Df0:... ^2 Dir$="Df0:" ^2 Cls 0 ^1 Now, I set the Screen Height. In this 3D demo, I`m using a full ^1screen value of 256. Usually, I use a value of 200, so as to leave ^1room for a status display. ^2 Td Screen Height 256 ^1 Now, I set the TD directory. This is the directory, which contains ^1all of the object definitions. ^2 Td Dir "Df0:Objects/" ^1 In this short demo, I only need to load up ONE previously saved ^1object, called `cube1'. ^2 Td Load "cube1" ^1 This is a simple cube, with `TA', on all sides. Next, I place my ^1objects using the TD OBJECT command. Notice how I use the single ^1cube definition for 2 objects. The first object is placed at ^1X-co-ordinate 2000, Y-co-ordinate 2500 and a Z value of 2000. I did ^1not want the cube to be at any special attitude, so I just set these ^1to 0,0,0. The second object is placed, higher up, ( Less Y value ), ^1and farther into the distance, ( Greater Z Value). ^2 Td Object 1,"cube1",2000,2500,2000,0,0,0 ^2 Td Object 2,"cube1",2000,2000,6000,0,0,0 ^1 Next, I want to move the viewpoint, so that when the program starts, ^1the viewer sees both cubes directly in front. Remember that object ^10, is the viewpoint. And I move it to X:2000, which is the same ^1value as my two previously defined cubes. Y:2300, is a value sort of ^1inbetween the Y values of the 2 cubes. Finally, the Z value is 0. ^2 Td Move 0,2000,2300,0 ^1 Next, I set some variables for the demo. F1, is the Z movement ^1value for cube 1, and F2 is the Z movement value for cube 2. The ^1TIME variable, determines exactly how many times the cubes will move. ^2 F1=400 ^2 F2=-400 ^2 TIME=0 ^1So, now I start up my REPEAT loop. ^2 Repeat ^1 The following bit is the USUAL way of drawing 3D objects on the ^1screen. First it clears any previous frames, draws the new ones, ^1swaps the physical and logical screens, and finally, synchronizes it. ^2 Td Cls ^2 Td Redraw ^2 Screen Swap ^2 Wait Vbl ^1 Now, I want my first cube to be spinning in all 3 ways, in one ^1direction, whilst the other, doing the same thing, but in the ^1opposite direction. The 3 values after the object number, are the ^1attitude values of A,B and C. ^2 Td Angle Rel 1,1000,1000,1000 ^2 Td Angle Rel 2,-1000,-1000,-1000 ^1 Now, I move the 2 cubes corresponding to what direction thay are ^1going, so I use the values F1, and F2, which have been defined ^1previously. ^2 Td Move Rel 1,0,0,F1 ^2 Td Move Rel 2,0,0,F2 ^1 Now, I add the TIME value, by one. ^2 Add TIME,1 ^1 If the timer value has reached 13, it checks to see which direction ^1cube 1 is going. If it is going towards the eye, then it knows to ^1set the other cube to go towards the viewpoint, whilst cube 1, to go ^1away. If not, then it tells cube 1 to go towards the viewpoint, and ^1cube 2, to go away. I know it sounds complicated, but it is quite ^1logical. Finally, it sets the TIME counter back to 0. ^2 If TIME>13 ^2 If F1=-400 ^2 F1=400 ^2 F2=-400 ^2 Else ^2 F1=-400 ^2 F2=400 ^2 End If ^2 TIME=0 ^2 End If ^1 Finally, to add a little `Spice', to the demo, I`ve decided to put ^1in some world controls. Basically, the following section, allows you ^1to control the viewpoint`s X and Y values using the cursor keys. ^1(76=up, 77=down, 79=left, 78=right) ^2 If Key State(79) ^2 Td Move Rel 0,-200,0,0 ^2 End If ^2 If Key State(78) ^2 Td Move Rel 0,200,0,0 ^2 End If ^2 If Key State(76) ^2 Td Move Rel 0,0,200,0 ^2 End If ^2 If Key State(77) ^2 Td Move Rel 0,0,-200,0 ^2 End If ^1 And at last, it checks to see if QUIT=True. As I have not put in an ^1EXIT feature on this demo, it will never be true. ^2 Until QUIT=True ^1 If you want to see how this looks straight away, then load up the ^13D-Tutorial.AMOS, program, which is the above program, in full ^1working form. ^4Other 3D Commands ^5+-+-+-+-+-+-+-+-+ ^61. Td Background ^7================= ^6 I found the TD BACKGROUND command very useful. Although I have only ^6got it work on LOW RES screens. ^6 You can use it for a sky background, or even an amazing Hit tech HUD ^6display. Believe me, if TD BACKGROUND had not been included, the 3D ^6programs would be drab and boring. ^6 Firstly, you have to note the following point. If you want the ^6screen to be displayed behind the objects, ie, like for a sky, then ^6it must be placed BEFORE the TD REDRAW command. If you want to use ^6it as a HUD or a SHIPS COCKPIT picture, then use it after. ^6 It is perfectly feasible to have 2 backgrounds. I used two in my ^6space game ZION. screen 2 had stars on, whilst screen 3 had the HUD ^6on, I simply did it like this... ^5 Td Cls ^5 Td Background 2,0,0,320,200 to 0,0,0 ^5 Td Redraw ^5 Td Background 3,0,0,320,200 to 0,0,0 ^5 Screen Swap ^5 Wait Vbl ^6See? It`s quite easy. ^62. Td Range ^7============ ^6 I used this command, INSTEAD of setting zones. To me, it worked ^6better. Just specify two objects, and you are returned with a value! ^6So if you wanted to see if missile 3, hit ship 7, you`d use something ^6like.... ^5 If Td Range(3,7)<1000 ^5 Proc WHAMBAMTHANKYAMAM ^5 End If ^6 There are many other 3D commands. Some of which are easy and useful ^6( TD FACE ), and others which are more obscure, ( TD ADVANCED ). I ^6hope this quick tutorial has helped. ^7=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ^7-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z-z- \