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

  1. /* CMD: ½QuickCone                                                      */
  2. /* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
  3.     MacrosName = "QuickCone"
  4. /* Macro Type:                                                          */
  5. /* CREATES     * OBJECTS   * LAYER NEEDED * SELECTED     * REMEMBERS    */
  6. /* Description:                                                         */
  7.  
  8. Info1A = "!Quick Cone ©                  Information 1 of 2"
  9. Info1B = ""
  10. Info1C = "@This macro will create a cone, using defaults   "
  11. Info1D = "@based on the currently selected and last used   "
  12. Info1E = "@settings.                                       "
  13. Info1F = ""
  14. Info1G = "þ The CENTER defaults to that of the selected.  "
  15. Info1H = "þ The RADIUS defaults to that of the selected.  "
  16. Info1I = "¤ If a radius is zero; then, the radius defaults"
  17. Info1J = "  to the previous settings.                     "
  18. Info1K = "¤ If there are no previous settings; then, the  "
  19. Info1L = "  default radius is one.                        "
  20. Info1M = "þ DIRECTION (- ¼ +) has pointed end in the neg. "
  21. Info1N = "            (- ½ +) has pointed end in the pos. "
  22.  
  23. Info2A = "!Quick Cone ©                  Information 2 of 2"
  24. Info2B = "@               Plug-Ins and Go! ©               "
  25. Info2C = "                           Hester and associates"
  26. Info2D = "                           13032 Copenhill Road "
  27. Info2E = "                           Dallas, Texas 75240  "
  28. Info2F = "@Special Thanks to:                              "
  29. Info2G = "Arnie Cachelin  Henry Ribron    Mark J. Holland "
  30. Info2H = "J. Phil Kelso   Terry Wester    Steven K. Simms "
  31. Info2I = "Kevin DeRita    Greg Glaser     William S. Hawes"
  32. Info2J = "NewTek ©        Commodore ©     INOVAtronics ©  "
  33. Info2K = ""
  34. Info2L = "@This macro represents a lot of time & hard work."
  35. Info2M = "@Encourage people to create new ones and not kill"
  36. Info2N = "@that possibility by stealing those that are out."
  37.  
  38. /* -------------------------------------------------------------------- */
  39.                                      /* Start Error Detection (See End) */
  40. SIGNAL ON ERROR
  41. SIGNAL ON SYNTAX
  42.                                                    /* Address LightWave */
  43. VT3DLib = ADDLIB("LWModelerARexx.port",0)
  44. ADDRESS "LWModelerARexx.port"
  45.  
  46. /* -------------------------------------------------------------------- */
  47.                                                    /* Empty Layer Setup */
  48. CL = CurLayer()
  49. Empty = EmptyLayers()
  50. IF (WORDS(Empty) < 1) THEN DO
  51.     CALL Notify(1, "Sorry!","@An empty layer is needed for this operation.")
  52.     CALL Exiting
  53. END
  54. EL = WORD(Empty, 1)
  55.  
  56. /* -------------------------------------------------------------------- */
  57.                                     /* Reading Global Macro Preferences */
  58. BEHDefaultFilePath = "Sys:"
  59. BEHSettingsSavedTo = "T:"
  60. BEHSpeechAndSound = "1"
  61.  
  62. IF (EXISTS("S:PlugInPrefs")) THEN DO
  63.     IF (~OPEN(PlugInPrefs, "S:PlugInPrefs", 'R')) THEN BREAK
  64.     IF (READLN(PlugInPrefs) ~= "PlugInPrefs") THEN BREAK
  65.     BEHDefaultFilePath = READLN(PlugInPrefs)
  66.     BEHSettingsSavedTo = READLN(PlugInPrefs)
  67.     BEHSpeechAndSound = READLN(PlugInPrefs)
  68.     CALL CLOSE PlugInPrefs
  69. END
  70.  
  71. /* -------------------------------------------------------------------- */
  72.                                             /* Recalling Macro Settings */
  73. ReqAxis = 3
  74. ReqSides = 16
  75. ReqSegs = 1
  76. ReqDir = 1
  77. OptRX = 1 ; OptRX = 1 ; OptRX = 1
  78.  
  79. PrefsFileName = BEHSettingsSavedTo||MacrosName||".PLUG"
  80.  
  81. IF (EXISTS(PrefsFileName)) THEN DO
  82.     IF (~OPEN(PrefsFile, PrefsFileName, 'R')) THEN BREAK
  83.     IF (READLN(PrefsFile) ~= MacrosName) THEN BREAK
  84.  
  85.     ReqAxis = READLN(PrefsFile)
  86.     ReqSides = READLN(PrefsFile)
  87.     ReqSegs = READLN(PrefsFile)
  88.     ReqDir = READLN(PrefsFile)
  89.     PARSE value READLN(PrefsFile) with OptRX OptRY OptRZ
  90.  
  91.     CALL CLOSE(PrefsFile)
  92. END
  93.  
  94. /* -------------------------------------------------------------------- */
  95.                                                    /* Main Body of Code */
  96. CALL Sel_Mode(USER)
  97.  
  98. CALL Copy() ; CALL SetLayer(EL) ; CALL Paste()
  99. PARSE value BoundingBox() with N X1 X2 Y1 Y2 Z1 Z2
  100.  
  101. CX = (X1/2)+(X2/2) ; CY = (Y1/2)+(Y2/2) ; CZ = (Z1/2)+(Z2/2)
  102. RX = (X2-X1)/2     ; RY = (Y2-Y1)/2     ; RZ = (Z2-Z1)/2
  103. IF RX=0 THEN RX=OptRX ; IF RY=0 THEN RY=OptRY ; IF RZ=0 THEN RZ=OptRZ
  104.  
  105. CALL Cut()
  106. CALL SetLayer(CL)
  107.  
  108. /* -------------------------------------------------------------------- */
  109.                                               /* For Information Window */
  110. BEHInfo = 1
  111.                       /* For Coming Back to Main Menu after Info Window */
  112. DO WHILE BEHInfo
  113.  
  114. /* -------------------------------------------------------------------- */
  115.                                                       /* User Interface */
  116.     CALL Req_Begin("Quick Cone ©                    by Brett Hester")
  117.  
  118.     ReqA = Req_AddControl("Center Point",'V',1)
  119.     ReqB = Req_AddControl("Radius",'V',1)
  120.     ReqC = Req_AddControl("Axis",'CH',"    X         Y         Z    ")
  121.     ReqD = Req_AddControl("Sides",'N',0)
  122.     ReqE = Req_AddControl("Segments",'N',0)
  123.     ReqF = Req_AddControl("Direction",'CH',"- ¼ + - ½ +")
  124.     ReqG = Req_AddControl("",'CH', "Information")
  125.  
  126.     CALL Req_SetVal(ReqA, CX CY CZ)
  127.     CALL Req_SetVal(ReqB, RX RY RZ)
  128.     CALL Req_SetVal(ReqC, ReqAxis)
  129.     CALL Req_SetVal(ReqD, ReqSides)
  130.     CALL Req_SetVal(ReqE, ReqSegs)
  131.     CALL Req_SetVal(ReqF, ReqDir)
  132.     CALL Req_SetVal(ReqG, 0)
  133.  
  134.     OKorCancel = Req_Post() ; IF OKorCancel = 0 THEN CALL Exiting
  135.  
  136.     PARSE value Req_GetVal(ReqA) with CX CY CZ
  137.     PARSE value Req_GetVal(ReqB) with RX RY RZ
  138.     ReqAxis = Req_GetVal(ReqC)
  139.     ReqSides = Req_GetVal(ReqD)
  140.     ReqSegs = Req_GetVal(ReqE)
  141.     ReqDir = Req_GetVal(ReqF)
  142.     BEHInfo = Req_GetVal(ReqG)
  143.  
  144.     CALL Req_End()
  145.  
  146.     ReqSides = ABS(TRUNC(ReqSides)) ; ReqSegs = ABS(TRUNC(ReqSegs))
  147.     X1 = CX + RX ; Y1 = CY + RY ; Z1 = CZ + RZ
  148.     X2 = CX - RX ; Y2 = CY - RY ; Z2 = CZ - RZ
  149.  
  150.     IF BEHInfo = 1 THEN CALL InformationWindows
  151.  
  152. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  153.                                                         /* Verify Input */
  154.     OKtoContinue = 0
  155.     IF RX ~= 0 THEN OKtoContinue = OKtoContinue + 1
  156.     IF RY ~= 0 THEN OKtoContinue = OKtoContinue + 1
  157.     IF RZ ~= 0 THEN OKtoContinue = OKtoContinue + 1
  158.     IF OKtoContinue < 2 THEN DO
  159.         CALL Notify(1,"!Sorry!","@At least two radii must not be zero.")
  160.         BEHInfo = 1
  161.     END
  162.  
  163.     IF ReqSides <= 2 THEN DO
  164.         CALL Notify(1,"!Sorry!","@At least three sides must be chosen.")
  165.         ReqSides = 3
  166.         BEHInfo = 1
  167.     END
  168.  
  169.     IF ReqSegs <= 0 THEN DO
  170.         CALL Notify(1,"!Sorry!","@At least one segment must be chosen.")
  171.         ReqSegs = 1
  172.         BEHInfo = 1
  173.     END
  174.  
  175. END
  176.  
  177. /* -------------------------------------------------------------------- */
  178.                                                    /* Creating the Cone */
  179. IF ReqAxis = 1 THEN Axis = "X"
  180. IF ReqAxis = 2 THEN Axis = "Y"
  181. IF ReqAxis = 3 THEN Axis = "Z"
  182.  
  183. IF ReqDir = 1 THEN CALL MakeCone(RX RY RZ, X1, X2, Axis, ReqSides, ReqSegs, CX CY CZ)
  184. IF ReqDir = 2 THEN CALL MakeCone(RX RY RZ, X2, X1, Axis, ReqSides, ReqSegs, CX CY CZ)
  185.  
  186. /* -------------------------------------------------------------------- */
  187.                                             /* Recording Macro Settings */
  188. IF (OPEN(PrefsFile, PrefsFileName, 'W')) THEN DO
  189.     CALL WRITELN(PrefsFile, MacrosName)
  190.  
  191.     CALL WRITELN(PrefsFile, ReqAxis)
  192.     CALL WRITELN(PrefsFile, ReqSides)
  193.     CALL WRITELN(PrefsFile, ReqSegs)
  194.     CALL WRITELN(PrefsFile, ReqDir)
  195.     CALL WRITELN(PrefsFile, RX RY RZ)
  196.  
  197.     CALL CLOSE(PrefsFile)
  198. END
  199.  
  200. CALL Exiting
  201.  
  202. /* -------------------------------------------------------------------- */
  203.                                                               /* Ending */
  204. Exiting:
  205.  
  206.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  207.     EXIT
  208.  
  209. RETURN
  210.  
  211. /* -------------------------------------------------------------------- */
  212.                                                  /* Information Windows */
  213. InformationWindows:
  214.  
  215.     OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N)
  216.     IF OKorCancel = 1 THEN CALL Notify(1, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N)
  217.  
  218. RETURN
  219.  
  220. /* -------------------------------------------------------------------- */
  221.                                                       /* Error Handling */
  222. SYNTAX:
  223. ERROR:
  224.  
  225.     ErrCode = RC
  226.     ErrLine = SIGL
  227.     ErrInfo = ERRORTEXT(ErrCode)
  228.  
  229.     Err1 = "!Sorry!"
  230.     Err2 = "An Error has been detected"
  231.     Err3 = "@þ Macro -            "
  232.     Err4 = "@þ Line Number -      "
  233.     Err5 = "@þ Error Code -       "
  234.     Err6 = "@þ Error Description -"
  235.     Err7 = "@¤ Please Inform -    "
  236.     Err8 = '  "Error Notice"     '
  237.     Err9 = "  13032 Copenhill Rd."
  238.     Err10 = "  Dallas, TX. 75240  "
  239.  
  240.     Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)
  241.  
  242. /* -------------------------------------------------------------------- */
  243.                                              /* Advanced Error Handling */
  244.     CALL SETCLIP("ErrorMacro",MacrosName)
  245.     CALL SETCLIP("ErrorLine",ErrLine)
  246.     CALL SETCLIP("ErrorCode",ErrCode)
  247.     CALL SETCLIP("ErrorDesc",ErrInfo)
  248.  
  249.     PARSE SOURCE TempA TempB ErrFile TempC TempD TempE
  250.  
  251.     CALL SETCLIP("ErrorFile",ErrFile)
  252.  
  253. /* -------------------------------------------------------------------- */
  254.  
  255.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  256.     EXIT
  257.