}
/*
* For realistic movement, we want a big acceleration on the straightaways.
*/
Interpolator initialSpline = new SplineInterpolator(1.00f, 0.00f, 0.2f, .2f);
Interpolator straightawaySpline = new SplineInterpolator(0.50f, 0.20f, .50f, .80f);
Interpolator curveSpline = new SplineInterpolator(0.50f, 0.20f, .50f, .80f);
Interpolator finalSpline = new SplineInterpolator(0.50f, 0.00f, .50f, 1.00f);
Interpolator[] interps = { null, initialSpline, curveSpline, straightawaySpline, curveSpline, straightawaySpline, curveSpline,
straightawaySpline, finalSpline };
final KeyFrames.Builder<Point> builder = new KeyFrames.Builder<Point>(values[0]);
for (int i = 1; i < values.length; i++) {
builder.addFrame(values[i], times[i], interps[i]);
}
final KeyFrames<Point> keyFrames = builder.build();
/*
* This PropertySetter enables the animation for the car movement all the
* way around the track.
*/
final TimingTarget modifier = PropertySetter.getTarget(basicGUI.getTrack(), "carPosition", keyFrames);
animator.addTarget(modifier);
/*
* Now create similar keyframes for rotation of car.
*/
int[] rotationKeyValues = { 360, 315, 270, 225, 180, 135, 90, 45, 0 };
Interpolator straightawayTurnSpline = new SplineInterpolator(1.0f, 0.0f, 1.0f, 0.0f);
Interpolator curveTurnSpline = new SplineInterpolator(0.0f, 0.5f, 0.5f, 1.0f);
Interpolator[] rotationInterps = { null, straightawayTurnSpline, curveTurnSpline, straightawayTurnSpline, curveTurnSpline,
straightawayTurnSpline, curveTurnSpline, straightawayTurnSpline, curveTurnSpline };
final KeyFrames.Builder<Integer> rotationBuilder = new KeyFrames.Builder<Integer>(rotationKeyValues[0]);
for (int i = 1; i < values.length; i++) {
rotationBuilder.addFrame(rotationKeyValues[i], times[i], rotationInterps[i]);