home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / OTTSPAR1.DMS / in.adf / LWMmacros / Pathfreezer.lwm < prev    next >
Encoding:
Text File  |  1994-03-03  |  2.1 KB  |  89 lines

  1. /* CMD: Freeze Motion
  2.  * Freezes Motion File so there is a key at every frame. All points in layer
  3.  * are used in the order they were created if you are using v3.1 modeler
  4.  * By Arnie Cachelin © 1993 NewTek Inc. Modified By Jon Tindall 2-18-94
  5.  */
  6.  
  7. NUMERIC DIGITS 6
  8. call addlib "LWModelerARexx.port", 0
  9. call addlib "rexxsupport.library", 0, -30, 0
  10. signal on error
  11. signal on syntax
  12. sysnam = 'Freeze motion '
  13. curlay=CurrentLayer
  14. elay=Emptylayers()
  15. Call setLayer(word(elay,1))
  16. LFile.name=getfilename("-- Load Envelope --","Motions")
  17. if LFile ="(none)" then exit
  18.    call Add_Begin()
  19.    call Add_point 0 0 0
  20.    call Add_end
  21.    if open(infile,LFile.name,'R') then do
  22.        Do i = 1 to 4
  23.            keyqty = readln(infile)
  24.        End
  25.        do i = 1 to (keyqty*2)
  26.            lastkey = readln(infile)
  27.        end
  28. call close infile
  29. end
  30. call Pathclone(LFile.name,1,0, Word(lastkey,1) )        /* name step start end    */
  31.  
  32. File.name=getfilename("-- Save Envelope --","Motions:")
  33. if File.name ="(none)" then exit
  34.  
  35. h=0; p=0; b=0
  36. xsc=1; ysc=1; zsc=1
  37. File.type="LWMO"
  38. n = xfrm_begin()
  39.  
  40.   Keys=n
  41.   KeySpacing=1 /* (Frames/Keys)%1+1 */
  42.   call WriteHeader(mot,keys)
  43.   do i=1 to n
  44.     parse value xfrm_getpos(i) with x y z .
  45.     k=(i-1)
  46.     call WriteKey(mot,k,0)
  47.     end
  48. call xfrm_end
  49. call close mot
  50. call cut
  51. call notify(1,'!Created Motion File: 'File.name)
  52.  
  53. Call setlayer(curlay)
  54.  
  55. exit
  56.  
  57. WriteKey:  PROCEDURE  EXPOSE x y z h p b xsc ysc zsc
  58.   arg MotFile, frame, lin
  59.   channels=x y z h p b xsc ysc zsc
  60.   spline=frame lin "0.0 0.0 0.0"
  61.   say channels spline
  62.   call writeln(MotFile,channels)
  63.   call writeln(MotFile,spline)
  64.   return frame
  65.  
  66. WriteHeader: PROCEDURE EXPOSE File.
  67.   arg MotFile, Keys
  68.   if open(MotFile,File.name,'W') then do
  69.     call writeln(MotFile,File.type)
  70.     call writeln(MotFile,"1") /* magic # */
  71.     call writeln(MotFile,"9") /* Channels */
  72.     call writeln(MotFile,Keys)
  73.   end
  74.   else do
  75.     Bummer("Can't open Motion file : "File.name)
  76.   end
  77.   return 1
  78.  
  79. Bummer:
  80.  ARG etxt
  81.    t=Notify(1,'!Rexx Script Error','@'ETxt)
  82.  exit
  83.  
  84. syntax:
  85. error:
  86.   call end_all
  87.    t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  88.    exit
  89.