home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / e / amigae / src / tools / vector / vectest2.e < prev    next >
Text File  |  1992-09-02  |  1KB  |  47 lines

  1. MODULE 'tools/vector'
  2.  
  3. CONST R=100,MAXD=24,N=3            /* set N=1..7 (number of shades) */
  4.  
  5. OBJECT status
  6.   phi,theta,depth,x,y
  7. ENDOBJECT
  8.  
  9. DEF depth:PTR TO LONG,stats[N]:ARRAY OF status
  10.  
  11. PROC main()
  12.   DEF w,curphi=75,curtheta=40,curd=0,curs=0,a,fact=1,curx=100,cury=100
  13.   IF w:=OpenW(0,11,220,189,$200,$E,'3d VectorZ in E!',NIL,1,NIL)
  14.     SetRast(stdrast,1)
  15.     RefreshWindowFrame(w)
  16.     FOR a:=0 TO N-1 DO stats[a].phi:=-1
  17.     depth:=[200,201,202,205,208,211,215,220,224,230,238,246,254,262,270,276,280,285,289,292,295,298,299,300]
  18.     REPEAT
  19.       stats[curs].phi:=curphi
  20.       stats[curs].theta:=curtheta
  21.       stats[curs].depth:=curd
  22.       stats[curs].x:=curx
  23.       stats[curs].y:=cury
  24.       drawshape(stats[curs],2)
  25.       curs++
  26.       IF curs>=N THEN curs:=0
  27.       curd:=curd+fact
  28.       IF curd>=(MAXD-1) THEN (curd:=MAXD-1) BUT fact:=-fact
  29.       IF curd<=0 THEN (curd:=0) BUT fact:=-fact
  30.       curphi:=curphi+2
  31.       IF curphi>=360 THEN curphi:=0
  32.       curtheta:=curtheta+2
  33.       IF curtheta>=360 THEN curtheta:=0
  34.       IF stats[curs].phi>=0 THEN drawshape(stats[curs],1)
  35.     UNTIL GetMsg(Long(w+$56))
  36.     CloseW(w)
  37.   ENDIF
  38. ENDPROC
  39.  
  40. PROC drawshape(s:PTR TO status,col)
  41.   setmiddle3d(s.x,s.y)
  42.   setpers3d(750,depth[s.depth])
  43.   init3d(s.phi,s.theta)
  44.   polygon3d([R,R,R,R,R,-R,R,-R,-R,R,-R,R,R,R,R,R,-R,R,-R,-R,R,-R,R,R,R,R,R],col)
  45.   polygon3d([-R,-R,-R,-R,-R,R,-R,R,R,-R,R,-R,-R,-R,-R,-R,R,-R,R,R,-R,R,-R,-R,-R,-R,-R],col)
  46. ENDPROC
  47.