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

  1.  
  2. <H1><A ID="SECTION00720000000000000000">
  3. Primitives</A>
  4. </H1>
  5.  
  6. <P>
  7. Primitive objects are the building box with which other objects are
  8. created.  Each primitive type has associated with it specialized
  9. methods for
  10. creation,
  11. intersection with a ray,
  12. bounding box calculation,
  13. surface normal calculation,
  14. ray enter/exit classification,
  15. and for the computation 2D texture coordinates termed <#358#><EM>u-v</EM><#358#>
  16. coordinates.
  17. This latter method is often referred to as the <#359#><EM>inverse mapping</EM><#359#>
  18. method.
  19.  
  20. <P>
  21. While most of these methods should be of little concern to you, the
  22. inverse mapping methods
  23. will affect the way in which certain textures are applied to primitives.
  24. Inverse mapping is a matter of computing normalized <I>u</I> and <I>v</I> coordinates
  25. for a given point on the surface of the primitive.  For planar objects,
  26. the <I>u</I> and <I>v</I> coordinates of a point are computed
  27. by linear interpolation based upon the <I>u</I> and <I>v</I> coordinates assigned
  28. to vertices or other known points on the primitive.  For non-planar
  29. objects, <I>uv</I> computation can be considerably more involved.
  30.  
  31. <P>
  32. This section briefly describes each primitive and
  33. the syntax that should be used to create an instance of the primitive.
  34. It also describes the inverse mapping method, if any, for each type.
  35.  
  36. <P>
  37. <DL>
  38. <DT><STRONG><#4723#><#4723#></STRONG></DT>
  39. <DD><#1277#><TT>blob</TT><#1277#> <#1278#><EM>thresh st r</EM><#1278#> <tex2html_verbatim_mark>#math74#<tex2html_image_mark>#tex2html_wrap_inline4725#⇧ [<#1280#><EM>st r</EM><#1280#> <tex2html_verbatim_mark>#math75#<tex2html_image_mark>#tex2html_wrap_inline4727#⇧ ...] 
  40. <BR>    Defines a blob with consisting of a threshold equal to <#366#><EM>thresh</EM><#366#>,
  41.     and a
  42.     group of one or more metaballs.  Each metaball is defined by 
  43.     its position <tex2html_verbatim_mark>#math76#<tex2html_image_mark>#tex2html_wrap_inline4729#⇧, radius <#368#><EM>r</EM><#368#>, and strength <#369#><EM>st</EM><#369#>.
  44. </DD>
  45. </DL>The metaballs affect each other according to a superimposed
  46. density distribution:
  47. <P><tex2html_verbatim_mark>#math77#</P><DIV ALIGN="CENTER">
  48. <I>F</I>(<I>x</I>, <I>y</I>, <I>z</I>) = <tex2html_image_mark>#tex2html_wrap_indisplay4731#⇧<I>b</I><SUB>i</SUB><I>e</I><SUP>-d<SUB>i</SUB></SUP> - <I>T</I> = 0
  49. </DIV><P></P>
  50. There is no inverse mapping method for blobs.
  51.  
  52. <P>
  53. <DL>
  54. <DT><STRONG><#4732#><#4732#></STRONG></DT>
  55. <DD><#1284#><TT>box</TT><#1284#> <tex2html_verbatim_mark>#math78#<tex2html_image_mark>#tex2html_wrap_inline4734#⇧ <tex2html_verbatim_mark>#math79#<tex2html_image_mark>#tex2html_wrap_inline4736#⇧ 
  56. <BR>    Creates an axis-aligned box
  57.     which has <tex2html_verbatim_mark>#math80#<tex2html_image_mark>#tex2html_wrap_inline4738#⇧ and <tex2html_verbatim_mark>#math81#<tex2html_image_mark>#tex2html_wrap_inline4740#⇧ as
  58.     opposite corners.
  59. </DD>
  60. </DL>Transformations may be applied to the box if a non-axis-aligned instance
  61. is required.  There is no inverse mapping method for boxes.
  62.  
  63. <P>
  64. <DL>
  65. <DT><STRONG><#4741#><#4741#></STRONG></DT>
  66. <DD><#1289#><TT>sphere</TT><#1289#> <#1290#><EM>radius</EM><#1290#> <tex2html_verbatim_mark>#math82#<tex2html_image_mark>#tex2html_wrap_inline4743#⇧ 
  67. <BR>    Creates a sphere with the given <#385#><EM>radius</EM><#385#> and centered at the
  68.     given position.
  69. </DD>
  70. </DL>Note that ellipsoids may be created by applying the proper scaling
  71. to a sphere.  Inverse mapping on the sphere is accomplished
  72. by computing the longitude and latitude of the point on the sphere,
  73. with the <I>u</I> value corresponding to longitude and <I>v</I> to latitude.
  74. On an untransformed sphere, the <I>z</I> axis defines the poles, and the
  75. <I>x</I> axis intersects the sphere at <I>u</I> = 0, <I>v</I> = 0.5.  There are
  76. degeneracies at the poles: the south pole contains all points of
  77. latitude 0., the north all points of latitude 1.
  78.  
  79. <P>
  80. <DL>
  81. <DT><STRONG><#4750#><#4750#></STRONG></DT>
  82. <DD><#1294#><TT>torus</TT><#1294#> <#1295#><EM>rmajor rminor</EM><#1295#> <tex2html_verbatim_mark>#math83#<tex2html_image_mark>#tex2html_wrap_inline4752#⇧ <tex2html_verbatim_mark>#math84#<tex2html_image_mark>#tex2html_wrap_inline4754#⇧ 
  83. <BR>    Creates a torus centered at <tex2html_verbatim_mark>#math85#<tex2html_image_mark>#tex2html_wrap_inline4756#⇧ by rotating
  84.     a circle with the given minor radius around the center
  85.     point at a distance equal to the major radius. 
  86. </DD>
  87. </DL>In tori inverse mapping,
  88. the <I>u</I> value is computed using the angle of rotation about the
  89. up vector, and the <I>v</I> value is computing the angle of rotation
  90. around the tube, with <I>v</I> = 0 occuring on the innermost point of the tube.
  91.  
  92. <P>
  93. <DL>
  94. <DT><STRONG><#4760#><#4760#></STRONG></DT>
  95. <DD><#1300#><TT>triangle</TT><#1300#> <tex2html_verbatim_mark>#math86#<tex2html_image_mark>#tex2html_wrap_inline4762#⇧ <tex2html_verbatim_mark>#math87#<tex2html_image_mark>#tex2html_wrap_inline4764#⇧ <tex2html_verbatim_mark>#math88#<tex2html_image_mark>#tex2html_wrap_inline4766#⇧ 
  96. <BR>    Creates a triangle with the given vertices.
  97. </DD>
  98. </DL>
  99. <P>
  100. <DL>
  101. <DT><STRONG><#4767#><#4767#></STRONG></DT>
  102. <DD><#1306#><TT>triangle</TT><#1306#> <tex2html_verbatim_mark>#math89#<tex2html_image_mark>#tex2html_wrap_inline4769#⇧ <tex2html_verbatim_mark>#math90#<tex2html_image_mark>#tex2html_wrap_inline4771#⇧ <tex2html_verbatim_mark>#math91#<tex2html_image_mark>#tex2html_wrap_inline4773#⇧ <tex2html_verbatim_mark>#math92#<tex2html_image_mark>#tex2html_wrap_inline4775#⇧
  103.     <tex2html_verbatim_mark>#math93#<tex2html_image_mark>#tex2html_wrap_inline4777#⇧ <tex2html_verbatim_mark>#math94#<tex2html_image_mark>#tex2html_wrap_inline4779#⇧ 
  104. <BR>    Creates a Phong-shaded triangle with the given vertices and
  105.     vertex normals.
  106. </DD>
  107. </DL>For both Phong- and flat-shaded triangles, the <I>u</I> axis is the
  108. vector from <tex2html_verbatim_mark>#math95#<tex2html_image_mark>#tex2html_wrap_inline4782#⇧ to <tex2html_verbatim_mark>#math96#<tex2html_image_mark>#tex2html_wrap_inline4784#⇧, and the <I>v</I> axis the vector
  109. from <tex2html_verbatim_mark>#math97#<tex2html_image_mark>#tex2html_wrap_inline4787#⇧ to <tex2html_verbatim_mark>#math98#<tex2html_image_mark>#tex2html_wrap_inline4789#⇧.  There is a degeneracy at
  110. <tex2html_verbatim_mark>#math99#<tex2html_image_mark>#tex2html_wrap_inline4791#⇧, which contains all points with <I>v</I> = 1.0.  This default
  111. mapping may be modified using the <#414#><TT>triangleuv</TT><#414#> primitive described
  112. below.
  113.  
  114. <P>
  115. <DL>
  116. <DT><STRONG><#4793#><#4793#></STRONG></DT>
  117. <DD><#1315#><TT>triangleuv</TT><#1315#> <tex2html_verbatim_mark>#math100#<tex2html_image_mark>#tex2html_wrap_inline4795#⇧ <tex2html_verbatim_mark>#math101#<tex2html_image_mark>#tex2html_wrap_inline4797#⇧ <tex2html_verbatim_mark>#math102#<tex2html_image_mark>#tex2html_wrap_inline4799#⇧
  118.   <tex2html_verbatim_mark>#math103#<tex2html_image_mark>#tex2html_wrap_inline4801#⇧ <tex2html_verbatim_mark>#math104#<tex2html_image_mark>#tex2html_wrap_inline4803#⇧ <tex2html_verbatim_mark>#math105#<tex2html_image_mark>#tex2html_wrap_inline4805#⇧
  119.   <tex2html_verbatim_mark>#math106#<tex2html_image_mark>#tex2html_wrap_inline4807#⇧ <tex2html_verbatim_mark>#math107#<tex2html_image_mark>#tex2html_wrap_inline4809#⇧ <tex2html_verbatim_mark>#math108#<tex2html_image_mark>#tex2html_wrap_inline4811#⇧ 
  120. <BR>    Creates a Phong-shaded triangle with the given vertices,
  121.     vertex normals.  When performing texturing, the
  122.     <#426#><EM>uv</EM><#426#> given for each vertex are used instead of the
  123.     default values.
  124. </DD>
  125. </DL>When computing <I>uv</I> coordinates within the interior of the
  126. triangle, linear interpolation of the coordinates associated with
  127. each triangle vertex is used.
  128.  
  129. <P>
  130. <DL>
  131. <DT><STRONG><#4813#><#4813#></STRONG></DT>
  132. <DD><#1327#><TT>poly</TT><#1327#> <tex2html_verbatim_mark>#math109#<tex2html_image_mark>#tex2html_wrap_inline4815#⇧ <tex2html_verbatim_mark>#math110#<tex2html_image_mark>#tex2html_wrap_inline4817#⇧ <tex2html_verbatim_mark>#math111#<tex2html_image_mark>#tex2html_wrap_inline4819#⇧ [<tex2html_verbatim_mark>#math112#<tex2html_image_mark>#tex2html_wrap_inline4821#⇧ ...] 
  133. <BR>    Creates a polygon with the given vertices. The vertices
  134.     should be given in counter-clockwise order as one is
  135.     looking at the ``front'' side of the polygon.  The number of
  136.     vertices in a polygon is limited only by available memory.
  137. </DD>
  138. </DL>Inverse mapping for arbitrary polygons is problematical.
  139. <#435#><#1927#><EM>Rayshade</EM><#1927#><#435#>
  140. punts and equates <I>u</I> with the <I>x</I> coordinate of the point of intersection,
  141. and <I>v</I> with the <I>y</I> coordinate.
  142.  
  143. <P>
  144. <DL>
  145. <DT><STRONG><#4826#><#4826#></STRONG></DT>
  146. <DD><#1334#><TT>heightfield</TT><#1334#> <#1335#><EM>file</EM><#1335#> 
  147. <BR>    Creates a height field defined by the altitude data stored
  148.     in the named <#439#><EM>file</EM><#439#>.  The height field is based upon
  149.     perturbations of the unit square in the <I>z</I> = 0 plane, and is
  150.     rendered as a surface tessellated by right isosceles triangles.
  151. </DD>
  152. </DL>See Appendix C for a discussion of the format of a height field file.
  153. Height field inverse mapping is straight-forward:  <I>u</I> is the
  154. <I>x</I> coordinate of the point of intersection, <I>v</I> the <I>y</I> coordinate.
  155.  
  156. <P>
  157. <DL>
  158. <DT><STRONG><#4832#><#4832#></STRONG></DT>
  159. <DD><#1338#><TT>plane</TT><#1338#> <tex2html_verbatim_mark>#math113#<tex2html_image_mark>#tex2html_wrap_inline4834#⇧ <tex2html_verbatim_mark>#math114#<tex2html_image_mark>#tex2html_wrap_inline4836#⇧ 
  160. <BR>    Creates a plane that passes through the given point and
  161.     has the specified normal.
  162. </DD>
  163. </DL>Inverse mapping on the plane is identical to polygonal inverse mapping.
  164.  
  165. <P>
  166. <DL>
  167. <DT><STRONG><#4837#><#4837#></STRONG></DT>
  168. <DD><#1343#><TT>cylinder</TT><#1343#> <#1344#><EM>radius</EM><#1344#> <tex2html_verbatim_mark>#math115#<tex2html_image_mark>#tex2html_wrap_inline4839#⇧ <tex2html_verbatim_mark>#math116#<tex2html_image_mark>#tex2html_wrap_inline4841#⇧ 
  169. <BR>    Creates a cylinder that extends from <tex2html_verbatim_mark>#math117#<tex2html_image_mark>#tex2html_wrap_inline4843#⇧ to <tex2html_verbatim_mark>#math118#<tex2html_image_mark>#tex2html_wrap_inline4845#⇧
  170.     and has the indicated <#453#><EM>radius</EM><#453#>.  Cylinders are rendered
  171.     <#454#><EM>without</EM><#454#> endcaps.
  172. </DD>
  173. </DL>The cylinder's axis defines the <I>v</I> axis.  The <I>u</I> axis wraps around the
  174. cylinder, with <I>u</I> = 0 dependent upon the orientation of the cylinder.
  175.  
  176. <P>
  177. <DL>
  178. <DT><STRONG><#4849#><#4849#></STRONG></DT>
  179. <DD><#1349#><TT>cone</TT><#1349#> <tex2html_verbatim_mark>#math119#<I>rad</I><SUB>bottom</SUB> <tex2html_verbatim_mark>#math120#<tex2html_image_mark>#tex2html_wrap_inline4852#⇧ <I>rad</I><SUB>top</SUB> <tex2html_verbatim_mark>#math121#<tex2html_image_mark>#tex2html_wrap_inline4855#⇧ 
  180. <BR>    Creats a (truncated) cone that extends from <tex2html_verbatim_mark>#math122#<tex2html_image_mark>#tex2html_wrap_inline4857#⇧ to
  181.     <tex2html_verbatim_mark>#math123#<tex2html_image_mark>#tex2html_wrap_inline4859#⇧.  The cone will have a radius of <tex2html_verbatim_mark>#math124#<I>rad</I><SUB>bottom</SUB> at
  182.     <tex2html_verbatim_mark>#math125#<tex2html_image_mark>#tex2html_wrap_inline4862#⇧ and a radius of <I>rad</I><SUB>top</SUB> at <tex2html_verbatim_mark>#math126#<tex2html_image_mark>#tex2html_wrap_inline4865#⇧.
  183.     Cones are rendered <#468#><EM>without</EM><#468#> endcaps.
  184. </DD>
  185. </DL>Cone inverse mapping is analogous to cylinder mapping.
  186.  
  187. <P>
  188. <DL>
  189. <DT><STRONG><#4866#><#4866#></STRONG></DT>
  190. <DD><#1356#><TT>disc</TT><#1356#> <#1357#><EM>radius</EM><#1357#> <tex2html_verbatim_mark>#math127#<tex2html_image_mark>#tex2html_wrap_inline4868#⇧ <tex2html_verbatim_mark>#math128#<tex2html_image_mark>#tex2html_wrap_inline4870#⇧ 
  191. <BR>    Creates a disc centered at the given position and with the
  192.     indicated surface normal.
  193. </DD>
  194. </DL>Discs are useful for placing
  195. endcaps on cylinders and cones.
  196. Inverse mapping for the disc is based on the computation of the
  197. normalized polar coordinates of the point of intersection.  The
  198. normalized radius
  199. of the point of intersection is assigned to <I>u</I>, while the normalized angle
  200. from a reference vector is assigned to <I>v</I>.
  201.  
  202. <P>
  203.