home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / scripts / pov / swordpov / sword.inc < prev    next >
Encoding:
Text File  |  1992-10-30  |  4.6 KB  |  213 lines

  1. //
  2. // Sword.Inc
  3. // 
  4. //  This file contains a simple Sword for use in other pictures.
  5. //  Hope someone can find a use for it.
  6. //  Created by: Dan Linder (dlinder@cse.unl.edu)
  7. //  If you use this in a creation of your own, please send
  8. //  me a copy of the scene file.
  9. //
  10.  
  11. #include "colors.inc"
  12. #include "shapes.inc"
  13. #include "shapesq.inc"
  14. #include "textures.inc"
  15.  
  16. #declare edge_len = 88    //  Length of the main edge of the sword
  17.             //   multiplied by 11.
  18.  
  19. #declare thickness = 11    //  "Thickness" value for the sword.
  20.             //  This is pureley arbitrary.
  21.  
  22. #declare handle = texture {
  23.             DMFWood1 // Nice black wood.
  24.             scale < .2 .2 1 >
  25.             phong 1
  26.             Dull
  27.         }
  28.  
  29. /*
  30.   The hilt of the sword is actually a simple, wide parabola
  31.    intersected at a slight angle to one another.
  32. */
  33. #declare hilt = quadric {
  34.             < 0.5 0 0 >
  35.             < 0 0 0 >
  36.             < 0 -5 0 >
  37.             0
  38.         }
  39.  
  40. /*
  41.   The edge of the sword is a simple equation like this:
  42.      y^2-z=0, or in other words, a parabola extending
  43.   to plus and minus infinity along the X axis, opening
  44.   to the plus Z axis.
  45.   I take this parabola and another turned 180 degrees
  46.    and have them intersect.  The result is like this:
  47.  
  48.          \ /
  49.           X
  50.          / \
  51.         (   )
  52.          \ /
  53.           X
  54.          / \
  55.  
  56.   The final intersection of these two parabolas is just the
  57.    simple "sliver".
  58.  
  59.   The tip is made much the same way, but as it moves along
  60.    the X axis, it goes toward positive Z infinity.
  61.  
  62.   There is a small bit of "fluting" along both sides of the
  63.    blade, and this is just another simple intersection of
  64.    parabolas.
  65. */
  66. #declare sword_edge = quadric    {
  67.         < 0.0 1.0 0.0 >
  68.         < 0.0 0.0 0.0 >
  69.         < 0.0 0.0 -thickness >
  70.         0.0
  71.     }
  72.  
  73. #declare sword_tip  = quadric    {
  74.             < 0.20 1 0 >
  75.             < 0 0 0 >
  76.             < 0 0 -thickness >
  77.             0
  78.         }
  79.  
  80. #declare Sword1 = 
  81. object {
  82.     union {
  83.         union { // Handle of Sword
  84.             sphere { <  0.00 0 0 > 2.5 texture { handle } }
  85.             sphere { < -1.50 0 0 > 2.5 texture { handle } }
  86.             sphere { < -3.00 0 0 > 2.5 texture { handle } }
  87.             sphere { < -4.50 0 0 > 2.5 texture { handle } }
  88.             sphere { < -6.00 0 0 > 2.5 texture { handle } }
  89.             sphere { < -7.50 0 0 > 2.5 texture { handle } }
  90.             sphere { < -9.00 0 0 > 2.5 texture { handle } }
  91.             sphere { < -10.50 0 0 > 2.5 texture { handle } }
  92.             sphere { < -12.00 0 0 > 2.5 texture { handle } }
  93.             sphere { < -13.50 0 0 > 2.5 texture { handle } }
  94.             sphere { < -15.00 0 0 > 2.5 texture { handle } }
  95.             sphere { < -16.50 0 0 > 2.5 texture { handle } }
  96.             sphere { < -18.00 0 0 > 2.5 texture { handle } }
  97.             sphere { < -19.50 0 0 > 2.5 texture { handle } }
  98.             sphere { < -21.00 0 0 > 2.5 texture { handle } }
  99.             sphere { < -22.50 0 0 > 2.5 texture { handle } }
  100.         }
  101.         intersection { // Begin the long edge of the sword
  102.             difference {
  103.                 quadric { 
  104.                     sword_edge
  105.                     translate < 0 0 -0.5 >
  106.                 }
  107.                 quadric { // add the "flute" along the spine
  108.                     sword_edge
  109.                     rotate < 180 0 0 >
  110.                     translate < 0 0 -0.35 >
  111.                 }
  112.             }
  113.             difference {
  114.                 quadric { 
  115.                     sword_edge
  116.                     rotate < 180 0 0 >
  117.                     translate < 0 0 0.5 >
  118.                 }
  119.                 quadric { // add the "flute" along the spine
  120.                     sword_edge
  121.                     translate < 0 0 0.35 >
  122.                 }
  123.             }
  124.             plane  { // cap for end nearest tip.
  125.                 < 1 0 0 > edge_len
  126.             }
  127.             plane    {
  128.             < -1 0 0 > 0 // cap for end nearest handle.
  129.             }
  130.         }
  131.         intersection { // Begin tip of sword.
  132.             plane {
  133.                 < -1 0 0 > 0
  134.                 translate < edge_len 0 0 >
  135.             }
  136.             difference { // take the flute out of the tip.
  137.                 quadric {
  138.                     sword_tip
  139.                     translate < edge_len 0 -0.5 >
  140.                 }
  141.                 quadric { // add the "flute" along the spine
  142.                     sword_edge
  143.                     rotate < 180 0 0 >
  144.                     translate < 0 0 -0.35 >
  145.                 }
  146.             }
  147.             difference { // take the flute out of the tip.
  148.                 quadric {
  149.                     sword_tip
  150.                     rotate < 180 0 0 >
  151.                     translate < edge_len 0 0.5 >
  152.                 }
  153.                 quadric { // add the "flute" along the spine
  154.                     sword_edge
  155.                     translate < 0 0 0.35 >
  156.                 }
  157.             }
  158.         }
  159.         intersection { // Tip of hilt going beside blade...
  160.             quadric { 
  161.                 hilt
  162.                 inverse
  163.             }
  164.             quadric {
  165.                 hilt
  166.                 rotate < 0 0 5 >
  167.                 translate < 2 -2 0 >
  168.             }
  169.             plane {
  170.                 < 0 0 1 > 0.5
  171.             }
  172.             plane {
  173.                 < 0 0 -1 > 0.5 
  174.             }
  175.             plane {
  176.                 < -1 0 0 > 0
  177.             }
  178.             rotate < 0 0 -90 >
  179.             translate < 1 0 0 >
  180.         }
  181.         intersection { // Tip of hilt going along handle....
  182.             quadric { 
  183.                 hilt
  184.                 inverse
  185.             }
  186.             quadric {
  187.                 hilt
  188.                 rotate < 0 0 5 >
  189.                 translate < 2 -2 0 >
  190.             }
  191.             plane {
  192.                 < 0 0 1 > 0.5
  193.             }
  194.             plane {
  195.                 < 0 0 -1 > 0.5 
  196.             }
  197.             plane {
  198.                 < -1 0 0 > 0
  199.             }
  200.             rotate < 0 0 90 >
  201.         }
  202.     }
  203.     texture {
  204.         Gold_Metal    // Always wanted a gold sword!
  205.         reflection .95    // Don't make it a perfect mirror.
  206.         ambient .05    // give the metal pieces a bit of
  207.                 // "inner glow"!
  208.     }
  209.     scale < 0.090909 0.090909 0.090909 > // Scale to approx 1 unit.
  210. }
  211.  
  212.  
  213.