import java.awt.*; import render.*; public class mycube1 extends RenderApplet { Geometry box; Material boxMaterial; double amplitude = 0.0; public void initialize() { setBgColor(.4,.4,.8); addLight(1,1,1, 1,1,1); addLight(-1,-1,-1, 1,1,1); box = getWorld().add().cube(); boxMaterial = new Material(); boxMaterial.setAmbient(.2,0,0); boxMaterial.setDiffuse(.8,0,0); box.setMaterial(boxMaterial); } public void animate(double time) { Matrix m = box.getMatrix(); m.identity(); double a = amplitude * Math.sin(30 * time); double b = amplitude * Math.cos(30 * time); m.rotateX(a); m.rotateY(b); m.scale(1 + a, 1 + b, 1); amplitude *= 0.95; } public boolean mouseUp(Event e, int x, int y) { amplitude = 0.5; return true; } }