Kovalan
Muniandy
Accompanying
software for Computer Animation:
Algorithms and Techniques book by
Dr.
Richard Parent

Animation: http://www.cis.ohio-state.edu/~muniandy/cis793/hillview.mpg
VertexList cp = getCurvePoints();
Transform3D
viewTrans = new Transform3D();
Transform3D
translationTrans = new Transform3D();
Vector3d
translate = new Vector3d();
for ( int
index=0; index < cp.getCount(); index++ ) {
Vertex v = cp.getAt( index );
translate.set( v.getRealX(), v.getRealY(), v.getRealZ() );
translationTrans.setIdentity();
translationTrans.setTranslation( translate
);
viewTrans.set( initTrans );
viewTrans.mul( translationTrans );
vpTransGroup.setTransform(
viewTrans );
}

Animation: http://www.cis.ohio-state.edu/~muniandy/cis793/ease.mpg
Transform3D
xf = new Transform3D();
final
Vector3d maxMove = new Vector3d( 700, 0, -20.0 );
Vector3d move
= new Vector3d( 0, 0, 0 );
Transform3D
moveXf = new Transform3D();
for ( double
distance=0.0; distance <= 1.0; distance+=0.002 ) {
double u = doEase? Ease.simple( distance ) : distance;
move.x = maxMove.x*u;
move.z = maxMove.z*u;
xf.set( move );
xf.mul( objectXf );
examineGroup.setTransform( xf );
}
Animation: http://www.cis.ohio-state.edu/~muniandy/cis793/spaceshp.mpg
VertexList cp = new VertexList(); // List
of control points
cp.add( 0, 0,
0);
cp.add( 2.5,
5.0, 8.0 );
cp.add( 5,
-5.0, 16.0 );
cp.add( 20.0,
0.0, 55.0 );
CubicBSplineCurve
curve = new CubicBSplineCurve( cp );
curve.enableArcLength( doEnableArcLen, 300.0,
doEase ); // 300 frames
VertexList
points = curve.getPoints();
Transform3D
xf = new Transform3D();
Vector3d
translate = new Vector3d();
for ( int
index=0; index < points.getCount(); index++ ) {
Vertex v = points.getAt( index );
translate.set( v.getRealX(), v.getRealY(), v.getRealZ() );
xf.setIdentity();
xf.setTranslation( translate );
xf.mul( objectXf );
examineGroup.setTransform( xf );
}

Animation: http://www.cis.ohio-state.edu/~muniandy/cis793/fly.mpg
// Setup FFD
around the bird
Point3d x0 =
new Point3d( max.x, min.y, max.z );
Vector3d s = new
Vector3d( -(max.x-min.x), 0, 0 );
Vector3d t =
new Vector3d( 0, (max.y-min.y), 0 );
Vector3d u =
new Vector3d( 0, 0, -(max.z-min.z) );
int l=6, m=6,
n=6;
FFD ffd = new FFD();
ffd.getLattice().set( x0, s, t, u, l, m, n );
// Get
deformed points
// Flap the
wings by pulling the grid points of the FFD.
// Right
wing: (2, 6, 0) +60z (up) +60y -60z (down)
// Left
wing: (2, 0, 0) +60z (up) -60y -60z
(down)
int
MAX_MOVE=60, INCREMENT=6, ARRAY_SIZE=MAX_MOVE/INCREMENT;
Point3d
up[][] = new Point3d[ARRAY_SIZE][];
Point3d
down[][] = new Point3d[ARRAY_SIZE][];
// Flip up
incrementally
int j=1;
for ( int
i=0; i < ARRAY_SIZE; i++ ) {
pt = ffd.getLattice().getGridPt( 2, 6, 0 ); // right wing
pt.z = j;
ffd.getLattice().setGridPt( 2, 6, 0, pt );
pt = ffd.getLattice().getGridPt( 2, 0, 0 ); // left wing
pt.z = j;
ffd.getLattice().setGridPt( 2, 0, 0, pt );
up[i] = ffd.deform( birdPts );
j += INCREMENT;
}