home *** CD-ROM | disk | FTP | other *** search
- //
- // Sword.Inc
- //
- // This file contains a simple Sword for use in other pictures.
- // Hope someone can find a use for it.
- // Created by: Dan Linder (dlinder@cse.unl.edu)
- // If you use this in a creation of your own, please send
- // me a copy of the scene file.
- //
-
- #include "colors.inc"
- #include "shapes.inc"
- #include "shapesq.inc"
- #include "textures.inc"
-
- #declare edge_len = 88 // Length of the main edge of the sword
- // multiplied by 11.
-
- #declare thickness = 11 // "Thickness" value for the sword.
- // This is pureley arbitrary.
-
- #declare handle = texture {
- DMFWood1 // Nice black wood.
- scale < .2 .2 1 >
- phong 1
- Dull
- }
-
- /*
- The hilt of the sword is actually a simple, wide parabola
- intersected at a slight angle to one another.
- */
- #declare hilt = quadric {
- < 0.5 0 0 >
- < 0 0 0 >
- < 0 -5 0 >
- 0
- }
-
- /*
- The edge of the sword is a simple equation like this:
- y^2-z=0, or in other words, a parabola extending
- to plus and minus infinity along the X axis, opening
- to the plus Z axis.
- I take this parabola and another turned 180 degrees
- and have them intersect. The result is like this:
-
- \ /
- X
- / \
- ( )
- \ /
- X
- / \
-
- The final intersection of these two parabolas is just the
- simple "sliver".
-
- The tip is made much the same way, but as it moves along
- the X axis, it goes toward positive Z infinity.
-
- There is a small bit of "fluting" along both sides of the
- blade, and this is just another simple intersection of
- parabolas.
- */
- #declare sword_edge = quadric {
- < 0.0 1.0 0.0 >
- < 0.0 0.0 0.0 >
- < 0.0 0.0 -thickness >
- 0.0
- }
-
- #declare sword_tip = quadric {
- < 0.20 1 0 >
- < 0 0 0 >
- < 0 0 -thickness >
- 0
- }
-
- #declare Sword1 =
- object {
- union {
- union { // Handle of Sword
- sphere { < 0.00 0 0 > 2.5 texture { handle } }
- sphere { < -1.50 0 0 > 2.5 texture { handle } }
- sphere { < -3.00 0 0 > 2.5 texture { handle } }
- sphere { < -4.50 0 0 > 2.5 texture { handle } }
- sphere { < -6.00 0 0 > 2.5 texture { handle } }
- sphere { < -7.50 0 0 > 2.5 texture { handle } }
- sphere { < -9.00 0 0 > 2.5 texture { handle } }
- sphere { < -10.50 0 0 > 2.5 texture { handle } }
- sphere { < -12.00 0 0 > 2.5 texture { handle } }
- sphere { < -13.50 0 0 > 2.5 texture { handle } }
- sphere { < -15.00 0 0 > 2.5 texture { handle } }
- sphere { < -16.50 0 0 > 2.5 texture { handle } }
- sphere { < -18.00 0 0 > 2.5 texture { handle } }
- sphere { < -19.50 0 0 > 2.5 texture { handle } }
- sphere { < -21.00 0 0 > 2.5 texture { handle } }
- sphere { < -22.50 0 0 > 2.5 texture { handle } }
- }
- intersection { // Begin the long edge of the sword
- difference {
- quadric {
- sword_edge
- translate < 0 0 -0.5 >
- }
- quadric { // add the "flute" along the spine
- sword_edge
- rotate < 180 0 0 >
- translate < 0 0 -0.35 >
- }
- }
- difference {
- quadric {
- sword_edge
- rotate < 180 0 0 >
- translate < 0 0 0.5 >
- }
- quadric { // add the "flute" along the spine
- sword_edge
- translate < 0 0 0.35 >
- }
- }
- plane { // cap for end nearest tip.
- < 1 0 0 > edge_len
- }
- plane {
- < -1 0 0 > 0 // cap for end nearest handle.
- }
- }
- intersection { // Begin tip of sword.
- plane {
- < -1 0 0 > 0
- translate < edge_len 0 0 >
- }
- difference { // take the flute out of the tip.
- quadric {
- sword_tip
- translate < edge_len 0 -0.5 >
- }
- quadric { // add the "flute" along the spine
- sword_edge
- rotate < 180 0 0 >
- translate < 0 0 -0.35 >
- }
- }
- difference { // take the flute out of the tip.
- quadric {
- sword_tip
- rotate < 180 0 0 >
- translate < edge_len 0 0.5 >
- }
- quadric { // add the "flute" along the spine
- sword_edge
- translate < 0 0 0.35 >
- }
- }
- }
- intersection { // Tip of hilt going beside blade...
- quadric {
- hilt
- inverse
- }
- quadric {
- hilt
- rotate < 0 0 5 >
- translate < 2 -2 0 >
- }
- plane {
- < 0 0 1 > 0.5
- }
- plane {
- < 0 0 -1 > 0.5
- }
- plane {
- < -1 0 0 > 0
- }
- rotate < 0 0 -90 >
- translate < 1 0 0 >
- }
- intersection { // Tip of hilt going along handle....
- quadric {
- hilt
- inverse
- }
- quadric {
- hilt
- rotate < 0 0 5 >
- translate < 2 -2 0 >
- }
- plane {
- < 0 0 1 > 0.5
- }
- plane {
- < 0 0 -1 > 0.5
- }
- plane {
- < -1 0 0 > 0
- }
- rotate < 0 0 90 >
- }
- }
- texture {
- Gold_Metal // Always wanted a gold sword!
- reflection .95 // Don't make it a perfect mirror.
- ambient .05 // give the metal pieces a bit of
- // "inner glow"!
- }
- scale < 0.090909 0.090909 0.090909 > // Scale to approx 1 unit.
- }
-
-
-