home *** CD-ROM | disk | FTP | other *** search
/ Maximum 3D 3 / m3d-p3.iso / 3DS_MAX / 3DSMAX.2_0 / SCRIPTS / OLE.MS < prev    next >
Text File  |  1997-10-19  |  2KB  |  80 lines

  1. --     OLE Automation demo
  2. --
  3. --   See the section on OLE Automation in the MAXScript manual
  4. --   (Page 138+) for information on setting up MAX for OLE
  5. --   operation and running this demo script.
  6. --
  7.  
  8. global chart, labels, row_count, col_count
  9.  
  10. function create_chart n_rows n_cols =
  11. (
  12.     row_count = n_rows
  13.     col_count = n_cols
  14.     chart = for i in 1 to n_rows collect
  15.                 for i in 1 to n_cols collect 0.0
  16.     labels = for i in 1 to n_cols collect ""
  17. )
  18.  
  19. function add_value row col val =
  20. (
  21.     chart[row][col] = val
  22. )
  23.  
  24. function add_label col val =
  25. (
  26.     labels[col] = val
  27. )
  28.  
  29. fn make_label txt size:15 pos:[0,0,0] =
  30. (
  31.     local t = text size:size font:"Arial" text:txt rotation:(quat -90 x_axis),
  32.           m = bevel ()
  33.     m.level_1_height = (size / 6)
  34.     addModifier t m
  35.     t.wirecolor = [227,152,152]
  36.     rotate t (quat 90 z_axis * quat 90 x_axis)
  37.     t.pivot = [t.center.x, t.max.y, t.max.z]
  38.     t.pos = pos
  39.     t
  40. )
  41.  
  42. function animate_chart =
  43. (
  44.     local x = -100
  45.     local bars = for col in chart[1] collect
  46.                       box width:20 length:10 height:col pos:[x+=22,0,0]
  47.     x = -100
  48.     for l in labels do make_label l pos:[x+=22,-12,0]   
  49.     local t = 0, dt = 100 / (chart.count - 1)
  50.     animate on
  51.         for row in chart do
  52.         (
  53.             at time t for i in 1 to row.count do bars[i].height = row[i]
  54.             t += dt
  55.         )
  56. )
  57.  
  58. fn render_animation = 
  59. (
  60.     local c = targetCamera pos:[71,-140,224]          \
  61.                 target:(targetObject pos:[-10,-3,10])
  62.     animate on 
  63.         at time 100 
  64.         (
  65.             c.pos = [30,-250,100]
  66.             c.target.pos = [-17,3,28]
  67.         )
  68.     render camera:c framerange:(interval 0f 100f)   \
  69.            outputwidth:320 outputheight:240         \
  70.            outputfile:"chart.avi"
  71. )
  72.  
  73.  
  74. registerOLEInterface #(create_chart,
  75.                        add_value,
  76.                        add_label,
  77.                        animate_chart,
  78.                        render_animation)
  79.  
  80.