home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 January / pcw-0195.iso / polyray / dat / animate / cannon / cannon.pi < prev    next >
Encoding:
Text File  |  1994-12-31  |  5.1 KB  |  164 lines

  1. // Cannon fires several balls
  2. //
  3. // Demonstrates static variables, and parabolic paths with bounces
  4. //
  5. // Polyray input file - Alexander Enzmann
  6.  
  7. // Define the range of the animation
  8. start_frame  0
  9. end_frame    350
  10. total_frames 350
  11. outfile can
  12.  
  13. // Set up the camera
  14. viewpoint {
  15.    from <0,10,-20>
  16.    at <0,0,2>
  17.    up <0, 1, 0>
  18.    angle 45
  19.    resolution 256, 128
  20.    aspect 2
  21.    }
  22.  
  23. // Set up background color & lights
  24. background midnightblue
  25. light 0.7*white, <-10,20,-10>
  26. light 0.7*white, < 10,20,-10>
  27.  
  28. include "..\..\colors.inc"
  29.  
  30. define copper <0.72, 0.45, 0.20>
  31. define brass <0.71, 0.65, 0.26>
  32.  
  33. define Silver texture { shiny { color 0.7*white } }
  34. define Copper texture { shiny { color copper } }
  35. define Brass texture { shiny { color brass } }
  36.  
  37. if (frame == start_frame)
  38.    include "cannon.inc"
  39.  
  40. // Cannon alignment
  41. if (frame < 10)
  42.    // Align the cannon with the direction of the first shot
  43.    define CTx transform { rotate <0, 0, 6*frame> rotate <0, -6*frame, 0> }
  44. else if (frame < 40)
  45.    define CTx transform { rotate <0, 0, 60> rotate <0, -60, 0> }
  46. else if (frame < 50)
  47.    // Realign the cannon for the second shot
  48.    define CTx transform { rotate <0, 0, 60> rotate <0, -60+3*(frame-40), 0> }
  49. else if (frame < 80)
  50.    define CTx transform { rotate <0, 0, 60> rotate <0, -30, 0> }
  51. else if (frame < 90)
  52.    // Realign the cannon for the third shot
  53.    define CTx transform { rotate <0, 0, 60-1.5*(frame-80)>
  54.               rotate <0, -30-1.5*(frame-80)> }
  55. else if (frame < 120)
  56.    define CTx transform { rotate <0, 0, 45> rotate <0, -45, 0> }
  57. else if (frame < 130)
  58.    // Realign the cannon for the fourth shot
  59.    define CTx transform { rotate <0, 0, 45-1.5*(frame-120)>
  60.               rotate <0, -45-3*(frame-120)> }
  61. else if (frame < 160)
  62.    define CTx transform { rotate <0, 0, 30> rotate <0, -75, 0> }
  63. else if (frame < 170)
  64.    // Realign the cannon for the fifth shot
  65.    define CTx transform { rotate <0, 0, 30+1.5*(frame-160)>
  66.               rotate <0, -75+6*(frame-160)> }
  67. else if (frame < 200)
  68.    define CTx transform { rotate <0, 0, 45> rotate <0, -15, 0> }
  69. else if (frame < 210)
  70.    // Realign the cannon for the sixth shot
  71.    define CTx transform { rotate <0, 0, 45-1.5*(frame-200)>
  72.               rotate <0, -15-3*(frame-200), 0> }
  73. else
  74.    // Final orientation
  75.    define CTx transform { rotate <0, 0, 30> rotate <0,-45, 0> }
  76.  
  77. // Build the cannon, orient it, and position it
  78. Cannon { CTx translate CPos }
  79.  
  80. // Projectiles
  81. if (frame == 11)
  82.    static define Ball1_Pos CPos+4*Ball1_Vel
  83. else if (frame > 11) {
  84.    static define Ball1_Pos Ball1_Pos + Ball1_Vel
  85.    static define Ball1_Vel Ball1_Vel + Gravity
  86.    if (Ball1_Pos[1] < -1) {
  87.       static define Ball1_Pos <Ball1_Pos[0], -2 - Ball1_Pos[1], Ball1_Pos[2]>
  88.       static define Ball1_Vel <Ball1_Vel[0], -0.7*Ball1_Vel[1], Ball1_Vel[2]>
  89.       }
  90.    }
  91. Projectile { translate Ball1_Pos }
  92.  
  93. if (frame == 51)
  94.    static define Ball2_Pos CPos+4*Ball2_Vel
  95. else if (frame > 51) {
  96.    static define Ball2_Pos Ball2_Pos + Ball2_Vel
  97.    static define Ball2_Vel Ball2_Vel + Gravity
  98.    if (Ball2_Pos[1] < -1) {
  99.       static define Ball2_Pos <Ball2_Pos[0], -2 - Ball2_Pos[1], Ball2_Pos[2]>
  100.       static define Ball2_Vel <Ball2_Vel[0], -0.7*Ball2_Vel[1], Ball2_Vel[2]>
  101.       }
  102.    }
  103. Projectile { translate Ball2_Pos }
  104.  
  105. if (frame == 91)
  106.    static define Ball3_Pos CPos+4*Ball3_Vel
  107. else if (frame > 91) {
  108.    static define Ball3_Pos Ball3_Pos + Ball3_Vel
  109.    static define Ball3_Vel Ball3_Vel + Gravity
  110.    if (Ball3_Pos[1] < -1) {
  111.       static define Ball3_Pos <Ball3_Pos[0], -2 - Ball3_Pos[1], Ball3_Pos[2]>
  112.       static define Ball3_Vel <Ball3_Vel[0], -0.7*Ball3_Vel[1], Ball3_Vel[2]>
  113.       }
  114.    }
  115. Projectile { translate Ball3_Pos }
  116.  
  117. if (frame == 131)
  118.    static define Ball4_Pos CPos+4*Ball4_Vel
  119. else if (frame > 131) {
  120.    static define Ball4_Pos Ball4_Pos + Ball4_Vel
  121.    static define Ball4_Vel Ball4_Vel + Gravity
  122.    if (Ball4_Pos[1] < -1) {
  123.       static define Ball4_Pos <Ball4_Pos[0], -2 - Ball4_Pos[1], Ball4_Pos[2]>
  124.       static define Ball4_Vel <Ball4_Vel[0], -0.7*Ball4_Vel[1], Ball4_Vel[2]>
  125.       }
  126.    }
  127. Projectile { translate Ball4_Pos }
  128.  
  129. if (frame == 171)
  130.    static define Ball5_Pos CPos+4*Ball5_Vel
  131. else if (frame > 171) {
  132.    static define Ball5_Pos Ball5_Pos + Ball5_Vel
  133.    static define Ball5_Vel Ball5_Vel + Gravity
  134.    if (Ball5_Pos[1] < -1) {
  135.       static define Ball5_Pos <Ball5_Pos[0], -2 - Ball5_Pos[1], Ball5_Pos[2]>
  136.       static define Ball5_Vel <Ball5_Vel[0], -0.7*Ball5_Vel[1], Ball5_Vel[2]>
  137.       }
  138.    }
  139. Projectile { translate Ball5_Pos }
  140.  
  141. if (frame == 211)
  142.    static define Ball6_Pos CPos+4*Ball6_Vel
  143. else if (frame > 211) {
  144.    static define Ball6_Pos Ball6_Pos + Ball6_Vel
  145.    static define Ball6_Vel Ball6_Vel + Gravity
  146.    if (Ball6_Pos[1] < -1) {
  147.       static define Ball6_Pos <Ball6_Pos[0], -2 - Ball6_Pos[1], Ball6_Pos[2]>
  148.       static define Ball6_Vel <Ball6_Vel[0], -0.7*Ball6_Vel[1], Ball6_Vel[2]>
  149.       }
  150.    }
  151. Projectile { translate Ball6_Pos }
  152.  
  153. // Floor
  154. define tx_P rotate(P, <1, 1, 0>, 27)
  155. object {
  156.    disc <0,-2, 0>, <0, 1, 0>, 200
  157.    texture {
  158.       special matte {
  159.      color tan
  160.      normal N + (dnoise(tx_P/5) - white/2)
  161.      }
  162.       }
  163.    }
  164.