//
import render.*; import java.awt.*; public class PollyTrack extends RenderApplet { Polly polly; double theta = 0; public boolean keyUp(Event e, int key) { // SET ACTIONS VIA KEYBOARD if (! super.keyUp(e, key)) action(key - 'a'); return true; } public void action(int a) { polly.setAction(a); } // SELECT AN ACTION public void initialize() { // INITIALIZE EVERYTHING addLight(1,1,1, 1,1,1); // LIGHTS addLight(0,-1,0, 1,1,1); setBgColor(.2,.2,.8); // BACKGROUND COLOR setFL(6); // CAMERA FOCAL LENGTH push(); rotateX(Math.PI/6); rotateY(9 * Math.PI / 8); transform(world); // INITIAL VIEW ANGLE pop(); world.add().setMaterial((new Material()).setColor(1,1,1).setTransparency(.5)); world.child[0].cylinder(20); push(); // MAKE THE TRANSPARENT FLOOR scale(3,.001,3); rotateX(Math.PI/2); transform(world.child[0]); pop(); world.add(polly = new Polly()); // CREATE POLLY } double prevTime = 0, size = .8, radius = 2; public void animate(double time) { // ANIMATE ONE FRAME polly.animate(time); push(); rotateY(theta); translate(radius,0,0); scale(size,size,size); transform(polly); pop(); if (prevTime == 0) prevTime = time; theta += size * polly.getTravel(time - prevTime) / radius; prevTime = time; } }