Previous Getting Started with IDL: Animation Next

Animation with XINTERANIMATE

IDL includes a powerful, widget-based animation tool called XINTERANIMATE. Sometimes it is useful to view a single wire-mesh surface or shaded surface from a number of different angles. Let's make a SURFACE plot from one of the S dataset frames and view it rotating through 360 degrees. by entering:

  1. Save the first frame of the S dataset in the variable A to simplify the next set of commands:
  2. A=S[*,*,0]  
    

     

  3. Create a window in which to display your surface:
  4. WINDOW,0,XSIZE=300,YSIZE=300  
    

     

  5. Display A as a wire-mesh surface:
  6. SURFACE,A,XSTYLE=4,YSTYLE=4,ZSTYLE=4  
    

     

    Setting the XSTYLE, YSTYLE, and ZSTYLE keywords equal to 4 turns axis drawing off. Usually, IDL automatically scales the axes of plots to best display all of the data points sent to the plotting routine. However, for this sequence of images, it is best if each SURFACE plot is drawn with the same size axes. The SCALE3 procedure can be used to control various aspects of the three-dimensional transformation used to display plots.

     

  7. Force the X and Y axis ranges to run from 0 to 32 and the Z axis range to run from 0 to 250:
  8. SCALE3,XRANGE=[0,31],YRANGE=[0,31],ZRANGE=[0,250]  
    

     

  9. Set up the XINTERANIMATE routine to hold 40, 300 by 300 byte images:
  10. XINTERANIMATE,SET=[300,300,40],/SHOWLOAD  
    

     

  11. Return focus to the plot window for the SURFACE calls which follow.
  12. WSET, 0  
    

     

  13. Generate each frame of the animation and store it for the XINTERANIMATE routine. Once a 3-D transformation has been established, most IDL plotting routines can be made to use it by including the T3D keyword. The [XYZ]STYLE keywords are shortened to [XYZ]ST:
  14. FOR I=0,39 DO BEGIN SCALE3,AZ= -i * 9 & SURFACE,A, $
       /T3D,XSTYLE=4,YSTYLE=4,ZSTYLE=4 & XINTERANIMATE,$ 
       FRAME=I,WIN=0 & END  
    

     

  15. Play images back as an animation after all the images have been saved in the XINTERANIMATE routine:
  16. XINTERANIMATE  
    

     

    Figure 11-4: The XINTERANIMATE window

    Figure 11-4: The XINTERANIMATE window

The XINTERANIMATE window should appear, as shown above. "Tape recorder" style controls can be used to play the animation forward, play it backward, or stop. Individual frames can also be selected by moving the "Animation Frame" slider. The "Options" menu controls the style and direction of image playback. Click on "End Animation" when you are ready to return to the IDL Command Line.

Cleaning Up the Animation Windows

Before continuing with the rest of the tutorials, delete the two windows you used to create the animations. The WDELETE procedure is used to delete IDL windows.

  1. Delete both window 0 and window 1 by entering:
  2. WDELETE, 0  
    WDELETE, 1  
    

  IDL Online Help (March 06, 2007)