home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / tt / raysh402 / guide.tex / node39_mn.html < prev    next >
Text File  |  1992-02-09  |  2KB  |  52 lines

  1.  
  2. <H1><A ID="SECTION001200000000000000000">
  3. Height Field Files</A>
  4. </H1>
  5.  
  6. <P>
  7. This appendix describes the format of the files that store data
  8. for the height field primitive.
  9. The format is an historical relic; a better format is needed.
  10.  
  11. <P>
  12. Height field data is stored in binary form.
  13. The first record in the file is a
  14. 32-bit integer giving the square root of number of data
  15. points in the file.
  16. We'll call this number
  17. the size of the height field.
  18.  
  19. <P>
  20. The size is
  21. followed by altitude (<I>z</I>) values stored as 32-bit
  22. floating point values.  The 0th value in the file specifies the <I>z</I>
  23. coordinate
  24. of the lower-left corner of the height field (0, 0).
  25. The next
  26. specifies the Z coordinate for <tex2html_verbatim_mark>#math171#(1/(<I>size</I> - 1), 0).  The last specifies the
  27. coordinate for (1., 1.).  In other words, the <I>i</I><SUP>th</SUP> value 
  28. in the heightfield file specifies the <I>z</I> coordinate for the point
  29. whose <I>x</I> coordinate is
  30. <tex2html_verbatim_mark>#math172#(<I>i</I>%<I>size</I>)/(<I>size</I> - 1), and whose
  31. <I>y</I> coordinate is <tex2html_verbatim_mark>#math173#(<I>i</I>/<I>size</I>)/(<I>size</I> - 1).
  32. Non-square height fields may be rendered by specifying altitude values
  33. less than or equal to the magic value
  34. -1000.  Triangles that have any vertex less than
  35. or equal in altitude to this value are not rendered.
  36.  
  37. <P>
  38. While this file format is compact, it sacrifices portability for
  39. ease of use.  While creating and handling height field files is
  40. simple, transporting a height field from one machine to another
  41. is problematical due to the fact that differences in byte order
  42. and floating-point format between machines is not taken into
  43. account.
  44.  
  45. <P>
  46. These problems could be circumvented by writing the height field file
  47. in a fixed-point format, taking care to write the bytes that
  48. encode a given value in a consistent way from machine to machine.
  49. An even better idea would be to write a set of tools for
  50. manipulating arbitrary 2D arrays of floating-point values in a compact,
  51. portable way, allowing for comments and the like in the file...
  52.