home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / 3d / irit / scripts / puz_anim.irt < prev    next >
Encoding:
Text File  |  1995-02-14  |  4.2 KB  |  166 lines

  1. #
  2. # Simple (and not so simple) 3D puzzles animated using animation curves.
  3. #
  4. #                    Gershon Elber, January 1994
  5. #
  6.  
  7. save_mat = view_mat;
  8.  
  9. #############################################################################
  10. # StickStar
  11. #
  12. sqrt2 = sqrt( 2 );
  13. eps = 0.015;
  14. rad = 0.3;
  15. len = ( rad + eps ) * 2;
  16. ItemAux1 = box( vector( -rad / sqrt2, -rad / sqrt2, -len ),
  17.             rad * 2 / sqrt2, rad * 2 / sqrt2, len * 2 ) * rz( 45 );
  18. ItemAux2 = ( ItemAux1 * tx( rad ) -
  19.          ItemAux1 * rotx( 90 ) * tz( rad + eps ) -
  20.          ItemAux1 * rotx( 90 ) * tz( -rad - eps ) ) * tx( eps / 2 );
  21. diag = len + eps;
  22. diagPoly = poly( list( vector( diag, diag, 0 ),
  23.                vector( -diag, diag, 0 ),
  24.                vector( -diag, 0, diag ),
  25.                vector(  diag, 0, diag ) ),
  26.         false);
  27. Item1 = ItemAux2 - diagPoly
  28.          - diagPoly * sy( -1 )
  29.          - diagPoly * sz( -1 )
  30.          - diagPoly * sz( -1 ) * sy( -1 );
  31. Item1 = convex( Item1 );
  32. color(Item1, red);
  33.  
  34. Item2 = Item1 * sx( -1 );
  35. color(Item2, magenta);
  36.  
  37. Item3 = Item1 * rx( 90 ) * rz( 90 );
  38. color(Item3, green);
  39.  
  40. Item4 = Item1 * rx( 90 ) * rz( -90 );
  41. color(Item4, yellow);
  42.  
  43. Item5 = Item1 * rx( 90 ) * ry( 90 );
  44. color(Item5, blue);
  45.  
  46. Item6 = Item1 * rx( 90 ) * ry( -90 );
  47. color(Item6, cyan);
  48.  
  49. Grp1 = list( Item2, Item3, Item5 );
  50. Grp2 = list( Item1, Item4, Item6 );
  51.  
  52. scl = creparam( cbspline( 3,
  53.               list( ctlpt( E1,  1.0 ),
  54.                     ctlpt( E1,  1.0 ),
  55.                        ctlpt( E1,  5.0 ) ),
  56.               list( KV_OPEN ) ),
  57.         0, 1 );
  58.  
  59. mov_xyz = creparam( cbspline( 4,
  60.                       list( ctlpt( E3,  0,   0,   -3 ),
  61.                     ctlpt( E3, -1,   1,   -3 ),
  62.                     ctlpt( E3, -0.5, 0.5, -0.5 ),
  63.                     ctlpt( E3,  0.0, 0.0,  0.0 ) ),
  64.                   list( KV_OPEN ) ),
  65.             0, 1 );
  66. rot_x = creparam( cbspline( 4,
  67.                 list( ctlpt( E1,  250 ),
  68.                       ctlpt( E1,  100 ),
  69.                       ctlpt( E1,  0 ),
  70.                          ctlpt( E1,  0 ) ),
  71.                 list( KV_OPEN ) ),
  72.           0, 1 );
  73. rot_y = creparam( cbspline( 4,
  74.                 list( ctlpt( E1,  350 ),
  75.                       ctlpt( E1,  100 ),
  76.                          ctlpt( E1,  0 ),
  77.                          ctlpt( E1,  0 ) ),
  78.                 list( KV_OPEN ) ),
  79.           0, 1 );
  80. rot_z = creparam( cbspline( 4,
  81.                 list( ctlpt( E1, -200 ),
  82.                       ctlpt( E1,  100 ),
  83.                          ctlpt( E1,  0 ),
  84.                          ctlpt( E1,  0 ) ),
  85.           list( KV_OPEN ) ),
  86.           0, 1 );
  87.  
  88. attrib( Grp1, "animation", list( rot_x, rot_y, rot_z, mov_xyz, scl ) );
  89. free( mov_xyz );
  90.  
  91. mov_xyz = creparam( cbspline( 4,
  92.                       list( ctlpt( E3, 0,    0,   3 ),
  93.                     ctlpt( E3, 1,   -1,   3 ),
  94.                     ctlpt( E3, 0.5, -0.5, 0.5 ),
  95.                     ctlpt( E3, 0.0,  0.0, 0.0 ) ),
  96.                   list( KV_OPEN ) ),
  97.             0, 1 );
  98. attrib( Grp2, "animation", list( rot_y, rot_z, rot_x, mov_xyz, scl ) );
  99.  
  100. free( mov_xyz );
  101. free( rot_x );
  102. free( rot_y );
  103. free( rot_z );
  104.  
  105. All = list( Grp1, Grp2 );
  106.  
  107. view_mat = sc( 0.2 ) * rotx( 40 ) * roty( 30 );
  108.  
  109. interact( list( All, view_mat ) );
  110. save( "puz1anim", All );
  111.  
  112. #############################################################################
  113.  
  114. scl = creparam( cbspline( 3,
  115.               list( ctlpt( E1,  5.0 ),
  116.                     ctlpt( E1,  5.0 ),
  117.                     ctlpt( E1,  2.0 ),
  118.                        ctlpt( E1,  2.0 ),
  119.                 ctlpt( E1,  5.0 ),
  120.                     ctlpt( E1,  5.0 ) ),
  121.               list( 0, 0, 0, 1, 2, 3, 4, 4, 4 ) ),
  122.         0, 1 );
  123.  
  124. mov_x = creparam( cbspline( 3,
  125.                 list( ctlpt( E1, 0 ),
  126.                   ctlpt( E1, 0 ),
  127.                   ctlpt( E1, 2 ),
  128.                   ctlpt( E1, 0 ),
  129.                   ctlpt( E1, 0 ) ),
  130.                 list( 0, 0, 0, 1, 1, 2, 2, 2 ) ),
  131.           0, 1 );
  132. mov_y = mov_x;
  133. mov_z = mov_x;
  134. attrib( Item1, "animation", list( mov_x, scl ) );
  135. attrib( Item3, "animation", list( mov_y, scl ) );
  136. attrib( Item6, "animation", list( mov_z, scl ) );
  137. free( mov_x );
  138. free( mov_y );
  139. free( mov_z );
  140.  
  141.  
  142. mov_x = creparam( cbspline( 3,
  143.                 list( ctlpt( E1, 0 ),
  144.                   ctlpt( E1, 0 ),
  145.                   ctlpt( E1, -2 ),
  146.                   ctlpt( E1, 0 ),
  147.                   ctlpt( E1, 0 ) ),
  148.                 list( 0, 0, 0, 1, 1, 2, 2, 2 ) ),
  149.           0, 1 );
  150. mov_y = mov_x;
  151. mov_z = mov_x;
  152. attrib( Item2, "animation", list( mov_x, scl ) );
  153. attrib( Item4, "animation", list( mov_y, scl ) );
  154. attrib( Item5, "animation", list( mov_z, scl ) );
  155. free( mov_x );
  156. free( mov_y );
  157. free( mov_z );
  158.  
  159. All = list( Item1, Item2, Item3, Item4, Item5, Item6 );
  160. interact( All );
  161. save( "puz2anim", All );
  162.  
  163. #############################################################################
  164. view_mat = save_mat;
  165. viewobj( view_mat );
  166.