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

  1.  Rotator/Scale Module
  2. 0,"To use this module run the !3DEditor application"
  3. rotscale_info
  4. )ModulePurpose$="Rotation and scaling"
  5. #ModuleAuthor$="Simon Wilkinson"
  6. rotscale_closed(win%):=0
  7. rotscale_priority:=25
  8. rotscale_initialise(data%)
  9. PutStr(data%,"rotate1")
  10. !data%=0:data%+=4
  11. PutStr(data%,"scale1")
  12. !data%=0:data%+=4
  13. PutStr(data%,"rotscale1")
  14. !data%=0:data%+=4
  15. b="-type creator -items 3 -windows -variables -menus -toggle -version 2.05 -atleast 2.15 -info"
  16. rotscale_windows(
  17. IndrPos%,task%)
  18. block%
  19. block%=Block%
  20. GRotate_Ybox%=
  21. Window_CreateYbox("rotateybox",IndrPos%,block%,task%)
  22. EScale_Ybox%=
  23. Window_CreateYbox("scaleybox",IndrPos%,block%,task%)
  24. JRotScale_Ybox%=
  25. Window_CreateYbox("rotscleybox",IndrPos%,block%,task%)
  26. rotscale_menus(task%)
  27. Menu_BuildMenu("Mirror","Mirror",12)
  28. Menu_AddSubMenu("Items","Mirror","Mirror",0,MenuNormal%)
  29. GRotScl_0%=
  30. Menu_AddItem("Mirror",task%,1,"X-axis",-1,0,MenuNormal%)
  31. GRotScl_1%=
  32. Menu_AddItem("Mirror",task%,2,"Y-axis",-1,0,MenuNormal%)
  33. GRotScl_2%=
  34. Menu_AddItem("Mirror",task%,3,"Z-axis",-1,0,MenuNormal%)
  35. rotscale_menuwarning
  36. Selected%<>-1
  37. opt%=0
  38. opt%=1
  39. Menu_GreyOut("Mirror",RotScl_0%,opt%)
  40. Menu_GreyOut("Mirror",RotScl_1%,opt%)
  41. Menu_GreyOut("Mirror",RotScl_2%,opt%)
  42. rotscale_variables
  43. rs_x%(3),rs_y%(3),rs_z%(3)
  44. RS_Xstep%=5
  45. RS_Ystep%=5
  46. RS_Zstep%=5
  47. rotscale_toolclick(tool$,num%)
  48. Selected%<>-1
  49. rotscale_toolstart(tool$,num%)
  50. 1    ok%=
  51. Selected%<>-1
  52. rs_objectdata
  53. rotate_ybox
  54. Window_NewYbox(Rotate_Ybox%,
  55. 8    ok%=
  56. rs_objectdata
  57. scale_ybox
  58. Window_NewYbox(Scale_Ybox%,
  59. =    ok%=
  60. rs_rotscalesetup
  61. Window_NewYbox(RotScale_Ybox%,
  62. A    ok%=
  63. rotscale_toolrestart(tool$,num%)
  64. rotscale_toolclick(tool$,num%)
  65. rotscale_toolend(tool$,num%)
  66. Window_LooseYbox(Rotate_Ybox%)
  67. Window_LooseYbox(Scale_Ybox%)
  68. rs_rotscaleend
  69. Window_LooseYbox(RotScale_Ybox%)
  70. rotscale_toolpause(tool$,num%)
  71. num%<>3
  72. dum%=
  73. rotscale_toolend(tool$,num%)
  74. =(num%<>3)
  75. rotscale_click(win%,icon%,x%,y%,button%)
  76. ToolNum%=3
  77. rs_click(win%,icon%,x%,y%,button%)
  78. Rotate_Ybox%
  79. \gup%=
  80. Window_ClickYboxNoSnap(win%,icon%,Rotate_X%,Rotate_Y%,Rotate_Z%,RS_Xstep%,RS_Ystep%,RS_Zstep%)
  81. icon%=18
  82. Window_Coord("Enter rotation",Rotate_X%,Rotate_Y%,Rotate_Z%,win%,1)
  83. rotate_update
  84. Scale_Ybox%
  85. baup%=
  86. Window_ClickYboxNoSnap(win%,icon%,Scale_X,Scale_Y,Scale_Z,RS_Xstep%,RS_Ystep%,RS_Zstep%)
  87. icon%=15
  88. Window_Coord("Enter scales",Scale_X,Scale_Y,Scale_Z,win%,2)
  89. scale_update
  90. rotscale_menuselect(name$,num%)
  91. rs_objectdata
  92. Object_UpdatePos(CurrentObj%,Selected%,0,0,0,0,0,0,-Scale_X,Scale_Y,Scale_Z,%001)
  93. Object_UpdatePos(CurrentObj%,Selected%,0,0,0,0,0,0,Scale_X,-Scale_Y,Scale_Z,%001)
  94. Object_UpdatePos(CurrentObj%,Selected%,0,0,0,0,0,0,Scale_X,Scale_Y,-Scale_Z,%001)
  95. Tool_Clear
  96. rotscale_coords(num%,x,y,z)
  97. RS_Xstep%=x
  98. RS_Ystep%=y
  99. RS_Zstep%=z
  100. Icon_UpText(Ybox%,11,"("+
  101. RS_Xstep%+","+
  102. RS_Ystep%+","+
  103. RS_Zstep%+")")
  104. Icon_Redraw(Ybox%,11)
  105. Rotate_X%=x
  106. Rotate_Y%=y
  107. Rotate_Z%=z
  108. rotate_update
  109. Scale_X=x
  110. Scale_Y=y
  111. Scale_Z=z
  112. scale_update
  113. CursorOn%=
  114. !s%=(rs_editing%
  115. 2)*2+(num%-3)
  116. rs_x%(s%)=x
  117. rs_y%(s%)=y
  118. rs_z%(s%)=z
  119. rs_update
  120. Display_Cursor(x,y,z)
  121. rotscale_dragged(num%,x%,y%,z%)
  122. 0,1,2,3
  123. CursorOn%=
  124. Display_ConvXY(x%,y%)
  125. Display_XYtoXYZ(rs_x%(num%),rs_y%(num%),rs_z%(num%),x%,y%,z%)
  126. 0rs_x%(num%)=x%:rs_y%(num%)=y%:rs_z%(num%)=z%
  127. rs_update
  128. Display_Cursor(x%,y%,z%)
  129. CursorOn%=
  130. !rs_x%(3)=rs_x%(3)-rs_x%(2)+x%
  131. !rs_y%(3)=rs_y%(3)-rs_y%(2)+y%
  132. !rs_z%(3)=rs_z%(3)-rs_z%(2)+z%
  133. rs_x%(2)=x%
  134. rs_y%(2)=y%
  135. rs_z%(2)=z%
  136. rs_update
  137. e%=rs_editing%
  138. Display_Cursor(rs_x%(e%),rs_y%(e%),rs_z%(e%))
  139. rotscale_redrawnotify
  140. rs_redraw3D
  141. rs_objectdata
  142. Selected%<>-2
  143. <pos%=
  144. Object_FindItem(CurrentObj%,Selected%)+ObjectItem%
  145. Select_Type%=?pos%
  146. Rotate_X%=pos%!20
  147. Rotate_Y%=pos%!16
  148. Rotate_Z%=pos%!24
  149. Scale_X=pos%!28/1000
  150. Scale_Y=pos%!32/1000
  151. Scale_Z=pos%!36/1000
  152. 'Rotate_X%=0:Rotate_Y%=0:Rotate_Z%=0
  153. !Scale_X=1:Scale_Y=1:Scale_Z=1
  154. rotate_ybox
  155. pos%,type$
  156. Icon_UpText(Rotate_Ybox%,11,"("+
  157. RS_Xstep%+","+
  158. RS_Ystep%+","+
  159. RS_Zstep%+")")
  160. Icon_Redraw(Rotate_Ybox%,11)
  161. Icon_UpText(Rotate_Ybox%,16,"Rotating "+
  162. Object_NameItem(Select_Type%))
  163. Icon_UpText(Rotate_Ybox%,18,"("+
  164. Rotate_X%+"
  165. Rotate_Y%+"
  166. Rotate_Z%+"
  167. Icon_Redraw(Rotate_Ybox%,14)
  168. scale_ybox
  169. pos%,type$
  170. Icon_UpText(Scale_Ybox%,11,"("+
  171. RS_Xstep%+","+
  172. RS_Ystep%+","+
  173. RS_Zstep%+")")
  174. Icon_Redraw(Scale_Ybox%,11)
  175. Icon_UpText(Scale_Ybox%,16,"Scaling "+
  176. Object_NameItem(Select_Type%))
  177. Icon_UpText(Scale_Ybox%,15,"("+
  178. scl_txt(Scale_X)+","++
  179. scl_txt(Scale_Y)+","+
  180. scl_txt(Scale_Z)+")")
  181. Icon_Redraw(Scale_Ybox%,14)
  182. rotate_update
  183. Rotate_X%>=360
  184. Rotate_X%-=360
  185. Rotate_Y%>=360
  186. Rotate_Y%-=360
  187. Rotate_Z%>=360
  188. Rotate_Z%-=360
  189. Rotate_X%<0
  190. Rotate_X%+=360
  191. Rotate_Y%<0
  192. Rotate_Y%+=360
  193. Rotate_Z%<0
  194. Rotate_Z%+=360
  195. Object_UpdatePos(CurrentObj%,Selected%,0,0,0,Rotate_Y%,Rotate_X%,Rotate_Z%,0,0,0,%010)
  196. Selected%=-2
  197. 'Rotate_X%=0:Rotate_Y%=0:Rotate_Z%=0
  198. Icon_UpText(Rotate_Ybox%,18,"("+
  199. Rotate_X%+"
  200. Rotate_Y%+"
  201. Rotate_Z%+"
  202. Icon_Redraw(Rotate_Ybox%,18)
  203. scale_update
  204. Object_UpdatePos(CurrentObj%,Selected%,0,0,0,0,0,0,Scale_X,Scale_Y,Scale_Z,%001)
  205. Selected%=-2
  206. !Scale_X=1:Scale_Y=1:Scale_Z=1
  207. Icon_UpText(Scale_Ybox%,15,"("+
  208. scl_txt(Scale_X)+","+
  209. scl_txt(Scale_Y)+","+
  210. scl_txt(Scale_Z)+")")
  211. Icon_Redraw(Scale_Ybox%,15)
  212. rs_rotscalesetup
  213. rs_editing%=0
  214. rs_orig%=Selected%
  215. $rs_x%(0)=0:rs_y%(0)=0:rs_z%(0)=0
  216. &rs_x%(1)=0:rs_y%(1)=100:rs_z%(1)=0
  217. Display_PointTrans(CurrentObj%,rs_orig%,rs_x%(0),rs_y%(0),rs_z%(0))
  218. Display_PointTrans(CurrentObj%,rs_orig%,rs_x%(1),rs_y%(1),rs_z%(1))
  219. Ars_x%(2)=rs_x%(0)+100:rs_y%(2)=rs_y%(0)+100:rs_z%(2)=rs_z%(0)
  220. Ars_x%(3)=rs_x%(1)+100:rs_y%(3)=rs_y%(1)+100:rs_z%(3)=rs_z%(1)
  221. jrs_new%=
  222. Object_CloneItem(CurrentObj%,Selected%,rs_x%(2)-rs_x%(0),rs_y%(2)-rs_y%(0),rs_z%(2)-rs_z%(0))
  223. ItemGreyed%=rs_orig%
  224. Selected%=-1
  225. Display_RedrawAll
  226. Display_Cursor(rs_x%(0),rs_y%(0),rs_z%(0))
  227.  Notify3DRedraw%=CurrentTask%
  228. rs_redraw3D
  229. rs_ybox
  230. rs_rotscaleend
  231. ItemGreyed%=-1
  232. Display_LoseCursor
  233. Object_DeleteItem(CurrentObj%,rs_orig%)
  234. Selected%=rs_new%-1
  235. Notify3DRedraw%=-1
  236. Display_RedrawAll
  237. rs_redraw3D
  238. Selected%=Items%
  239. Display_Start3DAdding
  240. (rs_editing%
  241. Display_Colour3D(11)
  242. Display_Colour3D(8)
  243. Display_Move3D(rs_x%(0),rs_y%(0),rs_z%(0))
  244. Display_Draw3D(rs_x%(1),rs_y%(1),rs_z%(1))
  245. (rs_editing%
  246. Display_Colour3D(11)
  247. Display_Colour3D(8)
  248. Display_Move3D(rs_x%(2),rs_y%(2),rs_z%(2))
  249. Display_Draw3D(rs_x%(3),rs_y%(3),rs_z%(3))
  250. Display_End3DAdding
  251. rs_ybox
  252. add%=(rs_editing%
  253. Icon_UpText(RotScale_Ybox%,20,"("+
  254. rs_x%(add%)+","+
  255. rs_y%(add%)+","+
  256. rs_z%(add%)+")")
  257. Icon_UpText(RotScale_Ybox%,21,"("+
  258. rs_x%(add%+1)+","+
  259. rs_y%(add%+1)+","+
  260. rs_z%(add%+1)+")")
  261. Icon_UpText(RotScale_Ybox%,11,"("+
  262. RS_Xstep%+","+
  263. RS_Ystep%+","+
  264. RS_Zstep%+")")
  265. add%=0
  266. Icon_UpState(RotScale_Ybox%,15,1)
  267. Icon_UpState(RotScale_Ybox%,16,0)
  268. Icon_UpState(RotScale_Ybox%,15,0)
  269. Icon_UpState(RotScale_Ybox%,16,1)
  270. add%=(rs_editing%
  271. add%=0
  272. Icon_UpState(RotScale_Ybox%,22,1)
  273. Icon_UpState(RotScale_Ybox%,23,0)
  274. Icon_UpState(RotScale_Ybox%,22,0)
  275. Icon_UpState(RotScale_Ybox%,23,1)
  276. rs_click(win%,icon%,x%,y%,but%)
  277. z%,l%,o%,e%
  278. CurrentMain%
  279. button%
  280. RSClicked%=
  281. ox%=x%:oy%=y%
  282. Display_ConvXY(x%,y%)
  283. --x1%=rs_x%(l%):y1%=rs_y%(l%):z1%=rs_z%(l%)
  284. Display_XYZtoXY(x1%,y1%,z1%)
  285. (x1%-x%)<8
  286. (y1%-y%)<8
  287. rs_editing%=l%
  288. RSClicked%=
  289. RSClicked%
  290. 52RSClicked%=
  291. Display_ClickedOn(ox%,oy%,rs_new%)
  292. RSClicked%
  293. RSClicked%=4:rs_editing%=2
  294. 93RSClicked%=
  295. Display_ClickedOn(ox%,oy%,rs_orig%)
  296. RSClicked%
  297. RSClicked%=
  298. :rs_editing%=0
  299. Display_MoveCursor(rs_x%(rs_editing%),rs_y%(rs_editing%),rs_z%(rs_editing%))
  300. rs_ybox
  301. %100*16
  302. RSClicked%
  303. RSClicked%
  304. Drag_StartLines
  305. o%=(rs_editing%
  306. e%=rs_editing%
  307. x1%=rs_x%(e%+1)
  308. y1%=rs_y%(e%+1)
  309. z1%=rs_z%(e%+1)
  310. x1%=rs_x%(e%-1)
  311. y1%=rs_y%(e%-1)
  312. z1%=rs_z%(e%-1)
  313. Display_XYZtoXY(x1%,y1%,z1%)
  314. Drag_Move(x1%,y1%)
  315. Drag_Draw(&FFFF,&FFFF)
  316. Drag_Node2(&FFFF,&FFFF)
  317. Drag_Node(&FFFF,&FFFF)
  318. T*x%=rs_x%(e%):y%=rs_y%(e%):z%=rs_z%(e%)
  319. Display_XYZtoXY(x%,y%,z%)
  320. Display_Screen(x%,y%)
  321. Drag_ReadyNew(x%,y%,e%,
  322. Drag_Item(rs_new%,RotScale_Ybox%,4,rs_x%(2),rs_y%(2),rs_z%(2))
  323. RotScale_Ybox%
  324. Window_ClickYboxNoSnap(win%,icon%,rs_x%(rs_editing%),rs_y%(rs_editing%),rs_z%(rs_editing%),RS_Xstep%,RS_Ystep%,RS_Zstep%)
  325. CursorOn%=
  326. rs_update
  327. Display_Cursor(rs_x%(rs_editing%),rs_y%(rs_editing%),rs_z%(rs_editing%))
  328. icon%
  329. rs_editing%>1
  330. rs_editing%-=2
  331. Display_MoveCursor(rs_x%(rs_editing%),rs_y%(rs_editing%),rs_z%(rs_editing%))
  332. rs_editing%<2
  333. rs_editing%+=2
  334. Display_MoveCursor(rs_x%(rs_editing%),rs_y%(rs_editing%),rs_z%(rs_editing%))