home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / 3d / irit / scripts / polygons.irt < prev    next >
Encoding:
Text File  |  1994-04-03  |  4.2 KB  |  186 lines

  1. #
  2. # Optimal polygonization of freeform surfaces.
  3. #
  4. #                    Gershon Elber, March 1994
  5. #
  6. #############################################################################
  7.  
  8. cross = ctlpt( E3, 0.0001, 0.0, 1.0 ) +
  9.         ctlpt( E3, 1.0,    0.0, 1.0 ) +
  10.         ctlpt( E3, 1.0,    0.0, 0.95 ) +
  11.     cbspline( 3,
  12.           list( ctlpt( E3, 0.1, 0.0, 0.95 ),
  13.             ctlpt( E3, 0.1, 0.0, 0.9 ),
  14.             ctlpt( E3, 0.1, 0.0, 0.7 ),
  15.             ctlpt( E3, 0.2, 0.0, 0.6 ),
  16.             ctlpt( E3, 0.2, 0.0, 0.2 ),
  17.             ctlpt( E3, 0.4, 0.0, 0.05 ),
  18.             ctlpt( E3, 0.4, 0.0, 0.0 ) ),
  19.           list( KV_OPEN ) ) +
  20.     ctlpt( E3, 0.0001, 0.0, 0.0 );
  21. table = surfprev( cross );
  22. color(table, green);
  23.  
  24. poly_approx_opt = 23;
  25. poly_approx_tol = 0.03;
  26. flat4ply = 1;
  27. p = gpolygon(table, on);
  28. interact(list(table, p));
  29.  
  30. poly_approx_opt = 1;
  31. poly_approx_tol = 10;
  32. flat4ply = 0;
  33. p = gpolygon(table, on);
  34. interact(list(table, p));
  35.  
  36. poly_approx_opt = 0;
  37. poly_approx_tol = 10;
  38. flat4ply = 1;
  39. p = gpolygon(table, on);
  40. interact(list(table, p));
  41.  
  42.  
  43. t = 4 * (sqrt(2) - 1) / 3;
  44. c1 = cbezier( list( ctlpt( E3,  1.0, 0.0, 0.0 ),
  45.             ctlpt( E3,  1.0,   t, 0.0 ),
  46.             ctlpt( E3,    t, 1.0, 0.0 ),
  47.             ctlpt( E3,  0.0, 1.0, 0.0 ) ) );
  48. c2 = -c1 * rotz( 180 );
  49. c3 = -c1 * rotz( 270 );
  50. c4 = c1 * rotz( 90 );
  51. srf = boolsum( c1, c2, c3, c4 );
  52. color(srf, green);
  53.  
  54. poly_approx_opt = 11;
  55. poly_approx_tol = 0.01;
  56. flat4ply = 1;
  57. p = gpolygon(srf, on);
  58. interact(list(srf, p));
  59.  
  60. poly_approx_opt = 23;
  61. poly_approx_tol = 0.01;
  62. flat4ply = 1;
  63. p = gpolygon(srf, on);
  64. interact(list(srf, p));
  65.  
  66. poly_approx_opt = 0;
  67. poly_approx_tol = 10;
  68. flat4ply = 1;
  69. p = gpolygon(srf, on);
  70. interact(list(srf, p));
  71.  
  72. srf = boolone( circle( vector( 0, 0, 0 ), 1 ) );
  73. color(srf, green);
  74.  
  75. poly_approx_opt = 11;
  76. poly_approx_tol = 0.03;
  77. flat4ply = 1;
  78. p = gpolygon(srf, on);
  79. interact(list(srf, p));
  80.  
  81. poly_approx_opt = 23;
  82. poly_approx_tol = 0.01;
  83. flat4ply = 0;
  84. p = gpolygon(srf, on);
  85. interact(list(srf, p));
  86.  
  87. poly_approx_opt = 0;
  88. poly_approx_tol = 10;
  89. flat4ply = 1;
  90. p = gpolygon(srf, on);
  91. interact(list(srf, p));
  92.  
  93. c1 = cbspline( 3,
  94.            list( ctlpt( E3, -1.0, 1.0, 0.0 ),
  95.              ctlpt( E3, -0.2, 0.2, 0.0 ),
  96.              ctlpt( E3,  0.2, 0.2, 0.0 ),
  97.              ctlpt( E3,  1.0, 1.0, 0.0 ) ),
  98.            list( KV_OPEN ) );
  99. c2 = c1 * trans( vector( 0.0,  0.0, 2.0 ) );
  100.  
  101. srf = sfromcrvs( list( c1, c2 ), 2 );
  102. color(srf, green);
  103.  
  104. poly_approx_opt = 2;
  105. poly_approx_tol = 0.01;
  106. flat4ply = 1;
  107. p = gpolygon(srf, on);
  108. interact(list(srf, p));
  109.  
  110. poly_approx_opt = 0;
  111. poly_approx_tol = 10;
  112. flat4ply = 0;
  113. p = gpolygon(srf, on);
  114. interact(list(srf, p));
  115.  
  116. poly_approx_opt = 0;
  117. poly_approx_tol = 10;
  118. flat4ply = 1;
  119. p = gpolygon(srf, on);
  120. interact(list(srf, p));
  121.  
  122. c1 = cbspline( 3,
  123.            list( ctlpt( E3, -1.0, 1.0, 0.0 ),
  124.              ctlpt( E3, -0.2, 0.2, 0.0 ),
  125.              ctlpt( E3,  0.2, 0.2, 0.0 ),
  126.              ctlpt( E3,  1.0, 1.0, 0.0 ) ),
  127.            list( KV_OPEN ) );
  128. c2 = c1 * trans( vector( 0.0, -0.5, 0.9 ) );
  129. c3 = c1 * trans( vector( 0.0, -0.5, 1.1 ) );
  130. c4 = c1 * trans( vector( 0.0,  0.0, 2.0 ) );
  131.  
  132. srf = sfromcrvs( list( c1, c2, c3, c4 ), 3 );
  133. color(srf, green);
  134.  
  135. poly_approx_opt = 2;
  136. poly_approx_tol = 0.01;
  137. p = gpolygon(srf, on);
  138. interact(list(srf, p));
  139.  
  140. poly_approx_opt = 0;
  141. poly_approx_tol = 10;
  142. flat4ply = 0;
  143. p = gpolygon(srf, on);
  144. interact(list(srf, p));
  145.  
  146. poly_approx_opt = 0;
  147. poly_approx_tol = 10;
  148. flat4ply = 1;
  149. p = gpolygon(srf, on);
  150. interact(list(srf, p));
  151.  
  152. wiggle = sbspline( 3, 3, 
  153.     list( list( ctlpt( E3, 0.01, 0.4, -1.0 ),
  154.                 ctlpt( E3, 0.4, -0.5, -0.9 ),
  155.                 ctlpt( E3, 0.7, 0.0, -0.4 ) ),
  156.           list( ctlpt( E3, -0.2, 1.2, -0.3 ),
  157.                 ctlpt( E3, 0.2, 0.0, -0.3 ),
  158.                 ctlpt( E3, 0.5, 0.6, 0.2 ) ),
  159.           list( ctlpt( E3, -0.3, 0.2, -0.2 ),
  160.                 ctlpt( E3, 0.1, -0.7, -0.1 ),
  161.                 ctlpt( E3, 0.4, -0.2, 0.4 ) ),
  162.           list( ctlpt( E3, -0.5, 0.8, 0.4 ),
  163.                 ctlpt( E3, -0.1, -0.3, 0.4 ),
  164.                 ctlpt( E3, 0.2, 0.3, 1.0 ) ),
  165.           list( ctlpt( E3, -0.6, -0.1, 0.5 ),
  166.                 ctlpt( E3, -0.2, -1.0, 0.6 ),
  167.                 ctlpt( E3, 0.1, -0.5, 1.2 ) ) ),
  168.     list( list( KV_OPEN ),
  169.           list( KV_OPEN ) ) );
  170. color(wiggle, green);
  171.  
  172. poly_approx_opt = 2;
  173. poly_approx_tol = 0.03;
  174. flat4ply = 1;
  175. p = gpolygon(wiggle, on);
  176. interact(list(wiggle, p));
  177.  
  178. poly_approx_opt = 0;
  179. flat4ply = 0;
  180. p = gpolygon(wiggle, on);
  181. interact(list(wiggle, p));
  182.  
  183. flat4ply = 1;
  184. p = gpolygon(wiggle, on);
  185. interact(list(wiggle, p));
  186.