home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Automation / Scripts / Effect - Zoom Enter.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  4.4 KB  |  139 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Mary Obelnicki
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. The following script creates a key frame animation effect on 
  19. the currently selected objects.
  20.  
  21. Function:
  22.     zoomenter(letters, frames, stagger, opacity, rotation, xdiff, ydiff, zdiff, forward, startNow, KFR)
  23.  
  24. Arguments:
  25.     <letters> LMObject - an array of the objects to apply the 
  26.         effect. Does not have to be text objects.  It can be 
  27.         any LMObject.
  28.     <frames> integer - the length of the animation for each 
  29.         object
  30.     <stagger> integer - the number of frames to stagger the 
  31.         start of each animation
  32.     <opacity> integer - the opacity to start at
  33.     <rotation> integer - the rotation to end at
  34.     <xdiff>, <ydiff>, <zdiff> integer - the x,y,z difference 
  35.         from the initial position to end at.  In 3-d space.
  36.     <forward> boolean - stagger from first character or 
  37.         last character
  38.     <KFR> integer - the number of frames between key frames.
  39.  
  40. ***************************************************************/
  41.  
  42. #include "../../Include/Camera.js"
  43.  
  44. /***************************************************************
  45. To change the behavior of this script, make your changes below
  46. ***************************************************************/
  47.  
  48. var objects = application.currentComposition.selection; 
  49. zoomenter(objects, 12, 2, 0, -360, 0, 0, 2000, true, true, 3); 
  50.  
  51. /***************************************************************
  52. DO NOT EDIT BELOW THIS LINE
  53. ***************************************************************/
  54.  
  55. function zoomenter(letters, frames, stagger, opacity, rotation, xdiff, ydiff, zdiff, forward, startNow, KFR)
  56. {
  57.     if(letters.length < 1)
  58.     return; 
  59.     keyFrameRate = KFR; 
  60.     
  61.     // set up the camera
  62.     // this sets the position of the eye at the same x and y as the middle object in the letters array. 
  63.     var midIndex = Math.ceil((letters.length)/2) -1;
  64.     var xe = letters[midIndex].position.x; 
  65.     var ye = letters[midIndex].position.y; 
  66.     var camera = new Camera(new Vector(xe, ye, -1000)); 
  67.     
  68.     // initial conditions
  69.     var frame0;
  70.     if (startNow)
  71.      frame0 = letters[0].currentFrame;
  72.     else
  73.     frame0 = letters[0].currentFrame - (stagger * (letters.length - 1) + frames); 
  74.     
  75.     // deltas per frame
  76.     var dxdf = xdiff/frames; 
  77.     var dydf = ydiff/frames; 
  78.     var dzdf = zdiff/frames;
  79.     
  80.     for (i=0; i < letters.length; i++)
  81.     {
  82.     var cl;
  83.     if (forward)
  84.         cl = letters[i];
  85.     else
  86.         cl = letters[letters.length -1 -i];
  87.     var xo = cl.position.x; 
  88.     var yo = cl.position.y;
  89.     var zo = 0; // allow this as an input parameter? 
  90.     var oriOpacity = cl.opacity; 
  91.     var oriRotation = cl.rotation;
  92.     
  93.     //turn on relevant stopwatches    
  94.     
  95.     if (opacity != oriOpacity)
  96.         cl.stopwatch.opacity = true;     
  97.     if (rotation != oriRotation) 
  98.         cl.stopwatch.rotation = true; 
  99.     
  100.     //I'm going to turn on the relevant stopwatches myself
  101.     camera.perspectiveSetup(cl, false);
  102.     
  103.     if (zdiff == 0)
  104.     {// test xdiff and ydiff
  105.         if((xdiff != 0) || (ydiff != 0))
  106.         cl.stopwatch.position = true; 
  107.     }
  108.     else
  109.     {
  110.         cl.stopwatch.position = true; 
  111.         cl.stopwatch.scale = true; 
  112.     }
  113.     
  114.     //first frame
  115.     cl.currentFrame = frame0 + (i * stagger);
  116.     camera.perspectiveTransform(cl, new Vector(xo+xdiff, yo+ydiff, zo+zdiff));
  117.     cl.opacity = opacity;
  118.     cl.rotation = rotation;
  119.     
  120.     if (zdiff != 0)
  121.         {
  122.         //middle frames
  123.         for(df =0; df < frames; df+=keyFrameRate)
  124.         {
  125.         cl.currentFrame = frame0 + df + (i * stagger); 
  126.         camera.perspectiveTransform(cl, new Vector(xo+xdiff-(dxdf * df), yo+ydiff-(dydf * df), zo+zdiff-(dzdf * df))); 
  127.         }
  128.     }    
  129.     
  130.     //last frame    
  131.     
  132.     cl.currentFrame = frame0 + frames + (i * stagger);
  133.     camera.perspectiveTransform(cl, new Vector(xo, yo, zo));
  134.     cl.opacity = oriOpacity;
  135.     cl.rotation = oriRotation; 
  136.     }
  137. }
  138.  
  139.