home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / _ / 3deditor / !3DEditor / Modules / Sweep / Module (.txt) next >
RISC OS BBC BASIC V Source  |  1994-01-07  |  9KB  |  323 lines

  1.  Sweep Module
  2. 0,"To use this module run the !3DEditor application"
  3. sweep_info
  4. 1ModulePurpose$="Create objects of revolution"
  5. #ModuleAuthor$="Simon Wilkinson"
  6. sweep_menuwarning:=0
  7. sweep_closed(b%):=0
  8. sweep_priority:=105
  9. sweep_initialise(data%)
  10. PutStr(data%,"sweep")
  11. !data%=0
  12. data%+=4
  13. S="-type creator -items 1 -version 1.13 -variables -windows -atleast 2.15 -info"
  14. sweep_windows(
  15. IndrPos%,task%)
  16. <Sweep_Ybox%=
  17. Window_Create("ybox",IndrPos%,Block%,task%)
  18. Window_Writeable(Sweep_Ybox%,8,10,4)
  19. Block%!0=8:Block%!4=2
  20. Block%!8=9:Block%!12=2
  21. Block%!16=10:Block%!20=2
  22. 7Block%!24=-1:
  23. Window_ActiveIcon(Sweep_Ybox%,Block%)
  24. sweep_variables
  25. SweepList(50,3)
  26. sweep_toolclick(tool$,num%):=1
  27. sweep_toolstart(tool$,num%)
  28. Display_Claim("Sweeping")
  29. Display_ClaimGrid
  30. Display_StartDrawing
  31. Display_Move(0,-MainYWidth%/2)
  32. Display_Draw(0,MainYWidth%/2)
  33. Display_EndDrawing
  34. Wimp_NewPointer("ptr_cross",7,7)
  35. ClickedOn%=-1
  36. ClickedSide%=-1
  37. Selected%>-1
  38. (Select_Type%=8
  39. Select_Type%=10)
  40. Sweep_Exists%=Selected%
  41. sweep_existing
  42. Sweep_Exists%=-1
  43. Sweep_TwoSided%=
  44. SweepPos%=0
  45. Window_NewYbox(Sweep_Ybox%,
  46. Icon_UpState(Sweep_Ybox%,18,0)
  47. Icon_UpState(Sweep_Ybox%,19,0)
  48. Icon_UpState(Sweep_Ybox%,20,0)
  49. NodesOn%=
  50. Icon_UpText(Sweep_Ybox%,8,"360")
  51. Icon_UpText(Sweep_Ybox%,9,"10")
  52. Icon_UpText(Sweep_Ybox%,10,"0")
  53. sweep_toolend(tool$,num%)
  54. Wimp_OldPointer("ptr_cross")
  55. Window_LooseYbox(Sweep_Ybox%)
  56. Display_LoseCursor
  57. Display_ReleaseGrid
  58. Display_Release
  59. sweep_click(win%,icon%,x%,y%,button%)
  60. d%,dum%,ok%,o%
  61. CurrentMain%
  62. button%
  63. ClickedOn%=-1
  64. Display_LoseCursor
  65. Display_ConvXY(x%,y%)
  66. G    ok%=
  67. :ClickedSide%=0
  68.  Sweep_TwoSided%
  69. :ClickedSide%=1
  70. o%=ClickedSide%*2
  71. loop%=0
  72. SweepPos%-1
  73. (SweepList(loop%,0+o%)-x%)<8
  74. (SweepList(loop%,1+o%)-y%)<8
  75. ClickedOn%=loop%
  76. ClickedOn%=-1
  77. sweep_addpoint(ClickedSide%)
  78. Display_SnapToClaimedGrid(x%,y%)
  79. ClickedOn%=-1
  80. SweepList(SweepPos%,0)=x%
  81. SweepList(SweepPos%,2)=-x%
  82. SweepList(SweepPos%,0)=-x%
  83. SweepList(SweepPos%,2)=x%
  84. SweepList(SweepPos%,1)=y%
  85. SweepList(SweepPos%,3)=y%
  86. ClickedOn%=SweepPos%
  87. SweepPos%+=1
  88. sweep_redraw
  89. sweep_redraw
  90. %100*16
  91. ClickedOn%<>-1
  92. Drag_StartLines
  93. o%=ClickedSide%*2
  94. ClickedOn%<>0
  95. Drag_Move(SweepList(ClickedOn%-1,0+o%),SweepList(ClickedOn%-1,1+o%))
  96. Drag_Draw(&FFFF,&FFFF)
  97. Drag_Move(&FFFF,&FFFF)
  98. ClickedOn%<>SweepPos%-1
  99. Drag_Draw(SweepList(ClickedOn%+1,0+o%),SweepList(ClickedOn%+1,1+o%))
  100. Drag_Node2(&FFFF,&FFFF)
  101. Drag_Node(&FFFF,&FFFF)
  102. s?x%=SweepList(ClickedOn%,0+o%):y%=SweepList(ClickedOn%,1+o%)
  103. Display_Screen(x%,y%)
  104. Drag_Ready(x%,y%,1,
  105. Sweep_Ybox%
  106. icon%
  107. {.Sweep_Rotation%=
  108. Icon_Read(Sweep_Ybox%,8)
  109. |+Sweep_Faces%=
  110. Icon_Read(Sweep_Ybox%,9)
  111. }-Sweep_Yshift%=
  112. Icon_Read(Sweep_Ybox%,10)
  113. sweep_go
  114. Tool_Clear
  115. Tool_Clear
  116. ClickedOn%<>-1
  117.  ClickedSide%=0
  118. sweep_deletepoint(ClickedOn%)
  119. Icon_UpState(win%,16,0)
  120. sweep_circle
  121. Icon_UpState(win%,17,0)
  122. $Sweep_TwoSided%=
  123. Sweep_TwoSided%
  124. ClickedSide%=0
  125. sweep_copysides
  126. sweep_redraw
  127. Icon_GreyOut(Sweep_Ybox%,8,Sweep_TwoSided%
  128. Icon_GreyOut(Sweep_Ybox%,10,Sweep_TwoSided%
  129. Icon_UpText(Sweep_Ybox%,8,"360")
  130. Icon_UpText(Sweep_Ybox%,9,"10")
  131. ClaimGridOn%=
  132. ClaimGridOn%
  133. sweep_redraw
  134. &ClaimSnapToGrid%=
  135. ClaimSnapToGrid%
  136. sweep_dragged(num%,x%,y%,z%)
  137. CursorOn%=
  138. Display_ConvXY(x%,y%)
  139. Display_SnapToClaimedGrid(x%,y%)
  140. o%=ClickedSide%*2
  141. !SweepList(ClickedOn%,0+o%)=x%
  142. !SweepList(ClickedOn%,1+o%)=y%
  143. sweep_redraw
  144. sweep_redraw
  145. x%,y%,loop%,l2%,o%,displayside%,colour%
  146. CursorOn%=
  147. Display_StartDrawing
  148. Display_Move(0,-MainYWidth%/2)
  149. Display_Draw(0,MainYWidth%/2)
  150. Display_Colour(7):colour%=7
  151. displayside%=0
  152. loop%=0
  153. loop%<>SweepPos%
  154. x%=SweepList(loop%,0)
  155. y%=SweepList(loop%,1)
  156. displayside%=1
  157. Sweep_TwoSided%
  158. x%=-x%
  159. x%=SweepList(loop%,2)
  160. y%=SweepList(loop%,3)
  161. ClickedOn%<>-1
  162.  loop%=ClickedOn%
  163.  ClickedSide%=displayside%
  164. Display_Colour(11)
  165. loop%=0
  166. Display_Move(x%,y%)
  167. Display_Draw(x%,y%)
  168. ClickedOn%<>-1
  169.  loop%=ClickedOn%+1
  170.  ClickedSide%=displayside%
  171. Display_Colour(colour%)
  172. loop%+=1
  173. Display_Colour(colour%)
  174. Sweep_TwoSided%
  175. Display_Colour(2):colour%=2
  176. displayside%
  177. Sweep_TwoSided%
  178. l2%=0
  179. loop%=0
  180. loop%<>SweepPos%
  181. x%=SweepList(loop%,0+l2%*2)
  182. Sweep_TwoSided%
  183. x%=-x%
  184. y%=SweepList(loop%,1+l2%*2)
  185. Display_Node(x%,y%)
  186. loop%+=1
  187. Display_EndDrawing
  188. o%=ClickedSide%*2
  189. ClickedOn%<>-1
  190. Display_Cursor2D(SweepList(ClickedOn%,0+o%),SweepList(ClickedOn%,1+o%))
  191. sweep_go
  192. Sweep_Exists%<>-1
  193. Object_DeleteItem(CurrentObj%,Sweep_Exists%)
  194. myitem%=-1
  195. Sweep_TwoSided%
  196. (Sweep_Faces%
  197. Sweep_Faces%+=1
  198. Sweep_TwoSided%
  199. Object_MakeMatrix(CurrentObj%,myitem%,Sweep_Faces%,SweepPos%-1,10,0,0,0,0,0,0,1,1,1,1+o%)
  200. (angle=Sweep_Rotation%/(Sweep_Faces%)
  201. middle%=Sweep_Faces%/2
  202. floop%=0
  203. Sweep_Faces%
  204. ang=angle*floop%
  205. floop%>middle%
  206. fat%=middle%-(floop%-middle%)
  207. fat%=floop%
  208. ploop%=0
  209. SweepPos%-1
  210. Sweep_TwoSided%
  211. conv=(middle%-fat%)/middle%
  212. <x%=SweepList(ploop%,0)*conv-SweepList(ploop%,2)*(1-conv)
  213. <y%=SweepList(ploop%,1)*conv+SweepList(ploop%,3)*(1-conv)
  214. x%=SweepList(ploop%,0)
  215. y%=SweepList(ploop%,1)
  216. xn%=x%*cos-z%*sin
  217. yn%=y%+Sweep_Yshift%*floop%
  218. zn%=x%*sin+z%*cos
  219. Object_MatrixPoint(CurrentObj%,myitem%,floop%,ploop%,xn%,yn%,zn%,1)
  220. Selected%=myitem%
  221. Select_Type%=8
  222. sweep_deletepoint(point%)
  223. loop%=point%
  224. SweepPos%-2
  225. +SweepList(loop%,0)=SweepList(loop%+1,0)
  226. +SweepList(loop%,1)=SweepList(loop%+1,1)
  227. +SweepList(loop%,2)=SweepList(loop%+1,2)
  228. +SweepList(loop%,3)=SweepList(loop%+1,3)
  229. SweepPos%-=1
  230. ClickedOn%=point%-1
  231. sweep_redraw
  232. sweep_circle
  233. centx%,centy%,loop%,radius%,r%,ang
  234. sweep_findcentre(centx%,centy%)
  235. radius%=0
  236. loop%=0
  237. SweepPos%-1
  238. ((SweepList(loop%,0)-centx%)^2+(SweepList(loop%,1)-centy%)^2)
  239. r%>radius%radius%=r%
  240. ang=-180/(SweepPos%-1)
  241. loop%=0
  242. SweepPos%-1
  243. 6SweepList(loop%,0)=centx%+radius%*
  244. (ang*loop%-90)
  245. 6SweepList(loop%,1)=centy%+radius%*
  246. (ang*loop%-90)
  247. 9SweepList(loop%,2)=-(centx%+radius%*
  248. (ang*loop%-90))
  249. 9SweepList(loop%,3)=-(centy%+radius%*
  250. (ang*loop%-90))
  251. sweep_redraw
  252. sweep_findcentre(
  253. loop%,x%,y%,minx%,miny%,maxx%,maxy%
  254. minx%=10000:maxx%=-10000
  255. miny%=10000:maxy%=-10000
  256. loop%=0
  257. SweepPos%-1
  258. x%=SweepList(loop%,0)
  259. y%=SweepList(loop%,1)
  260. x%<minx%minx%=x%
  261. x%>maxx%maxx%=x%
  262. y%<miny%miny%=y%
  263. y%>maxy%maxy%=y%
  264. cx%=(maxx%-minx%)/2+minx%
  265. cy%=(maxy%-miny%)/2+miny%
  266.      cx%=0
  267. sweep_addpoint(side%)
  268. loop%=0:ok%=
  269. side%=side%*2
  270. loop%<SweepPos%-2
  271. &"minx%=SweepList(loop%,0+side%)
  272. '"miny%=SweepList(loop%,1+side%)
  273. ($maxx%=SweepList(loop%+1,0+side%)
  274. )$maxy%=SweepList(loop%+1,1+side%)
  275. minx%>maxx%
  276. minx%,maxx%
  277. miny%>maxy%
  278. miny%,maxy%
  279. x%>minx%
  280.  x%<maxx%
  281.  y%>miny%
  282.  y%<maxy%
  283. -#x1%=maxx%-minx%:y1%=maxy%-miny%
  284. x2%=x%-minx%:y2%=y%-miny%
  285. y1%=0
  286. y2%>-16
  287.  y2%<16
  288. (x2%-x1%)<16
  289. minx2%=x1%*(y2%-16)/y1%-16
  290. maxx2%=x1%*(y2%+16)/y1%+16
  291. x2%>=minx2%
  292.  x2%<=maxx2%
  293. loop%+=1
  294. l2%=SweepPos%
  295. loop%
  296. ;'SweepList(l2%,0)=SweepList(l2%-1,0)
  297. <'SweepList(l2%,1)=SweepList(l2%-1,1)
  298. ='SweepList(l2%,2)=SweepList(l2%-1,2)
  299. >'SweepList(l2%,3)=SweepList(l2%-1,3)
  300. Display_SnapToClaimedGrid(x%,y%)
  301. side%=0
  302. SweepList(loop%,0)=x%
  303. SweepList(loop%,2)=-x%
  304. SweepList(loop%,0)=-x%
  305. SweepList(loop%,2)=x%
  306. SweepList(loop%,1)=y%
  307. SweepList(loop%,3)=y%
  308. ClickedOn%=loop%
  309. SweepPos%+=1
  310. sweep_existing
  311. O<pos%=
  312. Object_FindItem(CurrentObj%,Selected%)+ObjectItem%
  313. Sweep_TwoSided%=
  314. SweepPos%=pos%!48+1
  315. ploop%=0
  316. SweepPos%-1
  317. Object_MatrixPoint(CurrentObj%,Selected%,0,ploop%,SweepList(ploop%,0),SweepList(ploop%,1),SweepList(ploop%,2),0)
  318. sweep_redraw
  319. sweep_copysides
  320. SweepPos%-1
  321. Z$SweepList(l%,2)=-SweepList(l%,0)
  322. [#SweepList(l%,3)=SweepList(l%,1)
  323.