home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch17 / pi / cubic / cubic.pi < prev    next >
Encoding:
Text File  |  1994-08-05  |  3.0 KB  |  105 lines

  1. // Scene File: CUBIC.PI
  2. // Author: Rob McGregor
  3.  
  4. /************************************************* 
  5.   Three spheres follow different cubic paths,
  6.   starting and ending at the same points
  7. **************************************************/
  8.  
  9. include "..\..\..\colors.inc"
  10. include "..\..\..\texture.inc"
  11.  
  12. // SET UP THE CAMERA
  13. viewpoint {
  14.   from       <4.5, 0, -12>
  15.   at         <4.5, 1, 0>
  16.   up         <0, 1, 0>
  17.   angle      45
  18.   resolution 320, 200
  19.   aspect     1.6
  20. }
  21.  
  22. // Set the sky color and add a little haze
  23. background Grey
  24. haze 0.98, 25, Grey
  25.  
  26. // Lights
  27. light <-5, 5, -20>
  28. light <5, 5, -20>
  29.  
  30. // Define the range of the animation
  31. start_frame   0
  32. end_frame     49
  33. outfile       "cubic"
  34.  
  35. define s1_Nc 10.0 // Nc for sphere1 (red)
  36. define s2_Nc  2.5 // Nc for sphere2 (yellow)
  37. define s3_Nc -5.0 // Nc for sphere3 (blue)
  38.  
  39. define s1_Nd -2 // Nd for sphere1 (red)
  40. define s2_Nd  5 // Nd for sphere2 (yellow)
  41. define s3_Nd  3 // Nd for sphere3 (blue)
  42.  
  43. // Sphere1
  44. define s1N1x  0 // x-axis starting point
  45. define s1N1y -1 // y-axis starting point
  46. define s1N2x  9 // x-axis ending point
  47. define s1N2y -1 // y-axis ending point
  48.  
  49. // Sphere2
  50. define s2N1x  0 // x-axis starting point
  51. define s2N1y  0 // y-axis starting point
  52. define s2N2x  9 // x-axis ending point
  53. define s2N2y  0 // y-axis ending point
  54.  
  55. // Sphere3
  56. define s3N1x  0 // x-axis starting point
  57. define s3N1y  1 // y-axis starting point
  58. define s3N2x  9 // x-axis ending point
  59. define s3N2y  1 // y-axis ending point
  60.  
  61. // Calculate the value of t as:
  62. //   t = (F - F1) / (F2 - F1)
  63. define t (frame - start_frame) / (end_frame - start_frame)
  64.  
  65. // Now calculate the locations of the spheres using:
  66. //   N = (1 - t)^3 * N1 + (t^3) * N2 + 3 * t * 
  67. //       ((1 - t)^2) * Nc + 3 * (t^2) * (1 - t) * Nd
  68.  
  69. define s1_x (1 - t)^3 * s1N1x + (t^3) * s1N2x + 3 * t * 
  70.             ((1 - t)^2) * s1_Nc + 3 * (t^2) * (1 - t) * s1_Nd
  71. define s1_y (1 - t)^3 * s1N1y + (t^3) * s1N2y + 3 * t * 
  72.             ((1 - t)^2) * s1_Nc + 3 * (t^2) * (1 - t) * s1_Nd
  73.  
  74. define s2_x (1 - t)^3 * s2N1x + (t^3) * s2N2x + 3 * t * 
  75.             ((1 - t)^2) * s2_Nc + 3 * (t^2) * (1 - t) * s2_Nd
  76. define s2_y (1 - t)^3 * s2N1y + (t^3) * s2N2y + 3 * t * 
  77.             ((1 - t)^2) * s2_Nc + 3 * (t^2) * (1 - t) * s2_Nd
  78.  
  79. define s3_x (1 - t)^3 * s3N1x + (t^3) * s3N2x + 3 * t * 
  80.             ((1 - t)^2) * s3_Nc + 3 * (t^2) * (1 - t) * s3_Nd
  81. define s3_y (1 - t)^3 * s3N1y + (t^3) * s3N2y + 3 * t * 
  82.             ((1 - t)^2) * s3_Nc + 3 * (t^2) * (1 - t) * s3_Nd
  83.  
  84.  
  85. // Set the positions of the spheres
  86. define s1_loc <s1_x, s1_y, 0>
  87. define s2_loc <s2_x, s2_y, 0>
  88. define s3_loc <s3_x, s3_y, 0>
  89.  
  90. // Create 3 spheres
  91. object { sphere s1_loc, 0.5 reflective_red }
  92. object { sphere s2_loc, 0.5 reflective_yellow }
  93. object { sphere s3_loc, 0.5 reflective_blue }
  94.  
  95. // The floor...
  96. object {
  97.   disc <0, 0, 0>, <0, 1, 0>, 10000
  98.   texture { 
  99.     checker steely_blue, 
  100.     texture { shiny { color white }}
  101.   }
  102.   rotate <0, 25, 0>
  103.   translate <0, -3.5, 0>
  104. }
  105.