home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / E / TFF-A32R.LZX / AmigaE3.2a / Src / Tools / FilledVector / examples / cube39.e < prev    next >
Encoding:
Text File  |  1994-07-06  |  1.6 KB  |  68 lines

  1.  
  2. /*
  3.  
  4.   A _simple_ cube example, using Workbench 3.0 code
  5.  
  6.   FilledVector.m module example code, Michael Zucchi
  7.  
  8.   This code in the public domain
  9.  
  10. */
  11.  
  12. OPT OSVERSION=39
  13.  
  14. MODULE 'intuition/intuition', 'intuition/screens',
  15.     'tools/filledvector', 'tools/filledvdefs',
  16.     'tools/scrbuffer',
  17.     'graphics/rastport'
  18.  
  19. DEF scr,pc,cube:PTR TO vobject, destz=2000,
  20.     rast:rastport;
  21.  
  22. PROC main()
  23.  
  24. InitRastPort(rast);
  25.  
  26. scr:=sb_OpenScreen([SA_DEPTH,4,SA_WIDTH,320,SA_HEIGHT,200,0],0);
  27.  
  28. pc:=newPolyContext(sb_GetBitMap(scr),20)    -> create context
  29. setPolyFlags(pc,1,1)            -> turn on zclipping
  30.  
  31.  cube:=newVectorObject(0,    -> basic type
  32.      8,            -> 8 points
  33.      6,            -> 6 faces
  34.     [-100,100,-100,    -> 0    -> points array
  35.     100,100,-100,    -> 1
  36.     100,-100,-100,    -> 2
  37.     -100,-100,-100,    -> 3
  38.     -100,100,100,    -> 4
  39.     100,100,100,    -> 5
  40.     100,-100,100,    -> 6
  41.     -100,-100,100]:INT,    -> 7    -> faces array below
  42.     [0,1,2, 1, [4, 0,1,1,2,2,3,3,0]:INT, 0,    -> front
  43.     6,5,4, 2, [4, 4,5,5,6,6,7,7,4]:INT, 0,    -> back
  44.     2,1,5, 3, [4, 1,5,5,6,6,2,2,1]:INT, 0,    -> right
  45.     4,0,3, 4, [4, 4,0,0,3,3,7,7,4]:INT, 0,    -> left
  46.     1,0,4, 5, [4, 0,1,1,5,5,4,4,0]:INT, 0,    -> top
  47.     7,3,2, 6, [4, 3,2,2,6,6,7,7,3]:INT, 0]:face);    -> bottom
  48.  
  49. cube.pz:=1000;
  50.  
  51. WHILE Mouse()<>3
  52.   rast.bitmap:=sb_NextBuffer(scr);    -> next screen
  53.   SetRast(rast,0);            -> clear the off-screen
  54.   setPolyBitMap(pc, rast.bitmap);    -> take note of change
  55.   drawVObject(pc, cube);        -> draw to off-screen
  56.  
  57.   cube.ax:=cube.ax+1            -> move object
  58.   cube.ay:=cube.ay+2
  59.   cube.az:=cube.az+3
  60.   cube.pz:=cube.pz+((destz-cube.pz)/6)
  61.   IF Abs(cube.pz-destz)<6 THEN destz:=Rnd(2000)+10
  62. ENDWHILE
  63.  
  64. freeVectorObject(cube);
  65. sb_CloseScreen(scr);
  66.  
  67. ENDPROC
  68.