home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / graphuti / rayl210.zip / RAYLATHE.DOC < prev    next >
Text File  |  1993-09-18  |  11KB  |  245 lines

  1.  
  2.  
  3.  
  4.     RayLathe v 2.10 (c) 1993 Koehler
  5.  
  6.     DESCRIPTION:
  7.  
  8.      RayLathe is a text based tool that allows you to create three
  9.     dimensional objects using the metaphor of the carpenter's lathe.  The
  10.     objects are created as #declare'd composite's for POVRAY 1.0 (p.k.a.
  11.     DKB), POVRAY 2.0, or Vivid 2.0 ray tracing programs.  This program also
  12.     generates RAW (with and without color) triangle data for RAW2POV and
  13.     SNDPPR (which smooth triangle data into ray tracer source).
  14.  
  15.      Imagine the 'stock' we are cutting lies along the X axis.  We will
  16.     be cutting from 0 X in the positive direction.  POVRAY and Vivid output
  17.     is designed to use cones (or cylinders if straight) to make the surface
  18.     of each cut along the X axis.  This is VERY CPU efficient to render.
  19.     Unfortunatley curved surfaces show the seam between cuts.  For this
  20.     reason, v2.0 outputs in the RAW format.  Instead of making a smooth
  21.     cut around the 'stock', we are making a ring of triangles for each cut.
  22.     Imagine a sphere versus a geodesic dome.  RAW2POV and SNDPPR
  23.     (SandPaper) both take this data and create 'smooth' triangles for
  24.     various ray tracers.
  25.  
  26.      With version 2.0 of Raylathe, an optional header record describes
  27.     the input data format and how many facets about the X axis are to be
  28.     generated for RAW data.  If the first number in the file is -1, then
  29.     this is a header record with the third number in the file (second is
  30.     ignored at this point) is the number of facets around the stock to cut
  31.     for RAW data.  This information is ignored for POVRAY & Vivid data
  32.     formats.  If the first number in the file is -2, this means the same as
  33.     -1 plus all data after this record includes color information.
  34.  
  35.      The data is given as X Y THICK.  If color information is included,
  36.     then the format is RED GREEN BLUE X Y THICK.  Please refer to examples
  37.     at this point if the format confuses you.  All numbers are floating
  38.     point.
  39.  
  40.      X and Y are the coordinates of the end point of the line of a cut
  41.     on the lathe.  THICK is the thickness of the surface of the object.
  42.     This obviously differs from a real lathe were the object is solid.    We
  43.     can, however, do things a real lathe can't:  undercut an area.  See
  44.     example #2 below.  The values for THICK are:  -1 for POVRAY=solid /
  45.     Vivid=paper-thing object (renders quickest, no undercutting allowed in
  46.     POVRAY), 0 for 'move to' (like starting a new block of wood a distance
  47.     from the current one), and anything greater than 0 for the actual
  48.     thickness of the shell of the object.  The last entry must be '-1 -1
  49.     -1' to signify end of object.  If color data is present the last line
  50.     must be '-1 -1 -1 -1 -1 -1' for consistency.  Comments may be added
  51.     after this line.
  52.  
  53.  
  54.  
  55.  
  56.     EXAMPLE #1
  57.  
  58.      We will make an object that looks like a pulley.  Figure A shows
  59.     the coordinates with lines showing the cut surface.  Figure B is the
  60.     data set for Figure A.  Figure C is a view of the pulley looking into
  61.     the groove.
  62.  
  63.        Fig. A           Fig. B             Fig. C
  64.  
  65.     5 |   *      *           2 1 0  <-note move-to    .    .
  66.     4 |   |\     /|           5 5 -1            |\     /|
  67.     3 |   | *---* |           3 3 -1            | .---. |
  68.     2 |   |      |           5 3 -1            |    |
  69.     1 |   *      *           6 5 -1            |    |
  70.       + - - - - - - - - -       6 1 -1            |    |
  71.     0    1 2 3 4 5 6 7 8 9       -1 -1 -1            | .---. |
  72.                                 |/     \|
  73.                                 .    .
  74.     EXAMPLE #2
  75.  
  76.      Contrary to a real lathe, this lathe can undercut surfaces.  For
  77.     example we can make something that looks [barely] like a sun umbrella.
  78.     Remember to use thickness when undercutting else the solid object will
  79.     fill in the inside of the umbrella.  Also, use a thickness of 0 when
  80.     moving from the tip of the umbrella (point 3) into the center (point 4)
  81.     when drawing the post (line between 4 and 5).
  82.        Fig. D                     Fig. E
  83.  
  84.          3                      .
  85.            /                    / !
  86.         /                         /      !
  87.      /                      /      !
  88.       /                        /      !
  89.      2                          .       !
  90.      |4-----------------------------5          |-------------------------------
  91.      1                          |-------------------------------
  92.                           .       !
  93.                            \      !
  94.                           \      !
  95.                              \      !
  96.                             \ !
  97.                               .
  98.     EXAMPLE #3
  99.  
  100.      This example uses the same data as used in Example #1, with the
  101.     addition of color attributes.
  102.  
  103.            -2 -1 15    <- color record, unused, 15 sides around cut
  104.     2 1 0       2 1 0 1 0 0           <- Red
  105.     5 5 -1       5 5 -1 0.3 0.3 0.3  <- Dark Grey
  106.     3 3 -1       3 3 -1 1 1 1        <- White
  107.     5 3 -1       5 3 -1 0 0 1        <- Blue
  108.     6 5 -1       6 5 -1 0 1 0        <- Green
  109.     6 1 -1       6 1 -1 0 0 0        <- Black
  110.     -1 -1 -1       -1 -1 -1 -1 -1 -1
  111.  
  112.  
  113.  
  114.  
  115.  
  116.     APPLICATION NOTES:
  117.  
  118.      Another program is included to convert uLathe (by Daniel S.  Baker
  119.     CompuServe:  71551,2300) .LAT files to .DAT files used by RayLathe to
  120.     generate the objects.  uLathe is an excellent object creator for
  121.     windows.  I was disappointed that the output was not usable by any of
  122.     the ray tracers for building whole scenes.    Ta-Da!
  123.  
  124.      The objects themselves are a series of cuts (the line between the
  125.     specified points of data).    uLathe presents each cut as a number of
  126.     flat facets about the X axis.  For ray tracing, multiply the number of
  127.     cuts by the number of facets.  Thats a lot.  I observed that any given
  128.     cut would acutally look like a cone (or cylinder if parallel).  This
  129.     reduces the number of objects tremdously and thus speeds ray tracing +
  130.     smoother about the X axis.    Unfortunately there is not much I can do
  131.     with sharp edges of the cuts.  The candle in particular doesn't seem to
  132.     suffer.  Be careful with curved surfaces.  Once the scene is layed out,
  133.     you may want to switch to RAW output which produces the best smoothed
  134.     surfaces.
  135.  
  136.      For POVRAY the texture LatheWorkTex must be defined for the
  137.     resulting object.  See the included example .POV file.  At the end of
  138.     the file created by RayLathe are two #declare's (Location and Look_At)
  139.     which are vector definitions for where to put the camera and where to
  140.     aim the camera.
  141.  
  142.     To use them in POVRAY:
  143.  
  144.     Instead of:     location <1 2 3>     you can use:    location Location
  145.             look_at <3 2 1>            look_at Look_At
  146.  
  147.  
  148.     Usage:   LAT2RAYL candle            <- Converts uLathe CANDLE.LAT
  149.          RAYLATHE <candle.dat >candle.inc    <- Creates candle POVRAY object
  150.          RAYLATHE -v <candle.dat >candle.vo <- Creates candle Vivid object
  151.          Then create the scene (.pov or .v) and render.
  152.  
  153.  
  154.     ADDITIONAL BOTHER:
  155.  
  156.      See also CHAIN (which generates a chain of links), SHADE (which
  157.     generates pleated lamp shades), DIAMOND (which generates a cut gem,
  158.     plus creates the rest of the .POV file:  view, light, floor), GEAR
  159.     (guess), STAR (which generates 3D stars with several attributes),
  160.     FNT2POV (which converts Grasp/Pictor/compatible fonts to objects using
  161.     many options), and SHP2DKB (which should become SHP2PV) which takes
  162.     AutoCad .SHP font files and generates stroke-type font objects.  At
  163.     this time all of the programs listed in this paragraph are for POVRAY
  164.     only.
  165.  
  166.  
  167.  
  168.  
  169.  
  170.      With all of these programs, just play around with the variables to
  171.     generate new shapes.  For example, generating many long points on the
  172.     star looks like the spokes of a bicycle wheel.  Many short points on a
  173.     large radius star looks like a circular saw blade.    Use your
  174.     imagination and please post any ideas or neat works (with source) for
  175.     the world to enjoy.  As you can tell I don't like building single
  176.     objects; I'd rather build a factory that can spit out 'what if' objects.
  177.  
  178.      Trial size soap box:  Please include source when sending programs
  179.     or objects.  Even if its sloppy, it can only help others.  Follow the
  180.     lead of the people who brought us DKB in the first place.  We wouldn't
  181.     have a POVRAY now otherwise!  Many thanks to those who do post!
  182.  
  183.     I can be reached at YOU CAN CALL ME RAY RBBS (708) 358-5611.
  184.  
  185.  
  186.             "Its my world and you're welcome to it".
  187.  
  188.  
  189.                         Ken Koehler (7-21-93)
  190.                         CIS 72740,1161
  191.                         internet ken.koehler@pcohio.com
  192.     Enclosed are these files:
  193.  
  194.      RAYLATHE.C    C source
  195.      RAYLATHE.EXE  MS-DOS executable for object generator v2.00
  196.      RAYLATHE.DOC  This file
  197.      LAT2RAYL.C    C source
  198.      LAT2RAYL.EXE  uLathe .LAT to RayLathe .DAT converter v1.10
  199.      CANDLE.LAT    uLathe .LAT file containing shape data
  200.      CANDLE.POV    Sample POVRAY file to generate the test image
  201.      SNIFTER.LAT   uLathe .LAT file containing shape data
  202.      SNIFTER.V     Sample Vivid file to generate the test image
  203.  
  204.  
  205.     Credits:
  206.  
  207.      Doug Downs (finally a local tracer!  found on PC-OHIO) got me
  208.     interested in uLathe (by Daniel S.    Baker CompuServe:  71551,2300)
  209.     which is a great (windows) modeler for lathing the objects.  I was
  210.     disappointed there was no way to export the data for ray tracing.
  211.     Appearantly I got wound up enough to write this package.  I'm into
  212.     POVRAY, but Doug is into Vivid ("Tastes great, Less filling").  Doug
  213.     graciously provides the Vivid testing and ideas.
  214.  
  215.      Eduard Schwan (as indicated in the revision history below) added
  216.     POVRAY 2.0 support, made output prettier, and made the RayLathe code
  217.     cleaner.  Thanks for improvements!
  218.  
  219.  
  220.  
  221.  
  222.  
  223.    Revision History:
  224.  
  225.    03-24-93 1.00 KJK  New. Inspired by uLathe.
  226.    03-28-93 1.01 KJK  Attempting Vivid output for Doug Downs.
  227.    04-11-93 1.10 KJK  Releasable Vivid output version.
  228.               Noticed THICK in Vivid not supported! Must fix.
  229.    04-11-93 1.11 KJK  Cured black speckles in POVRAY output.
  230.    04-14-93 1.12 KJK  Allow 0 length cones (rings) for Vivid.
  231.    04-15-93 1.13 KJK  Enable THICK for Vivid. Print line # of .DAT file for
  232.               each element.
  233.    04-24-93 1.20 KJK  Since they are necessary when thickness is used,
  234.               simulate cone/rings for POVRAY.
  235.    07-20-93 2.00 esp   Add POV-Ray 2.0 syntax, clean up cmdline parsing,
  236.               add Macintosh (MPW) support, change FP compares like
  237.               (x==y) to (fabs(x-y) < EPSILON) to better conform to
  238.               the way fp numbers (mis)behave, add tabwidth parm,
  239.               clean up indenting.
  240.          KJK  Added RAW output format. Allow color input data for
  241.               RAW output. May support color for POVRAY/Vivid if
  242.               anyone cares. Currently POVRAY and Vivid ignore it.
  243.    09-18-93 2.10 KJK  Fix bug: Commas introduced by esp tabbing where they
  244.               didn't belong.
  245.