home *** CD-ROM | disk | FTP | other *** search
- #
- # Simple (and not so simple) 3D puzzles animated using animation curves.
- #
- # Gershon Elber, January 1994
- #
-
- save_mat = view_mat;
-
- #############################################################################
- # StickStar
- #
- sqrt2 = sqrt( 2 );
- eps = 0.015;
- rad = 0.3;
- len = ( rad + eps ) * 2;
- ItemAux1 = box( vector( -rad / sqrt2, -rad / sqrt2, -len ),
- rad * 2 / sqrt2, rad * 2 / sqrt2, len * 2 ) * rz( 45 );
- ItemAux2 = ( ItemAux1 * tx( rad ) -
- ItemAux1 * rotx( 90 ) * tz( rad + eps ) -
- ItemAux1 * rotx( 90 ) * tz( -rad - eps ) ) * tx( eps / 2 );
- diag = len + eps;
- diagPoly = poly( list( vector( diag, diag, 0 ),
- vector( -diag, diag, 0 ),
- vector( -diag, 0, diag ),
- vector( diag, 0, diag ) ),
- false);
- Item1 = ItemAux2 - diagPoly
- - diagPoly * sy( -1 )
- - diagPoly * sz( -1 )
- - diagPoly * sz( -1 ) * sy( -1 );
- Item1 = convex( Item1 );
- color(Item1, red);
-
- Item2 = Item1 * sx( -1 );
- color(Item2, magenta);
-
- Item3 = Item1 * rx( 90 ) * rz( 90 );
- color(Item3, green);
-
- Item4 = Item1 * rx( 90 ) * rz( -90 );
- color(Item4, yellow);
-
- Item5 = Item1 * rx( 90 ) * ry( 90 );
- color(Item5, blue);
-
- Item6 = Item1 * rx( 90 ) * ry( -90 );
- color(Item6, cyan);
-
- Grp1 = list( Item2, Item3, Item5 );
- Grp2 = list( Item1, Item4, Item6 );
-
- scl = creparam( cbspline( 3,
- list( ctlpt( E1, 1.0 ),
- ctlpt( E1, 1.0 ),
- ctlpt( E1, 5.0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
-
- mov_xyz = creparam( cbspline( 4,
- list( ctlpt( E3, 0, 0, -3 ),
- ctlpt( E3, -1, 1, -3 ),
- ctlpt( E3, -0.5, 0.5, -0.5 ),
- ctlpt( E3, 0.0, 0.0, 0.0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
- rot_x = creparam( cbspline( 4,
- list( ctlpt( E1, 250 ),
- ctlpt( E1, 100 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
- rot_y = creparam( cbspline( 4,
- list( ctlpt( E1, 350 ),
- ctlpt( E1, 100 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
- rot_z = creparam( cbspline( 4,
- list( ctlpt( E1, -200 ),
- ctlpt( E1, 100 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
-
- attrib( Grp1, "animation", list( rot_x, rot_y, rot_z, mov_xyz, scl ) );
- free( mov_xyz );
-
- mov_xyz = creparam( cbspline( 4,
- list( ctlpt( E3, 0, 0, 3 ),
- ctlpt( E3, 1, -1, 3 ),
- ctlpt( E3, 0.5, -0.5, 0.5 ),
- ctlpt( E3, 0.0, 0.0, 0.0 ) ),
- list( KV_OPEN ) ),
- 0, 1 );
- attrib( Grp2, "animation", list( rot_y, rot_z, rot_x, mov_xyz, scl ) );
-
- free( mov_xyz );
- free( rot_x );
- free( rot_y );
- free( rot_z );
-
- All = list( Grp1, Grp2 );
-
- view_mat = sc( 0.2 ) * rotx( 40 ) * roty( 30 );
-
- interact( list( All, view_mat ) );
- save( "puz1anim", All );
-
- #############################################################################
-
- scl = creparam( cbspline( 3,
- list( ctlpt( E1, 5.0 ),
- ctlpt( E1, 5.0 ),
- ctlpt( E1, 2.0 ),
- ctlpt( E1, 2.0 ),
- ctlpt( E1, 5.0 ),
- ctlpt( E1, 5.0 ) ),
- list( 0, 0, 0, 1, 2, 3, 4, 4, 4 ) ),
- 0, 1 );
-
- mov_x = creparam( cbspline( 3,
- list( ctlpt( E1, 0 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 2 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ) ),
- list( 0, 0, 0, 1, 1, 2, 2, 2 ) ),
- 0, 1 );
- mov_y = mov_x;
- mov_z = mov_x;
- attrib( Item1, "animation", list( mov_x, scl ) );
- attrib( Item3, "animation", list( mov_y, scl ) );
- attrib( Item6, "animation", list( mov_z, scl ) );
- free( mov_x );
- free( mov_y );
- free( mov_z );
-
-
- mov_x = creparam( cbspline( 3,
- list( ctlpt( E1, 0 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, -2 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ) ),
- list( 0, 0, 0, 1, 1, 2, 2, 2 ) ),
- 0, 1 );
- mov_y = mov_x;
- mov_z = mov_x;
- attrib( Item2, "animation", list( mov_x, scl ) );
- attrib( Item4, "animation", list( mov_y, scl ) );
- attrib( Item5, "animation", list( mov_z, scl ) );
- free( mov_x );
- free( mov_y );
- free( mov_z );
-
- All = list( Item1, Item2, Item3, Item4, Item5, Item6 );
- interact( All );
- save( "puz2anim", All );
-
- #############################################################################
- view_mat = save_mat;
- viewobj( view_mat );
-