home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / 3d / irit / contrib / scripts / hammer.irt < prev    next >
Encoding:
Text File  |  1995-01-29  |  4.7 KB  |  224 lines

  1. save_res = resolution;
  2. resolution = 20;
  3. save_mat = view_mat;
  4. #view_mat = view_mat * scale(vector(0.2, 0.2, 0.2));
  5. iritstate("Coplanar", false);
  6.  
  7. #
  8. # build nose for hammer
  9. #
  10. cylin1= cylin(vector(0, -4 , -0.1), vector(0, 0, 4.2), 8.1) * rotz( 2 );
  11. cylin2= cylin(vector(3.43, -4.92, -1), vector(0, 0, 6), 6) * rotz( 4 );
  12. #interact(list(cylin1, cylin2));
  13.  
  14. nose = cylin1 - cylin2;
  15. free(cylin1);
  16. free(cylin2);
  17. #interact(nose);
  18.  
  19. b1 = box(vector(6, -0.1, -1), -18, -18, 6);
  20. #interact(list(nose, b1));
  21.  
  22. nose = nose - b1;
  23. free(b1);
  24. #interact(nose);
  25.  
  26. b3 = box(vector(-0.1, -1, -1), -9, 6, 6);
  27. #interact(list(b3, nose));
  28.  
  29. nose = nose - b3;
  30. free(b3);
  31. #interact(nose);
  32.  
  33. body = box(vector(0.1, -0.25, -0.15), -6, 4.6, 4.3);
  34. #interact(list(body, nose));
  35.  
  36. body = body + nose;
  37. free(nose);
  38. #interact(body);
  39.  
  40. # up
  41. b2 = box(vector(2, 0, -1), -11, -1, 6);
  42. body = body - b2;
  43. free(b2);
  44. #interact(body);
  45.  
  46. # down 
  47. b2 = box(vector(2, 4, -1), -10, 2, 6);
  48. body = body - b2;
  49. free(b2);
  50. #interact(body);
  51.  
  52. # left 
  53. b3 = box(vector(-8, -4, 0), 20, 16, -1);
  54. body = body - b3;
  55. free(b3);
  56. #interact(body);
  57.  
  58. # right 
  59. b4 = box(vector(-8, -4, 4), 20, 16, 1);
  60. body = body - b4;
  61. free(b4);
  62. #interact(body);
  63.  
  64.  
  65. # build hole
  66. cylin3 = cylin(vector(3, -3, 2), vector(0, 7, 0), 0.7);
  67. box1 = box(vector(3, -3, 1.3), 7, 7, 1.4);
  68. #interact(list(cylin3,box1));
  69. hole1 = cylin3 + box1;
  70. free(cylin3);
  71. free(box1);
  72.  
  73. body = body - hole1;
  74. free(hole1);
  75. #interact(body);
  76.  
  77. # correct body
  78. box1 = box(vector(-5, -1, -1), -2, 6, 6);
  79. sph1 = sphere( vector(-4.3, 2, 2), 3 );
  80. hole3 = box1 - sph1;
  81. free(sph1);
  82. free(box1);
  83. body = body - hole3;
  84. free(hole3);
  85. #interact(body);
  86.  
  87. # add conus
  88. cone1 = cone(vector(-9, 2, 2), vector(8, 0, 0), 2);
  89. body = body + cone1;
  90. free(cone1);
  91. #interact(body);
  92.  
  93. #correct conus
  94. box4 = box(vector(-8, -1, -1), -4, 6, 6);
  95. cone4 = cone(vector(-7, 2, 2), vector(-7, 0, 0), 2.5);
  96. hole2 = box4 - cone4;
  97. #interact(list(body, hole2));
  98. free(box4);
  99. free(cone4);
  100.  
  101. body = body - hole2;
  102. free(hole2);
  103.  
  104. color( body, white );
  105. #interact(body);
  106.  
  107. # Build Klin
  108. klin = box(vector(0, 0, 0), 2.9, 3.0, 1);
  109. b1 = box(vector(0, 0, 0), 5, 5, 2)*rotx(7)*trans( vector(-1, -1, 0.5));
  110. klin = klin - b1;
  111.  
  112. b2 = box(vector(0, 0, 0), 5, 5, -2)*rotx(-7)*trans( vector(-1, -1, 0.5));
  113. klin = klin - b2;
  114.  
  115. klin = klin*trans(vector(-4.0, 2.2, 1.5));
  116. color(klin, cyan);
  117. #interact(klin);
  118.  
  119. # build handle
  120. # build handle bases
  121.  
  122. crc0 = circle( vector(0,0,0), 2.2) * rotx(90) 
  123.        * scale(vector(1, 1, 0.7))
  124.        * trans(vector(-2.5, -26.5, 2));
  125. crc1 = circle( vector(0,0,0), 2.5) * rotx(90) 
  126.        * scale(vector(1, 1, 0.7))
  127.        * trans(vector(-2.5, -25, 2));
  128. crc2 = circle( vector(0,0,0), 1.5) * rotx(90) 
  129.        * scale(vector(1, 1, 0.6))
  130.        * trans(vector(-2.5, 0, 2));
  131. crc3 = circle( vector(0,0,0), 1.9) * rotx(90) 
  132.        * scale(vector(1, 1, 0.6))
  133.        * trans(vector(-2.5, 6.3, 2));
  134. end_crc = circle( vector(0,0,0), 0.00001 );
  135. handle = sFromCrvs( list( trans( vector(-2.5, -26.5, 2))*end_crc,
  136.                           crc0, crc1, crc2, crc3,
  137.                           trans( vector(-2.5, 4.4, 2))*end_crc), 3 );
  138. free( crc0 );
  139. free( crc1 );
  140. free( crc2 );
  141. free( crc3 );
  142. free( end_crc );
  143.  
  144. #show the hammer
  145. #save("hammer1", list(body, handle, klin) );
  146. interact( list(body, handle, klin) );
  147.  
  148. #
  149. # build nail
  150. #
  151.  
  152. resolution = 10;
  153. cyl1= cylin(vector(0, 0, 2), vector(-0.5, 0, 0), 1);
  154. cyl2= cylin(vector(-0.48, 0, 2), vector(-10.2, 0, 0), 0.3);
  155. con = cone(vector(-10.5, 0, 2), vector(-1, 0, 0), 0.3);
  156. color(con, cyan);
  157. #interact( list(cyl1, cyl2, con));
  158.  
  159. nail1 = cyl1 + cyl2;
  160. color(nail1, cyan);
  161. free( cyl1 );
  162. free( cyl2 );
  163. #interact( list(nail1, con) );
  164.  
  165. # build matrix for the nail
  166. nail_mat = rotz(37)*trans(vector(-35.0, -12.0, 0));
  167. nail1 = nail_mat * nail1;
  168. con = nail_mat * con;
  169.  
  170. #
  171. # Build wall
  172. #
  173.  
  174. wall = box(vector(0, 0, 0), 2, 30, 20);
  175. wall = wall*trans(vector(-46.5,-30,-10));
  176. color(wall, MAGENTA);
  177.  
  178. #show hammer and nail
  179. #save("hammer2", list(body, handle, klin, nail1, con, wall) );
  180. interact( list(body, handle, klin, nail1, con, wall) );
  181.  
  182. # animate hammer
  183.  
  184. #initialize moving matrix
  185. matr1 = trans(vector(0,0,0));
  186. matr2 = trans(vector(0,0,0));
  187.  
  188. for( j=1, 1, 4,
  189.     # move hammer to the nail
  190.     for( i=1, 1, 35,
  191.         matr1 = matr1*trans(vector(-0.8, 0, 0))*rotz(1):
  192.         view( list(matr1*body, matr1*handle, matr1*klin,
  193.                    matr2*nail1, matr2*con, wall), TRUE)
  194.     ):
  195.  
  196.     #move nail with hammer
  197.     for( i=1, 1, 2,
  198.         matr1 = matr1*trans(vector(-0.8, 0, 0))*rotz(1):
  199.         matr2 = matr2*trans(vector(-0.8, 0, 0))*rotz(1):
  200.         view( list(matr1*body, matr1*handle, matr1*klin, 
  201.                    matr2*nail1, matr2*con, wall), TRUE)
  202.     ):
  203.  
  204.     #return hammer
  205.     for( i=1, 1, 35,
  206.         matr1 = matr1*trans(vector(0.8, 0, 0))*rotz(-1):
  207.         view( list(matr1*body, matr1*handle, matr1*klin, 
  208.                    matr2*nail1, matr2*con, wall), TRUE)
  209.     )
  210. );
  211.  
  212. # Free variables
  213. free( handle );
  214. free(body);
  215. free(wall);
  216. free( con );
  217. free( nail1 );
  218. #free( nail );
  219.  
  220. resolution = save_res;
  221. view_mat = save_mat;
  222.  
  223.  
  224.