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

  1. /* CMD: Follow the Leader
  2.  *
  3.  * creates a scene in which object clones follow a common path
  4.  * copyright © 1995 by Seth Stroh, Tue July 27, 1995
  5.  *
  6.  */
  7.  
  8. NUMERIC DIGITS 6
  9. libadd = addlib("LWModelerARexx.port",0)
  10. signal on error
  11. signal on syntax
  12.  
  13. RexxMathLib = "rexxmathlib.library"
  14. IF POS(RexxMathLib , SHOW('Libraries')) = 0 THEN
  15.   IF ~ADDLIB(RexxMathLib , 0 , -30, 0) THEN DO
  16.     call notify(1,"!Cant find rexxmathlib.library")
  17.     exit
  18.   end
  19.  
  20.  
  21. /* initialise variables */
  22.  
  23. version = 'v0.5'
  24. sysnam = 'Follow the Leader' version
  25. ObjectName = "3D:Objects"
  26. PathName = "3D:Motions"
  27. SceneName = "3D:Scenes"
  28.  
  29. ObjDisso = 2
  30. FadeFram = 15
  31. ObClones = 8
  32. ObOffset = 15
  33. PathLoop = 2
  34.  
  35. /* setup user control panel */
  36.  
  37. Do Forever
  38.     call req_begin sysnam
  39.     id_obds = req_addcontrol("object dissolve",'CH',"none abrupt smooth")
  40.     id_dsfr = req_addcontrol("disolve frames",'n')
  41.     id_clon = req_addcontrol("object clones",'n')
  42.     id_ofst = req_addcontrol("object offset",'n')
  43.     id_nmlp = req_addcontrol("number of loops",'n')
  44.  
  45.     call req_setval id_obds, ObjDisso
  46.     call req_setval id_dsfr, FadeFram
  47.     call req_setval id_clon, ObClones
  48.     call req_setval id_ofst, ObOffset
  49.     call req_setval id_nmlp, PathLoop
  50.  
  51. if (~req_post()) then do
  52.     call req_end
  53.     exit
  54.   end
  55.  
  56.  
  57. /* set variables to match user control panel */
  58.  
  59.     ObjDisso = req_getval(id_obds)
  60.     FadeFram = req_getval(id_dsfr)
  61.     ObClones = req_getval(id_clon)
  62.     ObOffset = req_getval(id_ofst)
  63.     PathLoop = req_getval(id_nmlp)
  64.  
  65.  
  66. /* get object, path, and scene name and check path duration */
  67.  
  68. ObjectName = getfilename("object name",ObjectName)
  69. if ObjectName='(none)' then do
  70.     call req_end
  71.     exit
  72.   end
  73.  
  74. PathName = getfilename("motion path name",PathName)
  75. if PathName='(none)' then do
  76.     call req_end
  77.     exit
  78.   end
  79.  
  80. SceneName = getfilename("scene name",SceneName)
  81. if SceneName='(none)' then do
  82.     call req_end
  83.     exit
  84.   end
  85.  
  86. If open('mpath',PathName,'r')~=1 then do
  87.     call notify(1,"!Cant find path file")
  88.     exit
  89.   end
  90. ptemp = readln('mpath')
  91. if ptemp ~= "LWMO" then do
  92.     call notify(1,"!Not a valid motion path file"
  93.     exit
  94.   end
  95. ptemp = readln('mpath')
  96. ptemp = readln('mpath')
  97.  
  98. PathKeys = readln('mpath')
  99.  
  100. Index = 1
  101. do while Index <= PathKeys
  102.       pdata.Index = readln('mpath')
  103.       pdatb.Index = readln('mpath')
  104.     Index = Index + 1
  105.   end
  106. call close('mpath')
  107.  
  108. PathFrames = Word(pdatb.PathKeys,1)
  109.  
  110. If open(scene,SceneName,'w')~=1 then do
  111.     call notify(1,"!Could not open the scene file")
  112.     exit
  113.   end
  114.  
  115. call startscene
  116. call addnull
  117.  
  118. ObIndex = 1
  119. do while ObIndex <= ObClones
  120.     ObOfs = ObOffset*(ObIndex-1)
  121.       call AddObject
  122.     ObIndex = ObIndex + 1
  123.   end
  124.  
  125. call finishscene
  126. call close('scene')
  127.  
  128. /* thats all folks */
  129.  
  130. exit
  131. call end_all
  132. end /* forever */
  133.  
  134.  
  135. /* subroutines */
  136.  
  137. startscene:    /* open the scene file and make first entries */
  138.   call writeln scene, "LWSC"
  139.   call writeln scene, "1"
  140.   call writeln scene, ""
  141.   call writeln scene, "FirstFrame 1"
  142.   call writeln scene, "LastFrame "||Trunc(PathFrames*PathLoop+ObOffset*(ObClones-1))
  143.   call writeln scene, "FrameStep 1"
  144.   call writeln scene, ""
  145. return
  146.  
  147.  
  148. addnull:    /* add a null object */
  149.   call writeln scene, "AddNullObject Center Point"
  150.   call writeln scene, "ShowObject 4"
  151.   call writeln scene, "ObjectMotion (unnamed)"
  152.   call writeln scene, "  9"
  153.   call writeln scene, "  1"
  154.   call writeln scene, "  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0"
  155.   call writeln scene, "  0 0 0.0 0.0 0.0"
  156.   call writeln scene, "EndBehavior 1"
  157.   call writeln scene, "ShadowOptions 7"
  158. return
  159.  
  160.  
  161. addobject:    /* add an object to the scene file */
  162.   call writeln scene, "LoadObject "||ObjectName
  163.   call writeln scene, "ShowObject 4"
  164.   call writeln scene, "ObjectMotion (unnamed)"
  165.   call writeln scene, "  9"
  166.   call writeln scene, "  "Trunc(PathKeys*PathLoop+1)
  167.  
  168.   call writeln scene, "  "pdata.1
  169.   call writeln scene, "  "pdatb.1
  170.  
  171.   tObOfs = ObOfs
  172.   Loop = 1
  173.   do while Loop <= PathLoop
  174.     Index = 1
  175.     do while Index <= PathKeys
  176.         call writeln scene, "  "pdata.Index
  177.         tempa = word(pdatb.Index,1) + ObOfs
  178.           if Index = 1 then tempa = tempa + 1
  179.         tempb = word(pdatb.Index,2)
  180.         tempc = word(pdatb.Index,3)
  181.         tempd = word(pdatb.Index,4)
  182.         tempe = word(pdatb.Index,5)
  183.         call writeln scene, "  "Trunc(tempa)" "Trunc(tempb)" "tempc" "tempd" "tempe
  184.       Index = Index + 1
  185.       end
  186.     Loop = Loop + 1
  187.     ObOfs = ObOfs + PathFrames
  188.     end
  189.   call writeln scene, "EndBehavior 1"
  190.   call writeln scene, "ParentObject 1"
  191.  
  192.   if ObjDisso = 2 then do
  193.       call writeln scene, "ObjDissolve (envelope)"
  194.       call writeln scene, "  1"
  195.       call writeln scene, "  5"
  196.       call writeln scene, "  1.0"
  197.       call writeln scene, "  0 1 0.0 0.0 0.0"
  198.       call writeln scene, "  1.0"
  199.       call writeln scene, "  "Trunc(tObOfs)" 1 0.0 0.0 0.0"
  200.       call writeln scene, "  0.0"
  201.       call writeln scene, "  "Trunc(tObOfs+1)" 1 0.0 0.0 0.0"
  202.       call writeln scene, "  0.0"
  203.       call writeln scene, "  "Trunc(ObOfs-1)" 1 0.0 0.0 0.0"
  204.       call writeln scene, "  1.0"
  205.       call writeln scene, "  "Trunc(ObOfs)" 1 0.0 0.0 0.0"
  206.       call writeln scene, "EndBehavior 1"
  207.     end
  208.  
  209.   if ObjDisso = 3 then do
  210.       call writeln scene, "ObjDissolve (envelope)"
  211.       call writeln scene, "  1"
  212.       call writeln scene, "  5"
  213.       call writeln scene, "  1.0"
  214.       call writeln scene, "  0 1 0.0 0.0 0.0"
  215.       call writeln scene, "  1.0"
  216.       call writeln scene, "  "Trunc(tObOfs)" 1 0.0 0.0 0.0"
  217.       call writeln scene, "  0.0"
  218.       call writeln scene, "  "Trunc(tObOfs+FadeFram)" 1 0.0 0.0 0.0"
  219.       call writeln scene, "  0.0"
  220.       call writeln scene, "  "Trunc(ObOfs-FadeFram)" 1 0.0 0.0 0.0"
  221.       call writeln scene, "  1.0"
  222.       call writeln scene, "  "Trunc(ObOfs)" 1 0.0 0.0 0.0"
  223.       call writeln scene, "EndBehavior 1"
  224.     end
  225.  
  226.   call writeln scene, "ShadowOptions 7"
  227.   call writeln scene, ""
  228. return
  229.  
  230.  
  231. finishscene:
  232.   call writeln scene, "AmbientColor 255 255 255"
  233.   call writeln scene, "AmbIntensity 0.250000"
  234.   call writeln scene, ""
  235.   call writeln scene, "AddLight"
  236.   call writeln scene, "LightName Light"
  237.   call writeln scene, "ShowLight 0"
  238.   call writeln scene, "LightMotion (unnamed)"
  239.   call writeln scene, "  9"
  240.   call writeln scene, "  1"
  241.   call writeln scene, "  0.0 0.0 0.0 30.000000 45.000000 0.0 1.0 1.0 1.0"
  242.   call writeln scene, "  0 0 0.0 0.0 0.0"
  243.   call writeln scene, "EndBehavior 1"
  244.   call writeln scene, "LightColor 255 255 255"
  245.   call writeln scene, "LgtIntensity 1.000000"
  246.   call writeln scene, "LightType 2"
  247.   call writeln scene, "Falloff 0.000000"
  248.   call writeln scene, "ConeAngle 30.000000"
  249.   call writeln scene, "EdgeAngle 5.000000"
  250.   call writeln scene, "ShadowCasting 1"
  251.   call writeln scene, ""
  252.   call writeln scene, "ShowCamera 1"
  253.   call writeln scene, "CameraMotion (unnamed)"
  254.   call writeln scene, "  9"
  255.   call writeln scene, "  1"
  256.   call writeln scene, "  0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0"
  257.   call writeln scene, "  0 0 0.0 0.0 0.0"
  258.   call writeln scene, "EndBehavior 1"
  259.   call writeln scene, "ZoomFactor 3.200000"
  260.   call writeln scene, "RenderMode 2"
  261.   call writeln scene, "RayTraceEffects 0"
  262.   call writeln scene, "Resolution 1"
  263.   call writeln scene, "Overscan 1"
  264.   call writeln scene, "SegmentMemory 2200000"
  265.   call writeln scene, "Antialiasing 0"
  266.   call writeln scene, "AdaptiveSampling 1"
  267.   call writeln scene, "AdaptiveThreshold 12"
  268.   call writeln scene, "FilmSize 2"
  269.   call writeln scene, "FieldRendering 0"
  270.   call writeln scene, "MotionBlur 0"
  271.   call writeln scene, "DepthOfField 0"
  272.   call writeln scene, ""
  273.   call writeln scene, "SolidBackdrop 1"
  274.   call writeln scene, "BackdropColor 0 0 0"
  275.   call writeln scene, "ZenithColor 0 40 80"
  276.   call writeln scene, "SkyColor 120 180 240"
  277.   call writeln scene, "GroundColor 50 40 30"
  278.   call writeln scene, "NadirColor 100 80 60"
  279.   call writeln scene, "FogType 0"
  280.   call writeln scene, "DitherIntensity 1"
  281.   call writeln scene, "AnimatedDither 0"
  282.   call writeln scene, ""
  283.   call writeln scene, "RenderDisplayDevice 0"
  284.   call writeln scene, "DataOverlayLabel"
  285.   call writeln scene, ""
  286.   call writeln scene, "ViewMode 5"
  287.   call writeln scene, "ViewAimpoint 0.000000 0.000000 0.000000"
  288.   call writeln scene, "ViewDirection 0.000000 0.000000 0.000000"
  289.   call writeln scene, "ViewZoomFactor 3.200000"
  290.   call writeln scene, "LayoutGrid 4"
  291.   call writeln scene, "GridSize 1.000000"
  292.   call writeln scene, "ShowMotionPath 1"
  293.   call writeln scene, "ShowSafeArea 0"
  294.   call writeln scene, "ShowBGImage 0"
  295.   call writeln scene, "ShowFogRadius 0"
  296.   call writeln scene, "ShowRedraw 0"
  297. return
  298.  
  299.  
  300. syntax:    /* tell me where it all went wrong */
  301. error:
  302.    call end_all
  303.    t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL||sourceline(SIGL))
  304.    exit
  305.