home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / graphics.formats / nff.doc.old.Z / nff.doc.old
Text File  |  1991-09-24  |  8KB  |  223 lines

  1. Neutral File Format,
  2.     by Eric Haines, 3D/Eye Inc, 410 E. Upland Rd, Ithaca, NY  14850
  3.     email: hpfcla!hpfcrs!eye!erich@hplabs.hp.com
  4.  
  5. Draft #1, 10/3/88
  6.  
  7. [This is a description of the format used in the SPD package.  Any comments
  8. on how to expand this format are appreciated.  Some extensions seem obvious
  9. to me (e.g. adding directional lights, circles, and tori), but I want to take
  10. my time, gather opinions, and get it more-or-less right the first time. -EAH]
  11.  
  12. The NFF (Neutral File Format) is designed as a minimal scene description
  13. language.  The language was designed in order to test various rendering
  14. algorithms and efficiency schemes.  It is meant to describe the geometry and
  15. basic surface characteristics of objects, the placement of lights, and the
  16. viewing frustum for the eye.  Some additional information is provided for
  17. esthetic reasons (such as the color of the objects, which is not strictly
  18. necessary for testing rendering algorithms).
  19.  
  20. Future enhancements include:  circle and torus objects, spline surfaces
  21. with trimming curves, directional lights, characteristics for positional
  22. lights, CSG descriptions, and probably more by the time you read this.
  23. Comments, suggestions, and criticisms are all welcome.
  24.  
  25. At present the NFF file format is used in conjunction with the SPD (Standard
  26. Procedural Database) software, a package designed to create a variety of
  27. databases for testing rendering schemes.  The SPD package is available
  28. from Netlib and via ftp from drizzle.cs.uoregon.edu.  For more information
  29. about SPD see "A Proposal for Standard Graphics Environments," IEEE Computer
  30. Graphics and Applications, vol. 7, no. 11, November 1987, pp. 3-5.
  31.  
  32. By providing a minimal interface, NFF is meant to act as a simple format to
  33. allow the programmer to quickly write filters to move from NFF to the
  34. local file format.  Presently the following entities are supported:
  35.      A simple perspective frustum
  36.      A positional (vs. directional) light source description
  37.      A background color description
  38.      A surface properties description
  39.      Polygon, polygonal patch, cylinder/cone, and sphere descriptions
  40.  
  41. Files are output as lines of text.  For each entity, the first line
  42. defines its type.  The rest of the first line and possibly other lines
  43. contain further information about the entity.  Entities include:
  44.  
  45. "v"  - viewing vectors and angles
  46. "l"  - positional light location
  47. "b"  - background color
  48. "f"  - object material properties
  49. "c"  - cone or cylinder primitive
  50. "s"  - sphere primitive
  51. "p"  - polygon primitive
  52. "pp" - polygonal patch primitive
  53.  
  54.  
  55. These are explained in depth below:
  56.  
  57. Viewpoint location.  Description:
  58.     "v"
  59.     "from" Fx Fy Fz
  60.     "at" Ax Ay Az
  61.     "up" Ux Uy Uz
  62.     "angle" angle
  63.     "hither" hither
  64.     "resolution" xres yres
  65.  
  66. Format:
  67.  
  68.     v
  69.     from %g %g %g
  70.     at %g %g %g
  71.     up %g %g %g
  72.     angle %g
  73.     hither %g
  74.     resolution %d %d
  75.  
  76. The parameters are:
  77.  
  78.     From:  the eye location in XYZ.
  79.     At:    a position to be at the center of the image, in XYZ world
  80.        coordinates.  A.k.a. "lookat".
  81.     Up:    a vector defining which direction is up, as an XYZ vector.
  82.     Angle: in degrees, defined as from the center of top pixel row to
  83.        bottom pixel row and left column to right column.
  84.     Resolution: in pixels, in x and in y.
  85.  
  86.   Note that no assumptions are made about normalizing the data (e.g. the
  87.   from-at distance does not have to be 1).  Also, vectors are not
  88.   required to be perpendicular to each other.
  89.  
  90.   For all databases some viewing parameters are always the same:
  91.     Yon is "at infinity."
  92.     Aspect ratio is 1.0.
  93.  
  94.   A view entity must be defined before any objects are defined (this
  95.   requirement is so that NFF files can be used by hidden surface machines).
  96.  
  97. --------
  98.  
  99. Positional light.  A light is defined by XYZ position.  Description:
  100.     "l" X Y Z
  101.  
  102. Format:
  103.     l %g %g %g
  104.  
  105.     All light entities must be defined before any objects are defined (this
  106.     requirement is so that NFF files can be used by hidden surface machines).
  107.     Lights have a non-zero intensity of no particular value [this definition
  108.     may change soon, with the addition of an intensity and/or color].
  109.  
  110. --------
  111.  
  112. Background color.  A color is simply RGB with values between 0 and 1:
  113.     "b" R G B
  114.  
  115. Format:
  116.     b %g %g %g
  117.  
  118.     If no background color is set, assume RGB = {0,0,0}.
  119.  
  120. --------
  121.  
  122. Fill color and shading parameters.  Description:
  123.     "f" red green blue Kd Ks Shine T index_of_refraction
  124.  
  125. Format:
  126.     f %g %g %g %g %g %g %g %g
  127.  
  128.     RGB is in terms of 0.0 to 1.0.
  129.  
  130.     Kd is the diffuse component, Ks the specular, Shine is the Phong cosine
  131.     power for highlights, T is transmittance (fraction of light passed per
  132.     unit).  Usually, 0 <= Kd <= 1 and 0 <= Ks <= 1, though it is not required
  133.     that Kd + Ks == 1.  Note that transmitting objects ( T > 0 ) are considered
  134.     to have two sides for algorithms that need these (normally objects have
  135.     one side).
  136.   
  137.     The fill color is used to color the objects following it until a new color
  138.     is assigned.
  139.  
  140. --------
  141.  
  142. Objects:  all objects are considered one-sided, unless the second side is
  143. needed for transmittance calculations (e.g. you cannot throw out the second
  144. intersection of a transparent sphere in ray tracing).
  145.  
  146. Cylinder or cone.  A cylinder is defined as having a radius and an axis
  147.     defined by two points, which also define the top and bottom edge of the
  148.     cylinder.  A cone is defined similarly, the difference being that the apex
  149.     and base radii are different.  The apex radius is defined as being smaller
  150.     than the base radius.  Note that the surface exists without endcaps.  The
  151.     cone or cylinder description:
  152.  
  153.     "c"
  154.     base.x base.y base.z base_radius
  155.     apex.x apex.y apex.z apex_radius
  156.  
  157. Format:
  158.     c
  159.     %g %g %g %g
  160.     %g %g %g %g
  161.  
  162.     A negative value for both radii means that only the inside of the object is
  163.     visible (objects are normally considered one sided, with the outside
  164.     visible).  Note that the base and apex cannot be coincident for a cylinder
  165.     or cone.
  166.  
  167. --------
  168.  
  169. Sphere.  A sphere is defined by a radius and center position:
  170.     "s" center.x center.y center.z radius
  171.  
  172. Format:
  173.     s %g %g %g %g
  174.  
  175.     If the radius is negative, then only the sphere's inside is visible
  176.     (objects are normally considered one sided, with the outside visible).
  177.  
  178. --------
  179.  
  180. Polygon.  A polygon is defined by a set of vertices.  With these databases,
  181.     a polygon is defined to have all points coplanar.  A polygon has only
  182.     one side, with the order of the vertices being counterclockwise as you
  183.     face the polygon (right-handed coordinate system).  The first two edges
  184.     must form a non-zero convex angle, so that the normal and side visibility
  185.     can be determined.  Description:
  186.  
  187.     "p" total_vertices
  188.     vert1.x vert1.y vert1.z
  189.     [etc. for total_vertices vertices]
  190.  
  191. Format:
  192.     p %d
  193.     [ %g %g %g ] <-- for total_vertices vertices
  194.  
  195. --------
  196.  
  197. Polygonal patch.  A patch is defined by a set of vertices and their normals.
  198.     With these databases, a patch is defined to have all points coplanar.
  199.     A patch has only one side, with the order of the vertices being
  200.     counterclockwise as you face the patch (right-handed coordinate system).
  201.     The first two edges must form a non-zero convex angle, so that the normal
  202.     and side visibility can be determined.  Description:
  203.  
  204.     "pp" total_vertices
  205.     vert1.x vert1.y vert1.z norm1.x norm1.y norm1.z
  206.     [etc. for total_vertices vertices]
  207.  
  208. Format:
  209.     pp %d
  210.     [ %g %g %g %g %g %g ] <-- for total_vertices vertices
  211.  
  212. --------
  213.  
  214. Comment.  Description:
  215.     "#" [ string ]
  216.  
  217. Format:
  218.     # [ string ]
  219.  
  220.     As soon as a "#" character is detected, the rest of the line is considered
  221.     a comment.
  222.  
  223.