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

  1. /* CMD: ½ModifyToSphere                                                 */
  2. /* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
  3.     MacrosName = "ModifyToSphere"
  4. /* Macro Type:                                                          */
  5. /* MODIFIES    * OBJECTS   * SELECTED     * TIME NEEDED                 */
  6. /* Description:                                                         */
  7.  
  8. Info1A = "!Modify To Sphere ©            Information 1 of 2"
  9. Info1B = ""
  10. Info1C = "@This macro reshapes the current object into that"
  11. Info1D = "@of a sphere, spheriod, or circular based object."
  12. Info1E = ""
  13. Info1F = "þ the default CENTER is that of the current obj."
  14. Info1G = "þ the default RADIUS is that of the current obj."
  15. Info1H = "þ each AXIS defaults to off if the obj. is flat "
  16. Info1I = "  on that axis.                                 "
  17. Info1J = "¤ If all are turned on a spheriod is created.   "
  18. Info1K = "¤ If two are turned on a cylidrical shaped      "
  19. Info1L = "  object is the result.                         "
  20. Info1M = "¤ If only one axis is chosen, a bumped or T.V.  "
  21. Info1N = "  screen look is made.                          "
  22.  
  23. Info2A = "!Modify To Sphere ©            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.                                                   /* Add Math Functions */
  46. MATHLIB= "rexxmathlib.library"
  47. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  48.     IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  49.         CALL Notify(1,"!Can't find "MATHLIB)
  50.         IF VT3DLib THEN CALL REMLIB("LWModelerARexx.port")
  51.         EXIT
  52.     END
  53.  
  54. /* -------------------------------------------------------------------- */
  55.                                                /* Retrieving Layer Info */
  56. Box = BoundingBox()
  57. PARSE var Box N X1 X2 Y1 Y2 Z1 Z2
  58.  
  59. IF N = 0 THEN DO
  60.     CALL Notify(1,"!Sorry!","@An object must be present for this macro.")
  61.     CALL Exiting
  62. END
  63.  
  64. CntX = (X1/2)+(X2/2) ; CntY = (Y1/2)+(Y2/2) ; CntZ = (Z1/2)+(Z2/2)
  65. RadX = (X2-X1)/2     ; RadY = (Y2-Y1)/2     ; RadZ = (Z2-Z1)/2
  66.  
  67. IF RadX = 0 THEN ReqAxisX = 0 ; ELSE ReqAxisX = 1
  68. IF RadY = 0 THEN ReqAxisY = 0 ; ELSE ReqAxisY = 1
  69. IF RadZ = 0 THEN ReqAxisZ = 0 ; ELSE ReqAxisZ = 1
  70.  
  71. /* ******************************************************************** */
  72.                                                    /* Main Body Of Code */
  73. CALL MenuRequester
  74. CALL TransformObject
  75. CALL Exiting
  76.  
  77. /* ******************************************************************** */
  78.                                                       /* User Interface */
  79. MenuRequester:
  80.  
  81.     CALL Req_Begin("Modify To Sphere ©        by Brett Hester")
  82.  
  83.     ReqA = Req_AddControl("Center",'V',1)
  84.     ReqB = Req_AddControl("Radius",'V',1)
  85.     ReqC = Req_AddControl("X Axis",'B')
  86.     ReqD = Req_AddControl("Y Axis",'B')
  87.     ReqE = Req_AddControl("Z Axis",'B')
  88.     ReqF = Req_AddControl("",'CH', "Information")
  89.  
  90.     CALL Req_SetVal(ReqA, CntX CntY CntZ)
  91.     CALL Req_SetVal(ReqB, RadX RadY RadZ)
  92.     CALL Req_SetVal(ReqC, ReqAxisX)
  93.     CALL Req_SetVal(ReqD, ReqAxisY)
  94.     CALL Req_SetVal(ReqE, ReqAxisZ)
  95.     CALL Req_SetVal(ReqF, 0)
  96.  
  97.     OKorCancel = Req_Post() ; IF OKorCancel = 0 THEN CALL Exiting
  98.  
  99.     ReqCenter = Req_GetVal(ReqA)
  100.     ReqRadius = Req_GetVal(ReqB)
  101.     ReqAxisX = Req_GetVal(ReqC)
  102.     ReqAxisY = Req_GetVal(ReqD)
  103.     ReqAxisZ = Req_GetVal(ReqE)
  104.     BEHInfo = Req_GetVal(ReqF)
  105.  
  106.     PARSE var ReqCenter CntX CntY CntZ
  107.     PARSE var ReqRadius RadX RadY RadZ
  108.  
  109.     CALL Req_End()
  110.  
  111.     IF BEHInfo = 1 THEN CALL InformationWindows
  112.  
  113. RETURN
  114.  
  115. /* -------------------------------------------------------------------- */
  116.                                                     /* Transform Object */
  117. TransformObject:
  118.  
  119.     N = XFrm_Begin()
  120.     CALL Meter_Begin(N, "Modifing To Spheroid-Based Shape")
  121.     DO i = 1 to N
  122.         PARSE value XFrm_GetPos(i) with X Y Z .
  123.         DX = X - CntX ; DY = Y - CntY ; DZ = Z - CntZ
  124.         D = SQRT(DX * DX + DY * DY + DZ * DZ)
  125.         IF (D ~= 0) THEN DO
  126.             DRadX = RadX / D ; DRadY = RadY / D ; DRadZ = RadZ / D
  127.  
  128.             IF ReqAxisX = 1 THEN X = (DX * DRadX) + CntX
  129.             IF ReqAxisY = 1 THEN Y = (DY * DRadY) + CntY
  130.             IF ReqAxisZ = 1 THEN Z = (DZ * DRadZ) + CntZ
  131.  
  132.             CALL XFrm_SetPos(i, X Y Z)
  133.         END
  134.         CALL Meter_Step()
  135.     END
  136.     CALL Meter_End()
  137.     CALL XFrm_End()
  138.  
  139. RETURN
  140.  
  141. /* -------------------------------------------------------------------- */
  142.                                                               /* Ending */
  143. Exiting:
  144.  
  145.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  146.     EXIT
  147.  
  148. RETURN
  149.  
  150. /* -------------------------------------------------------------------- */
  151.                                                  /* Information Windows */
  152. InformationWindows:
  153.  
  154.     OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N)
  155.     IF OKorCancel = 1 THEN CALL Notify(1, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N)
  156.     CALL MenuRequester
  157.  
  158. RETURN
  159.  
  160. /* -------------------------------------------------------------------- */
  161.                                                       /* Error Handling */
  162. SYNTAX:
  163. ERROR:
  164.  
  165.     ErrCode = RC
  166.     ErrLine = SIGL
  167.     ErrInfo = ERRORTEXT(ErrCode)
  168.  
  169.     Err1 = "!Sorry!"
  170.     Err2 = "An Error has been detected"
  171.     Err3 = "@þ Macro -            "
  172.     Err4 = "@þ Line Number -      "
  173.     Err5 = "@þ Error Code -       "
  174.     Err6 = "@þ Error Description -"
  175.     Err7 = "@¤ Please Inform -    "
  176.     Err8 = '  "Error Notice"     '
  177.     Err9 = "  13032 Copenhill Rd."
  178.     Err10 = "  Dallas, TX. 75240  "
  179.  
  180.     Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)
  181.  
  182. /* -------------------------------------------------------------------- */
  183.                                              /* Advanced Error Handling */
  184.     CALL SETCLIP("ErrorMacro",MacrosName)
  185.     CALL SETCLIP("ErrorLine",ErrLine)
  186.     CALL SETCLIP("ErrorCode",ErrCode)
  187.     CALL SETCLIP("ErrorDesc",ErrInfo)
  188.  
  189.     PARSE SOURCE TempA TempB ErrFile TempC TempD TempE
  190.  
  191.     CALL SETCLIP("ErrorFile",ErrFile)
  192.  
  193. /* -------------------------------------------------------------------- */
  194.  
  195.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  196.     EXIT
  197.