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

  1. --Created by:Ravi Karra [ravi.karra@ktx.com]
  2.  
  3. resetMaxFile #noPrompt
  4.  
  5. --size of the enclosing cube for random creation of the dummy
  6. range = 800
  7.  
  8. --num of objects to be placed
  9. num = 20
  10.  
  11. --Create a box and a dummy
  12. b = box length:100 width:100 height:20 
  13. d = dummy pos:(random [-range,-range,-range] [range,range,range])
  14.  
  15. fn linearInterp valueIni valueFin range cur =
  16. (
  17.     valueIni + (valueFin - valueIni)*cur/range
  18. )
  19.  
  20. fn createObjects source target objNum = 
  21. (
  22.     --Create a ray originating from dummy in the direction of box
  23.     ry = ray target.pos (source.pos - target.pos)
  24.  
  25.     --Intersect the ray with the box
  26.     ir = intersectRay source ry
  27.     
  28.     --Create equally spaced objects on the ray 
  29.     rad = (distance source target)/(2*objNum)
  30.     for i = 1 to objNum do
  31.     (
  32.         obj = teapot radius:rad pos:((linearInterp ir.pos target.pos objNum (i-1)))
  33.         obj.dir = ir.dir
  34.     )
  35. )
  36.  
  37. createObjects b d num
  38. for s in $tea* do s.parent = d
  39. d.pivot = b.pos
  40.  
  41. animate on for t in 0 to 100 do at time t
  42. (
  43.     at time 100
  44.     (
  45.         rotate d 360 [0,0,1]        
  46.     )
  47. )
  48.  
  49. max zoomext sel all
  50. max time play