home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Raytracing / Raytracer / LW5VT09.LHA / Toaster / Arexx_examples / lwm / TestScript.lwm < prev    next >
Encoding:
Text File  |  1996-06-10  |  6.6 KB  |  289 lines

  1. /* CMD: Test Script
  2.  * Skeleton for Modeler ARexx scripts
  3.  */
  4.  
  5. ax.1='X'
  6. ax.2='Y'
  7. ax.3='Z'
  8. lax="X"
  9. address "LWModelerARexx.port"
  10. call addlib "LWModelerARexx.port", 0
  11. SIGNAL ON ERROR
  12. SIGNAL ON SYNTAX
  13. NUMERIC DIGITS 4
  14. call addlib "rexxsupport.library", 0, -30, 0
  15. call addlib "rexxmathlib.library", 0, -30, 0
  16. sysnam = 'Text Thing'
  17. version = '0.01ß'
  18.  
  19. N=pointcount()
  20. call req_begin sysnam
  21.  
  22.  id_srf = req_addcontrol("Surfaces",'R')
  23.  id_fnt = req_addcontrol("Faces",'F',1)
  24.  id_txt = req_addcontrol("@Hey ", 'T',"Points: "N"  So far")
  25. id_ind = req_addcontrol("Text Type", "CH",'Block Fillet Chisel Cut')
  26. /* id_lay = req_addcontrol("Layer", 'CH','1 2 3 4 5 6 7 8')
  27. id_num = req_addcontrol("Segments", 'N')
  28. id_ind = req_addcontrol("Axis", "CH",'X Y Z')
  29. id_cnt = req_addcontrol("Center", 'V', 0)
  30.  
  31. call req_setval id_cnt 0,N,0
  32.  */
  33.  
  34. if (~req_post()) then do
  35.     call req_end
  36.     exit
  37. end
  38. surf=req_getval(id_srf)
  39. 'surface "'surf'"'
  40.  call req_end
  41.  
  42. /* fullfile=getfilename("-- Load Macro --","REXX:lwm" ) */
  43. /* call rxcmd_add fullfile, fullfile */
  44.  
  45. call center
  46. typ=req_getval(id_ind)
  47. if typ=1 then
  48.   'EXTRUDE e0.1 n1 axis=Z'
  49. if typ=2 then
  50.   Call BevelExtrudeText
  51. if typ=3 then do
  52.   COPY
  53.   'BEVEL i0.035 s-0.15'
  54.   PASTE
  55.   end
  56. if typ=4 then do
  57.   FLIP
  58.   'surface "CutText"'
  59.   COPY
  60.   FLIP
  61.   'BEVEL i-0.035 s0.25'
  62.   PASTE
  63.   'MOVE O[0,0,'0.25*0.5']'
  64.   end
  65. exit
  66.  
  67. empty=emptylayers()
  68. if empty~="" then do
  69.   slablayer=word(empty,1)
  70.   end
  71. else do    /* Need 1 layer to transform in */
  72.   call notify(1,'!'sysnam,'@Sorry, No Scratch Layer Available')
  73.   exit
  74.   end
  75.  
  76. w=3
  77. h=2
  78. bx=2*w
  79. by=2*h
  80. bz=h
  81. marg=h/10
  82. txlayer=curlayer()
  83. 'setlayer 'slablayer
  84. 'surface "back"'
  85. 'makebox L0 H['bx','by','0'] nsegments=1'
  86. 'bevel i'marg' s'marg
  87. call center
  88. say 'drill w'txlayer' operation=SLICE axis=Z'
  89. 'drill w3 operation=SLICE axis=Z'
  90. 'boolean with'txlayer' operation=SUBTRACT' /* Remove Slab poly */
  91. 'boolean with'txlayer' operation=ADD' /* Add in Text Poly */
  92. 'EXTRUDE e'h' n1 axis=Z'
  93. 'PASTE'
  94.  
  95. 'setlayer 'txtlayer
  96.  
  97. SYNTAX:
  98. ERROR:
  99.   say 'Sorry, Error #'RC' on line 'SIGL' has been detected.'
  100.   say errortext(rc)
  101.   say sourceline(SIGL)
  102.   t=notify(1,'!Total Bummer Dude!','!An error has been detected.','@'ErrorText(rc),'Line 'SIGL)
  103.   call end_all
  104.   exit
  105.  
  106.  
  107. PointCount: PROCEDURE
  108.   n=XFRM_BEGIN()
  109.   call END_ALL
  110.   return n
  111.  
  112. MakeTube: PROCEDURE
  113.   arg cen, len, rad, ax,t
  114.   parse var cen cx','cy','cz
  115.   axlet=translate(ax,'XYZ','123')
  116.   'SURFACE "TubeType_'t'"'
  117.   tb.1='B'cx' T'cx+len
  118.   tb.2='B'cy' T'cy+len
  119.   tb.3='B'cz' T'cz+len
  120.   select
  121.     when t=1 then do
  122.       sides=random(3,16,time('s')) /* Rand Tube */
  123.       mrad=max(randu(),0.5)*rad
  124.       r.1=rad','rad','mrad
  125.       r.2=rad','rad','mrad
  126.       r.3=rad','mrad','rad
  127.       "MAKEDISC c["cen"] r[" r.ax '] axis='axlet' nsides='sides' 'tb.ax' NSEGMENTS=1'
  128.       end
  129.     when t=2 then do
  130.       sides=12 /* Tri-Tube */
  131.       cn.1='c['cx','cy+rad*.5','cz'] r'0.5*rad' axis='axlet
  132.       cn.2='c['cx+rad*.5','cy','cz'] r'0.5*rad' axis='axlet
  133.       cn.3='c['cx','cy+rad*.5','cz'] r'0.5*rad' axis='axlet
  134.       CUT
  135.       'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
  136.       'ROTATE c['cx','cy','cz'] axis='axlet' angle=120'
  137.       'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
  138.       'ROTATE c['cx','cy','cz'] axis='axlet' angle=120'
  139.       'MAKEDISC 'cn.ax' nsides='sides' 'tb.ax' NSEGMENTS=1'
  140.       PASTE
  141.       end
  142.     when t=3 then do
  143.       r=0.707*rad
  144.       corn.1='L['cx','cy+r','cz+r'] H['cx+len','cy-r','cz-r'] n1'
  145.       corn.2='L['cx+r','cy','cz+r'] H['cx-r','cy+len','cz-r'] n1'
  146.       corn.3='L['cx+r','cy+r','cz'] H['cx-r','cy-r','cz+len'] n1'
  147.       "MAKEBOX "corn.ax
  148.       if random(0,1,time('s')) then 'ROTATE c['cen'] axis='axlet' angle=45'
  149.       end
  150.     when t=4 then do  /* Accordion tube */
  151.       if ax="1" then do
  152.         y1=cy+rad
  153.         y2=cy+rad*(0.5*randu() + 0.25)
  154.         segs=random(2,5,time('s'))
  155.         dx=len/(2*segs)
  156.         x=cx
  157.         p=0
  158.         CUT
  159.         call add_begin
  160.         do i=1 to segs
  161.           vec= x y1 cz
  162.           call add_point vec
  163.           p=p+1
  164.           x=x+dx
  165.           call add_point x y2 cz
  166.           p=p+1
  167.           x=x+dx
  168.           call add_polygon p-1 p
  169.           call add_point x y1 cz
  170.           p=p+1
  171.           call add_polygon p-1 p
  172.           end
  173.         call add_end
  174.         'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
  175.         PASTE
  176.         end
  177.       if ax="2" then do
  178.         x1=cx+rad
  179.         x2=cx+rad*(0.5*randu() + 0.25)
  180.         segs=random(2,5,time('s'))
  181.         dy=len/(2*segs)
  182.         y=cy
  183.         p=0
  184.         CUT
  185.         call add_begin
  186.         do i=1 to segs
  187.           call add_point x1 y cz
  188.           p=p+1
  189.           y=y+dy
  190.           call add_point x2 y cz
  191.           p=p+1
  192.           y=y+dy
  193.           call add_polygon p-1 p
  194.           call add_point x1 y cz
  195.           y=y+dy
  196.           p=p+1
  197.           call add_polygon p-1 p
  198.           end
  199.         call add_end
  200.         'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
  201.         PASTE
  202.         end
  203.       if ax="3" then do
  204.         y1=cy+rad
  205.         y2=cy+rad*(0.5*randu() + 0.25)
  206.         segs=random(2,5,time('s'))
  207.         dz=len/(2*segs)
  208.         z=cz
  209.         p=0
  210.         CUT
  211.         call add_begin
  212.         do i=1 to segs
  213.           call add_point cx y1 z
  214.           p=p+1
  215.           z=z+dz
  216.           call add_point cx y2 z
  217.           p=p+1
  218.           z=z+dz
  219.           call add_polygon p-1 p
  220.           call add_point cx y1 z
  221.           z=z+dz
  222.           p=p+1
  223.           call add_polygon p-1 p
  224.           end
  225.         call add_end
  226.         'LATHE c['cx','cy','cz'] s0 e360 axis='axlet' n'random(3,16)
  227.         PASTE
  228.         end
  229.       end
  230.     end
  231.     return t
  232.  
  233.  
  234. Transform:
  235.   arg mov, rot, scl, cnt
  236.   parse var rot rx','ry','rz
  237.   'SCALE C['cnt'] F['scl']'
  238.   if rx~=0 then 'ROTATE C['cnt'] Axis=X ang'rx  /* Interpret rotations as sequential operations */
  239.   if ry~=0 then 'ROTATE C['cnt'] Axis=Y ang'ry
  240.   if rz~=0 then 'ROTATE C['cnt'] Axis=Z ang'rz
  241.   'MOVE O['mov']'
  242.   return
  243.  
  244. SolidText: Procedure
  245. call Center
  246. 'BEVEL i0 s0.02'
  247. 'COPY'
  248. 'UNDO'
  249. FLIP
  250. 'PASTE'
  251. return
  252.  
  253. BevelExtrudeText: Procedure /* Have flat text polygons ready! */
  254. 'BEVEL i0.015 s0.015'
  255. 'COPY'
  256. 'UNDO'
  257. 'EXTRUDE e0.1 n1 axis=Z'
  258. 'PASTE'
  259. return .015
  260.  
  261. BevelChiselText: Procedure /* Have flat text polygons ready! */
  262. 'BEVEL i0.045 s-0.15'
  263.  return
  264.  
  265. /* TextSlab: */
  266. Center: Procedure
  267.   box=boundingbox()  /* Should check out empty list ...  */
  268.   parse var box n x1 x2 y1 y2 z1 z2
  269.   cx=-(x2+x1)/2
  270.   cy=-(y2+y1)/2
  271.   cz=-(z2+z1)/2
  272.   'MOVE O=['cx','cy','cz']'
  273.   return box
  274.  
  275. CenterAx: Procedure
  276.   arg A
  277.   box=boundingbox()  /* Should check out empty list ...  */
  278.   parse var box n x1 x2 y1 y2 z1 z2
  279.   cx=-(x2+x1)/2
  280.   cy=-(y2+y1)/2
  281.   cz=-(z2+z1)/2
  282.   say A cx cy cz
  283.   if ~pos(upper(A),'X') then cx=0
  284.   if ~pos(upper(A),'Y') then cy=0
  285.   if ~pos(upper(A),'Z') then cz=0
  286.   say cx cy cz
  287.   'MOVE O=['cx','cy','cz']'
  288.   return box
  289.