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

  1. /* CMD: ½CreateLightning                                                */
  2. /* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
  3.     MacrosName = "CreateLightning"
  4. /* Macro Type:                                                          */
  5. /* CREATES     * LAYOUT    * OBJECTS      * LAYER NEEDED * REMEMBERS    */
  6. /* Description:                                                         */
  7.  
  8. Info1A = "!Create Lightning ©            Information 1 of 3"
  9. Info1B = ""
  10. Info1C = "@This macro creates and saves multiple objects & "
  11. Info1D = "@a scene file to go with them. The goal is to add"
  12. Info1E = "@some spark and flare to a scene.                "
  13. Info1F = ""
  14. Info1G = "STYLE is the high & low points of the lightning."
  15. Info1H = '  __/\__ - "Spike"       (100% at the mid-point)'
  16. Info1I = '  _/¯¯\_ - "Transitional"(100% third of the way)'
  17. Info1J = '  _|¯¯|_ - "Constant"    (100% from beg. to end)'
  18. Info1K = "  ( Style is the size of the parenting object. )"
  19. Info1L = "START is the origination point of the lightning."
  20. Info1M = "HEADING & PITCH is the approx. direction to head"
  21. Info1N = "@- -- --- More Information to follow... --- -- - "
  22.  
  23. Info2A = "!Create Lightning ©            Information 2 of 3"
  24. Info2B = ""
  25. Info2C = "OFFSET MIN-MAX is the amount of freedom for the "
  26. Info2D = "  Heading and Pitch in degrees and for the      "
  27. Info2E = "  Distance in whatever unit selected.           "
  28. Info2F = "# OF OBJS. determines how many objs. to create, "
  29. Info2G = "  save, and pull from to get the final effect.  "
  30. Info2H = "# OF BOLTS is the number of bolts that appear to"
  31. Info2I = "  be present in the lightning effect.           "
  32. Info2J = "# OF SEGS. is how many segments or polygons in  "
  33. Info2K = "  each and every lightning bolt.                "
  34. Info2L = "1st & LAST FRM. determine the life of the effect"
  35. Info2M = '@To add the effect to a scene: Select "Objects"  '
  36. Info2N = '@in layout and then choose "Load From Scene".    '
  37.  
  38. Info3A = "!Create Lightning ©            Information 3 of 3"
  39. Info3B = "@               Plug-Ins and Go! ©               "
  40. Info3C = "                           Hester and associates"
  41. Info3D = "                           13032 Copenhill Road "
  42. Info3E = "                           Dallas, Texas 75240  "
  43. Info3F = "@Special Thanks to:                              "
  44. Info3G = "Arnie Cachelin  Henry Ribron    Mark J. Holland "
  45. Info3H = "J. Phil Kelso   Terry Wester    Steven K. Simms "
  46. Info3I = "Kevin DeRita    Greg Glaser     William S. Hawes"
  47. Info3J = "NewTek ©        Commodore ©     INOVAtronics ©  "
  48. Info3K = ""
  49. Info3L = "@This macro represents a lot of time & hard work."
  50. Info3M = "@Encourage people to create new ones and not kill"
  51. Info3N = "@that possibility by stealing those that are out."
  52.  
  53. /* -------------------------------------------------------------------- */
  54.                                      /* Start Error Detection (See End) */
  55. SIGNAL ON ERROR
  56. SIGNAL ON SYNTAX
  57.                                                    /* Address LightWave */
  58. VT3DLib = ADDLIB("LWModelerARexx.port",0)
  59. ADDRESS "LWModelerARexx.port"
  60.                                                   /* Add Math Functions */
  61. MATHLIB= "rexxmathlib.library"
  62. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  63.     IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  64.         CALL Notify(1,"!Sorry,","@Cannot find "||MATHLIB)
  65.         CALL Exiting
  66.     END
  67.                                                /* Add Support Functions */
  68. SupportLib = "rexxsupport.library"
  69. IF POS(SupportLib , SHOW('L')) = 0 THEN
  70.     IF ~ADDLIB(SupportLib , 0 , -30 , 0) THEN DO
  71.         CALL Notify(1,"!Cannot find "SupportLib)
  72.         CALL Exiting
  73.     END
  74.  
  75. /* -------------------------------------------------------------------- */
  76.                                                    /* Empty Layer Setup */
  77. CL = CurLayer()
  78. Empty = EmptyLayers()
  79. IF (WORDS(Empty) < 1) THEN DO
  80.     CALL Notify(1,"Sorry!","!Need an empty layer","for this operation.")
  81.     CALL Exiting
  82. END
  83. EL = WORD(Empty, 1)
  84.  
  85. /* -------------------------------------------------------------------- */
  86.                                     /* Reading Global Macro Preferences */
  87. BEHDefaultFilePath = "Sys:"
  88. BEHSettingsSavedTo = "T:"
  89. BEHSpeechAndSound = "1"
  90.  
  91. IF (EXISTS("S:PlugInPrefs")) THEN DO
  92.     IF (~OPEN(PlugInPrefs, "S:PlugInPrefs", 'R')) THEN BREAK
  93.     IF (READLN(PlugInPrefs) ~= "PlugInPrefs") THEN BREAK
  94.     BEHDefaultFilePath = READLN(PlugInPrefs)
  95.     BEHSettingsSavedTo = READLN(PlugInPrefs)
  96.     BEHSpeechAndSound = READLN(PlugInPrefs)
  97.     CALL CLOSE(PlugInPrefs)
  98. END
  99.  
  100. /* -------------------------------------------------------------------- */
  101.                                                      /* Fixed Variables */
  102. PI = 3.141592653589793238462643
  103. RadToDeg = 180/PI ; DegToRad = PI/180
  104.  
  105. /* -------------------------------------------------------------------- */
  106.                                             /* Recalling Macro Settings */
  107. ReqStyle = 3
  108. ReqX = 0         ; ReqY = 0         ; ReqZ = 0
  109. ReqHeading = 30  ; ReqAngMinH = -45 ; ReqAngMaxH = 45
  110. ReqPitch = 60    ; ReqAngMinP = -45 ; ReqAngMaxP = 45
  111. ReqDistance = 10 ; ReqLngMin = -2.5 ; ReqLngMax = 2.5
  112. ReqObjs = 30     ; ReqBolts = 3     ; ReqSegs = 15
  113. ReqBegFrm = 0
  114. ReqEndFrm = 90
  115. FilePathObj = "Objects"
  116. FilePathScn = "Scenes"
  117. FileName = ""
  118.  
  119. PrefsFileName = BEHSettingsSavedTo||MacrosName||".PLUG"
  120.  
  121. IF (EXISTS(PrefsFileName)) THEN DO
  122.     IF (~OPEN(PrefsFile, PrefsFileName, 'R')) THEN BREAK
  123.     IF (READLN(PrefsFile) ~= MacrosName) THEN BREAK
  124.     
  125.     ReqStyle = READLN(PrefsFile)
  126.     PARSE VALUE READLN(PrefsFile) WITH ReqX ReqY ReqZ
  127.     PARSE VALUE READLN(PrefsFile) WITH ReqHeading ReqAngMinH ReqAngMaxH
  128.     PARSE VALUE READLN(PrefsFile) WITH ReqPitch ReqAngMinP ReqAngMaxP
  129.     PARSE VALUE READLN(PrefsFile) WITH ReqDistance ReqLngMin ReqLngMax
  130.     PARSE VALUE READLN(PrefsFile) WITH ReqObjs ReqBolts ReqSegs
  131.     ReqBegFrm = READLN(PrefsFile)
  132.     ReqEndFrm = READLN(PrefsFile)
  133.     FilePathObj = READLN(PrefsFile)
  134.     FilePathScn = READLN(PrefsFile)
  135.     FileName = READLN(PrefsFile)
  136.  
  137. CALL CLOSE(PrefsFile)
  138. END
  139.  
  140. /* ******************************************************************** */
  141.                                                    /* Main Body Of Code */
  142. CALL MenuRequester
  143. CALL SaveScnReq
  144. CALL SaveObjReq
  145. CALL DefineStyle
  146. CALL SaveSettings
  147. CALL CreationStage
  148. CALL CreateScene
  149. CALL Exiting
  150.  
  151. /* ******************************************************************** */
  152.                                                       /* User Interface */
  153. MenuRequester:
  154.  
  155.     OKtoContinue = 0
  156.     DO UNTIL OKtoContinue = 1
  157.  
  158.         CALL Req_Begin("Create Lightning ©            by Brett Hester")
  159.  
  160.         ReqA = Req_AddControl("Style   ",'CH'," __/\__    _/¯¯\_    _|¯¯|_  ")
  161.         ReqB = Req_AddControl("Start At",'V',"1")
  162.         CALL Req_AddControl("",'T',"           | Min -- Offset -- Max |")
  163.         ReqC = Req_AddControl("Heading ",'V',"0")
  164.         ReqD = Req_AddControl("Pitch   ",'V',"0")
  165.         ReqE = Req_AddControl("Distance",'V',"1")
  166.         CALL Req_AddControl("",'T',"# of Objs.  # of Bolts  # of Segs.")
  167.         ReqF = Req_AddControl("",'V',"0")
  168.         CALL Req_AddControl("",'T',"")
  169.         ReqG = Req_AddControl("First Frm.",'N',"0")
  170.         ReqH = Req_AddControl("Last Frame",'N',"0")
  171.         ReqI = Req_AddControl("",'CH',"Information")
  172.  
  173.         CALL Req_SetVal(ReqA, ReqStyle)
  174.         CALL Req_SetVal(ReqB, ReqX ReqY ReqZ)
  175.         CALL Req_SetVal(ReqC, ReqHeading ReqAngMinH ReqAngMaxH)
  176.         CALL Req_SetVal(ReqD, ReqPitch ReqAngMinP ReqAngMaxP)
  177.         CALL Req_SetVal(ReqE, ReqDistance ReqLngMin ReqLngMax)
  178.         CALL Req_SetVal(ReqF, ReqObjs ReqBolts ReqSegs)
  179.         CALL Req_SetVal(ReqG, ReqBegFrm)
  180.         CALL Req_SetVal(ReqH, ReqEndFrm)
  181.         CALL Req_SetVal(ReqI, 0)
  182.  
  183.         IF Req_Post() = 0 THEN CALL Exiting
  184.  
  185.         ReqStyle = Req_GetVal(ReqA)
  186.         PARSE VALUE Req_GetVal(ReqB) WITH ReqX ReqY ReqZ
  187.         PARSE VALUE Req_GetVal(ReqC) WITH ReqHeading ReqAngMinH ReqAngMaxH
  188.         PARSE VALUE Req_GetVal(ReqD) WITH ReqPitch ReqAngMinP ReqAngMaxP
  189.         PARSE VALUE Req_GetVal(ReqE) WITH ReqDistance ReqLngMin ReqLngMax
  190.         PARSE VALUE Req_GetVal(ReqF) WITH ReqObjs ReqBolts ReqSegs
  191.         ReqBegFrm = Req_GetVal(ReqG)
  192.         ReqEndFrm = Req_GetVal(ReqH)
  193.         BEHInfo = Req_GetVal(ReqI)
  194.  
  195.         CALL Req_End()
  196.  
  197.         OKtoContinue = 1
  198.  
  199.         ReqAngMinH = TRUNC(ReqAngMinH) ; ReqAngMaxH = TRUNC(ReqAngMaxH)
  200.         IF ReqAngMinH > ReqAngMaxH THEN DO
  201.             Temp = ReqAngMaxH
  202.             ReqAngMaxH = ReqAngMinH
  203.             ReqAngMinH = Temp
  204.         END
  205.  
  206.         ReqAngMinP = TRUNC(ReqAngMinP) ; ReqAngMaxP = TRUNC(ReqAngMaxP)
  207.         IF ReqAngMinP > ReqAngMaxP THEN DO
  208.             Temp = ReqAngMaxP
  209.             ReqAngMaxP = ReqAngMinP
  210.             ReqAngMinP = Temp
  211.         END
  212.  
  213.         ReqDistance = ABS(ReqDistance) ; IF ReqDistance = 0 THEN ReqDistance = 1
  214.         IF ReqLngMin > ReqLngMax THEN DO
  215.             Temp = ReqLngMax
  216.             ReqLngMax = ReqLngMin
  217.             ReqLngMin = Temp
  218.         END
  219.  
  220.         SegDistance = ReqDistance/ReqSegs
  221.         SegLngMin = ReqLngMin/ReqSegs
  222.         SegLngMax = ReqLngMax/ReqSegs
  223.  
  224.         ReqObjs = TRUNC(ReqObjs)   ; IF ReqObjs < 1 THEN ReqObjs = 1 
  225.         ReqBolts = TRUNC(ReqBolts) ; IF ReqBolts < 1 THEN ReqBolts = 1
  226.         ReqSegs = TRUNC(ReqSegs)   ; IF ReqSegs < 1 THEN ReqSegs = 1 
  227.  
  228.         ReqBegFrm = ABS(TRUNC(ReqBegFrm)) ; ReqEndFrm = ABS(TRUNC(ReqEndFrm))
  229.         IF ReqBegFrm > ReqEndFrm THEN DO
  230.             Temp = ReqEndFrm
  231.             ReqEndFrm = ReqBegFrm
  232.             ReqBegFrm = Temp
  233.         END
  234.  
  235.         IF BEHInfo = 1 THEN CALL InformationWindows
  236.  
  237.     END
  238.  
  239. RETURN
  240.  
  241. /* -------------------------------------------------------------------- */
  242.                                  /* File Requester for saving the Scene */
  243. SaveScnReq:
  244.  
  245.     OKtoContinue = 0
  246.     DO UNTIL OKtoContinue = 1
  247.         OKtoContinue = 1
  248.         FileReqScn = GetFileName("-- Save Scene --", FilePathScn, FileName)
  249.         IF FileReq = "(none)" THEN CALL Exiting
  250.         FileType = "Scn"
  251.         PARSE VALUE ExtractName(FileReqScn) WITH FilePathScn FileNameScn
  252.     END
  253.  
  254. RETURN
  255.  
  256. /* -------------------------------------------------------------------- */
  257.                                    /* File Requester for saving Objects */
  258. SaveObjReq:
  259.  
  260.     OKtoContinue = 0
  261.     DO UNTIL OKtoContinue = 1
  262.         OKtoContinue = 1
  263.         FileReqObj = GetFileName("-- Save Objects --", FilePathObj, FileName)
  264.         IF FileReq = "(none)" THEN CALL Exiting
  265.         FileType = "Obj"
  266.         PARSE VALUE ExtractName(FileReqObj) WITH FilePathObj FileNameObj
  267.     END
  268.  
  269. RETURN
  270.  
  271. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  272.                                       /* Extract Name, Path, and Verify */
  273. ExtractName:
  274.  
  275.     PARSE ARG FileReq
  276.  
  277.     FileReqLength = LENGTH(FileReq)
  278.     FileDivider = LASTPOS("/",FileReq)
  279.     IF FileDivider = 0 THEN FileDivider = LASTPOS(":",FileReq)
  280.     FileNameLength = FileReqLength - FileDivider
  281.  
  282.     FilePath = STRIP(LEFT(FileReq, FileDivider),"T","/")
  283.     FileName = RIGHT(FileReq, FileNameLength)
  284.  
  285.     IF EXISTS(FilePath) = 0 THEN DO
  286.         OKtoContinue = Notify(3,"!Sorry!",'Directory "'||FilePath||'" not found.',"@Create NEW directory?")
  287.         IF OKtoContinue = 1 THEN CALL MAKEDIR(FilePath)
  288.     END
  289.  
  290.     IF FileType = "Scn" THEN DO
  291.         IF EXISTS(FileReq) = 1 THEN DO
  292.             PARSE VALUE STATEF(FileReq) WITH DirOrFile .
  293.             IF DirOrFile = "DIR" THEN DO
  294.                 CALL Notify(1,"!Sorry!",'@"'||FileReq||'" is not a valid filename.')
  295.                 OKtoContinue = 0
  296.             END
  297.             IF DirOrFile = "FILE" THEN OKtoContinue = Notify(3,"!Warning!","A file with that name already exists.",'@Overwrite "'||FileReq||'" ?')
  298.         END
  299.     END
  300.  
  301.     IF FileType = "Obj" THEN DO
  302.         VerifyA = 1 ; VerifyB = 1
  303.         DO i=1 TO ReqObjs
  304.             IF EXISTS(FileReq||i) = 1 THEN DO
  305.                 PARSE VALUE STATEF(FileReq||i) WITH DirOrFile .
  306.                 IF DirOrFile = "DIR" THEN VerifyA = 0
  307.                 IF DirOrFile = "FILE" THEN VerifyB = 0
  308.             END
  309.         END
  310.         IF VerifyA = 0 THEN DO
  311.             CALL Notify(1,"!Sorry!",'@"'||FileReq||'" is not a valid filename.')
  312.             OKtoContinue = 0
  313.         END
  314.         IF VerifyB = 0 THEN OKtoContinue = Notify(3,"!Warning!","File(s) will be overwritten.","@Overwrite ?")
  315.     END
  316.  
  317. RETURN FilePath FileName
  318.  
  319. /* -------------------------------------------------------------------- */
  320.                                              /* Define Lightning Length */
  321. DefineStyle:
  322.  
  323.     FrmDiff = (ReqEndFrm-ReqBegFrm)+1
  324.                                                         /* Spike __/\__ */
  325.     IF ReqStyle = 1 THEN DO
  326.         MidPoint = TRUNC(ReqBegFrm+(FrmDiff/2))
  327.         IF ReqBegFrm = 0 THEN DO
  328.             Keys = 3
  329.             Key.1 = ReqBegFrm ; Lng.1 = 0.0
  330.             Key.2 = MidPoint  ; Lng.2 = 1.0
  331.             Key.3 = ReqEndFrm ; Lng.3 = 0.0
  332.         END
  333.         IF ReqBegFrm ~= 0 THEN DO
  334.             Keys = 4
  335.             Key.1 = 0         ; Lng.1 = 0.0
  336.             Key.2 = ReqBegFrm ; Lng.2 = 0.0
  337.             Key.3 = MidPoint  ; Lng.3 = 1.0
  338.             Key.4 = ReqEndFrm ; Lng.4 = 0.0
  339.         END
  340.     END
  341.                                                  /* Transitional _/¯¯\_ */
  342.     IF ReqStyle = 2 THEN DO
  343.         OneThirds = TRUNC(ReqBegFrm+(FrmDiff/3))
  344.         TwoThirds = TRUNC(ReqEndFrm-(FrmDiff/3))
  345.         IF ReqBegFrm = 0 THEN DO
  346.             Keys = 4
  347.             Key.1 = ReqBegFrm ; Lng.1 = 0.0
  348.             Key.2 = OneThirds ; Lng.2 = 1.0
  349.             Key.3 = TwoThirds ; Lng.3 = 1.0
  350.             Key.4 = ReqEndFrm ; Lng.4 = 0.0
  351.         END
  352.         IF ReqBegFrm ~= 0 THEN DO
  353.             Keys = 5
  354.             Key.1 = 0         ; Lng.1 = 0.0
  355.             Key.2 = ReqBegFrm ; Lng.2 = 0.0
  356.             Key.3 = OneThirds ; Lng.3 = 1.0
  357.             Key.4 = TwoThirds ; Lng.4 = 1.0
  358.             Key.5 = ReqEndFrm ; Lng.5 = 0.0
  359.         END
  360.     END
  361.                                                      /* Constant _|¯¯|_ */
  362.     IF ReqStyle = 3 THEN DO
  363.         IF ReqBegFrm <= 1 THEN DO
  364.             Keys = 3
  365.             Key.1 = ReqBegFrm   ; Lng.1 = 1.0
  366.             Key.2 = ReqEndFrm   ; Lng.2 = 1.0
  367.             Key.3 = ReqEndFrm+1 ; Lng.3 = 0.0
  368.         END
  369.         IF ReqBegFrm > 1 THEN DO
  370.             Keys = 5
  371.             Key.1 = 0           ; Lng.1 = 0.0
  372.             Key.2 = ReqBegFrm-1 ; Lng.2 = 0.0
  373.             Key.3 = ReqBegFrm   ; Lng.3 = 1.0
  374.             Key.4 = ReqEndFrm   ; Lng.4 = 1.0
  375.             Key.5 = ReqEndFrm+1 ; Lng.5 = 0.0
  376.         END
  377.     END
  378.  
  379. RETURN
  380.  
  381. /* -------------------------------------------------------------------- */
  382.                                                         /* Creation Hub */
  383. CreationStage:
  384.  
  385.     CALL SetLayer(EL)
  386.                                                      /* Loading Surface */
  387.     OrigSurf = CurSurface()
  388.     IF EXISTS("Objects/PlugInLightning") = 1 THEN DO
  389.         CALL Load("Objects/PlugInLightning")
  390.         CALL Cut()
  391.     END
  392.     CALL Surface("Lightning")
  393.                                               /* Creating Random Factor */
  394.     Seed = TIME("S")
  395.  
  396.     DO Obj=1 TO ReqObjs
  397.         CALL Meter_Begin(ReqSegs,"Creating Lightning Bolt" Obj "of" ReqObjs, "   Please Wait...")
  398.         CALL Add_Begin()
  399.  
  400.         NewPnt = Add_Point(ReqX ReqY ReqZ)
  401.         CALL MakeBolt(0 NewPnt ReqX ReqY ReqZ ReqHeading ReqPitch)
  402.  
  403.         CALL Add_End()
  404.         CALL Meter_End()
  405.  
  406.         CALL Save(FileReqObj||Obj)
  407.         CALL Cut()
  408.     END
  409.                                                   /* Restoring Settings */
  410.     CALL Surface(OrigSurf)
  411.     CALL SetLayer(CL)
  412.  
  413. RETURN
  414.  
  415. /* -------------------------------------------------------------------- */
  416.                                                        /* Creating Bolt */
  417. MakeBolt: PROCEDURE EXPOSE ReqHeading ReqPitch SegDistance SegLngMin SegLngMax ReqAngMinH ReqAngMaxH ReqAngMinP ReqAngMaxP ReqSegs Seed DegToRad MacrosName
  418.  
  419.     PARSE ARG Gen OldPnt X Y Z H P .
  420.  
  421.     IF Gen < ReqSegs THEN DO
  422.         CALL Meter_Step()
  423.  
  424.         PARSE VALUE Calculations(X Y Z H P) WITH X Y Z H P
  425.         NewPnt = Add_Point(X Y Z)
  426.         CALL Add_Polygon(OldPnt NewPnt)
  427.  
  428.         CALL MakeBolt(Gen+1 NewPnt X Y Z H P)
  429.     END
  430.  
  431. RETURN
  432.  
  433. /* -------------------------------------------------------------------- */
  434.                                                         /* Calculations */
  435. Calculations:
  436.  
  437.     PARSE ARG X Y Z H P .
  438.                                       /**********************************/
  439.     OrigAngH = 25 ; LastAngH = 75      /* These four percentages allow   */
  440.     OrigAngP = 25 ; LastAngP = 75      /* for more customized lightning. */
  441.                                       /**********************************/
  442.  
  443.     H = ((ReqAngMaxH-ReqAngMinH) * RANDU(Seed)) + ReqAngMinH + ((ReqHeading*(OrigAngH*0.01))+(H*(LastAngH*0.01)))
  444.     P = ((ReqAngMaxP-ReqAngMinP) * RANDU(Seed)) + ReqAngMinP + ((ReqPitch*(OrigAngP*0.01))+(P*(LastAngP*0.01)))
  445.     D = SegDistance + (SegLngMin+((SegLngMax-SegLngMin) * RANDU(Seed)))
  446.  
  447.     Skew = D * COS((P * DegToRad))
  448.  
  449.     X = (Skew * SIN((H * DegToRad))) + X
  450.     Y = ((D * SIN((P * DegToRad))) * -1) + Y
  451.     Z = (Skew * COS((H * DegToRad))) + Z
  452.  
  453. RETURN X Y Z H P
  454.  
  455. /* -------------------------------------------------------------------- */
  456.                                         /* Creating / Saving Scene File */
  457. CreateScene:
  458.  
  459.     OKtoContinue = 0
  460.     DO UNTIL OKtoContinue = 1
  461.         OKtoContinue = OPEN(NewFile, FileReqScn, 'W')
  462.         IF OKtoContinue = 0 THEN DO
  463.             CALL Notify(1,"!Sorry!",'@Unable to save "'||FileReqScn||'"')
  464.             CALL SaveScnReq
  465.         END
  466.     END
  467.  
  468.     ObjNumber = 0
  469.     ObjLimit = ReqObjs
  470.     MorphStep = 1
  471.     IF ReqObjs > FrmDiff THEN ObjLimit = FrmDiff
  472.     IF ReqObjs > 1 THEN MorphStep = (FrmDiff-1)/(ObjLimit-1)
  473.  
  474.     CALL Meter_Begin((ObjLimit*ReqBolts)+ReqObjs,"Saving Scene File", "   Please Wait...")
  475.  
  476.     MainObjList = ""
  477.     DO Obj = 1 TO ReqObjs
  478.         MainObjList = MainObjList Obj
  479.         CALL Meter_Step()
  480.     END
  481.  
  482.     CALL WRITELN(NewFile, "LWSC")
  483.     CALL WRITELN(NewFile, "1")
  484.     CALL WRITELN(NewFile, "")
  485.     CALL WRITELN(NewFile, "FirstFrame" ReqBegFrm)
  486.     CALL WRITELN(NewFile, "LastFrame" ReqEndFrm)
  487.     CALL WRITELN(NewFile, "FrameStep 1")
  488.     CALL WRITELN(NewFile, "")
  489.     IF EXISTS("Objects/PlugInLightning") = 1 THEN DO
  490.         CALL WRITELN(NewFile, "LoadObject Objects/PlugInLightning")
  491.         CALL WRITELN(NewFile, "ObjectMotion (unnamed)")
  492.         CALL WRITELN(NewFile, "  9")
  493.         CALL WRITELN(NewFile, "  "||Keys)
  494.         DO i=1 TO Keys
  495.             CALL WRITELN(NewFile, "  0.0 0.0 0.0 0.0 0.0 0.0" Lng.i Lng.i Lng.i)
  496.             CALL WRITELN(NewFile, "  "||Key.i||" 0 0.0 0.0 0.0")
  497.         END
  498.         CALL WRITELN(NewFile, "EndBehavior 1")
  499.         CALL WRITELN(NewFile, "ShadowOptions 7")
  500.         CALL WRITELN(NewFile, "")
  501.         ObjNumber = 1
  502.     END
  503.     DO Bolt = 1 TO ReqBolts
  504.         ObjList = MainObjList
  505.         DO Obj = 1 TO ObjLimit
  506.             ObjNumber = ObjNumber + 1
  507.             RndNum = RANDOM(1,WORDS(ObjList),Seed)
  508.             RndObj = WORD(ObjList,RndNum)
  509.             ObjList = DELWORD(ObjList,RndNum,1)
  510.             CALL Meter_Step()
  511.  
  512.             CALL WRITELN(NewFile, "LoadObject" FileReqObj||RndObj)
  513.             CALL WRITELN(NewFile, "ObjectMotion (unnamed)")
  514.             CALL WRITELN(NewFile, "  9")
  515.             IF ObjNumber = 1 THEN DO
  516.                 CALL WRITELN(NewFile, "  "||Keys)
  517.                 DO i = 1 TO Keys
  518.                     CALL WRITELN(NewFile, "  0.0 0.0 0.0 0.0 0.0 0.0" Lng.i Lng.i Lng.i)
  519.                     CALL WRITELN(NewFile, "  "||Key.i||" 0 0.0 0.0 0.0")
  520.                 END
  521.             END
  522.             IF ObjNumber ~= 0 THEN DO
  523.                 CALL WRITELN(NewFile, "  1")
  524.                 CALL WRITELN(NewFile, "  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0")
  525.                 CALL WRITELN(NewFile, "  0 0 0.0 0.0 0.0")
  526.             END
  527.             CALL WRITELN(NewFile, "EndBehavior 1")
  528.             IF ObjNumber ~= 1 THEN CALL WRITELN(NewFile, "ParentObject 1")
  529.             CALL WRITELN(NewFile, "Metamorph (envelope)")
  530.             CALL WRITELN(NewFile, "  1")
  531.             IF Obj = 1 THEN DO
  532.                 CALL WRITELN(NewFile, "  2")
  533.             END
  534.             IF Obj ~= 1 THEN DO
  535.                 CALL WRITELN(NewFile, "  3")
  536.                 CALL WRITELN(NewFile, "  0.0")
  537.                 CALL WRITELN(NewFile, "  0 1 0.0 0.0 0.0")
  538.             END
  539.             CALL WRITELN(NewFile, "  0.0")
  540.             CALL WRITELN(NewFile, "  "||TRUNC(MorphStep*(Obj-1))||" 1 0.0 0.0 0.0")
  541.             CALL WRITELN(NewFile, "  1.0")
  542.             CALL WRITELN(NewFile, "  "||TRUNC(MorphStep*Obj)||" 1 0.0 0.0 0.0")
  543.             CALL WRITELN(NewFile, "EndBehavior 1")
  544.             CALL WRITELN(NewFile, "MorphTarget" ObjNumber+1)
  545.             CALL WRITELN(NewFile, "MorphSurfaces 0")
  546.             IF Obj ~= 1 THEN CALL WRITELN(NewFile, "ObjDissolve 1.000000")
  547.             CALL WRITELN(NewFile, "ShadowOptions 7")
  548.             CALL WRITELN(NewFile, "")
  549.         END
  550.     END
  551.     CALL WRITELN(NewFile, "AmbientColor 255 255 255")
  552.     CALL WRITELN(NewFile, "AmbIntensity 0.250000")
  553.     CALL WRITELN(NewFile, "")
  554.     CALL WRITELN(NewFile, "CameraMotion (unnamed)")
  555.     CALL WRITELN(NewFile, "  9")
  556.     CALL WRITELN(NewFile, "  1")
  557.     CALL WRITELN(NewFile, "  0.0 0.0 -1.0 0.0 0.0 0.0 1.0 1.0 1.0")
  558.     CALL WRITELN(NewFile, "  0 0 0.0 0.0 0.0")
  559.     CALL WRITELN(NewFile, "EndBehavior 1")
  560.     CALL WRITELN(NewFile, "ZoomFactor 3.200000")
  561.     CALL WRITELN(NewFile, "RenderMode 2")
  562.     CALL WRITELN(NewFile, "RayTraceEffects 0")
  563.     CALL WRITELN(NewFile, "Resolution 1")
  564.     CALL WRITELN(NewFile, "Overscan 1")
  565.     CALL WRITELN(NewFile, "Antialiasing 0")
  566.     CALL WRITELN(NewFile, "AdaptiveSampling 1")
  567.     CALL WRITELN(NewFile, "AdaptiveThreshold 8")
  568.     CALL WRITELN(NewFile, "FilmSize 2")
  569.     CALL WRITELN(NewFile, "FieldRendering 0")
  570.     CALL WRITELN(NewFile, "MotionBlur 0")
  571.     CALL WRITELN(NewFile, "DepthOfField 0")
  572.     CALL WRITELN(NewFile, "")
  573.     CALL WRITELN(NewFile, "SolidBackdrop 1")
  574.     CALL WRITELN(NewFile, "BackdropColor 0 0 0")
  575.     CALL WRITELN(NewFile, "ZenithColor 0 40 80")
  576.     CALL WRITELN(NewFile, "SkyColor 120 180 240")
  577.     CALL WRITELN(NewFile, "GroundColor 50 40 30")
  578.     CALL WRITELN(NewFile, "NadirColor 100 80 60")
  579.     CALL WRITELN(NewFile, "FogType 0")
  580.     CALL WRITELN(NewFile, "DitherIntensity 1")
  581.     CALL WRITELN(NewFile, "AnimatedDither 0")
  582.     CALL WRITELN(NewFile, "")
  583.     CALL WRITELN(NewFile, "ViewMode 3")
  584.     CALL WRITELN(NewFile, "ViewAimpoint 0.000000 0.000000 0.000000")
  585.     CALL WRITELN(NewFile, "ViewDirection 0.000000 0.000000 0.000000")
  586.     CALL WRITELN(NewFile, "ViewZoomFactor 3.200000")
  587.     CALL WRITELN(NewFile, "LayoutGrid 3")
  588.     CALL WRITELN(NewFile, "GridSize 1.000000")
  589.     CALL WRITELN(NewFile, "ShowObjects 1")
  590.     CALL WRITELN(NewFile, "ShowBones 1")
  591.     CALL WRITELN(NewFile, "ShowLights 0")
  592.     CALL WRITELN(NewFile, "ShowCamera 1")
  593.     CALL WRITELN(NewFile, "ShowMotionPath 1")
  594.     CALL WRITELN(NewFile, "ShowSafeAreas 0")
  595.     CALL WRITELN(NewFile, "ShowBGImage 0")
  596.     CALL WRITELN(NewFile, "ShowFogRadius 0")
  597.     CALL WRITELN(NewFile, "ShowRedraw 0")
  598.  
  599.     CALL CLOSE(NewFile)
  600.  
  601.     CALL Meter_End()
  602.  
  603. RETURN
  604.  
  605. /* -------------------------------------------------------------------- */
  606.                                             /* Recording Macro Settings */
  607. SaveSettings:
  608.  
  609.     IF (OPEN(PrefsFile, PrefsFileName, 'W')) THEN DO
  610.         CALL WRITELN(PrefsFile, MacrosName)
  611.  
  612.         CALL WRITELN(PrefsFile, ReqStyle)
  613.         CALL WRITELN(PrefsFile, ReqX ReqY ReqZ)
  614.         CALL WRITELN(PrefsFile, ReqHeading ReqAngMinH ReqAngMaxH)
  615.         CALL WRITELN(PrefsFile, ReqPitch ReqAngMinP ReqAngMaxP)
  616.         CALL WRITELN(PrefsFile, ReqDistance ReqLngMin ReqLngMax)
  617.         CALL WRITELN(PrefsFile, ReqObjs ReqBolts ReqSegs)
  618.         CALL WRITELN(PrefsFile, ReqBegFrm)
  619.         CALL WRITELN(PrefsFile, ReqEndFrm)
  620.         CALL WRITELN(PrefsFile, FilePathObj)
  621.         CALL WRITELN(PrefsFile, FilePathScn)
  622.         CALL WRITELN(PrefsFile, FileName)
  623.  
  624.         CALL CLOSE(PrefsFile)
  625.     END
  626.  
  627. RETURN
  628.  
  629. /* -------------------------------------------------------------------- */
  630.                                                               /* Ending */
  631. Exiting:
  632.  
  633.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  634.     EXIT
  635.  
  636. RETURN
  637.  
  638. /* -------------------------------------------------------------------- */
  639.                                                  /* Information Windows */
  640. InformationWindows:
  641.  
  642.     OKtoContinue = 0
  643.     OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N)
  644.     IF OKorCancel = 1 THEN OKorCancel = Notify(2, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N)
  645.     IF OKorCancel = 1 THEN CALL Notify(1, Info3A, Info3B, Info3C, Info3D, Info3E, Info3F, Info3G, Info3H, Info3I, Info3J, Info3K, Info3L, Info3M, Info3N)
  646.  
  647. RETURN
  648.  
  649. /* -------------------------------------------------------------------- */
  650.                                                       /* Error Handling */
  651. SYNTAX:
  652. ERROR:
  653.  
  654.     ErrCode = RC
  655.     ErrLine = SIGL
  656.     ErrInfo = ERRORTEXT(ErrCode)
  657.  
  658.     Err1 = "!Sorry!"
  659.     Err2 = "An Error has been detected"
  660.     Err3 = "@þ Macro -            "
  661.     Err4 = "@þ Line Number -      "
  662.     Err5 = "@þ Error Code -       "
  663.     Err6 = "@þ Error Description -"
  664.     Err7 = "@¤ Please Inform -    "
  665.     Err8 = '  "Error Notice"     '
  666.     Err9 = "  13032 Copenhill Rd."
  667.     Err10 = "  Dallas, TX. 75240  "
  668.  
  669.     Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)
  670.  
  671. /* -------------------------------------------------------------------- */
  672.                                              /* Advanced Error Handling */
  673.     CALL SETCLIP("ErrorMacro",MacrosName)
  674.     CALL SETCLIP("ErrorLine",ErrLine)
  675.     CALL SETCLIP("ErrorCode",ErrCode)
  676.     CALL SETCLIP("ErrorDesc",ErrInfo)
  677.  
  678.     PARSE SOURCE TempA TempB ErrFile TempC TempD TempE
  679.  
  680.     CALL SETCLIP("ErrorFile",ErrFile)
  681.  
  682. /* -------------------------------------------------------------------- */
  683.  
  684.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  685.     EXIT
  686.