/* */ import java.awt.*; import java.lang.*; public class Test1 extends BufferedApplet { int w, h; Cuboid c = new Cuboid(0.3,0.05,0.05); Cuboid c1 = new Cuboid(0.3,0.05,0.05); Cuboid co = new Cuboid(0.05,0.05,0.2); Sphere s = new Sphere(0.2,Math.PI/16); Torus t = new Torus(0.1,Math.PI/16); Cylinder cy = new Cylinder(0.125,0.2, Math.PI/16); Cone cy1 = new Cone(0.15,0.2,Math.PI/16); Matrix3D camera = new Matrix3D(); public void init() { super.init(); w = bounds().width; h = bounds().height; initializeMatrixStackForAnimationFrame(); } public void render(Graphics g) { g.setColor(Color.black); g.fillRect(0,0,w,h); double time = System.currentTimeMillis() / 1000.0; initializeMatrixStackForAnimationFrame(); g.setColor(Color.blue); camera.identityMatrix(); //camera.printMatrix(); camera.translate(0.5*Math.cos(time),0.5+Math.sin(time),0.5); m().invert(camera); push(); rotateX(Math.PI/64); rotateY(Math.PI); rotateZ(Math.PI/32); c.copy(m()); c.transformPerspective(0.4); c.render(g, w, h); push(); translate(0.6,0,0); c1.copy(m()); c1.transformPerspective(0.4); c1.render(g, w, h); pop(); push(); translate(0.3,0.20,0); s.copy(m()); s.transformPerspective(0.4); s.render(g,w,h); push(); co.copy(m()); co.transformPerspective(0.4); co.render(g,w,h); pop(); push(); translate(0.0,0.20,0); cy.copy(m()); cy.transformPerspective(0.4); cy.render(g,w,h); pop(); push(); translate(0.0,0.20,-0.2); cy1.copy(m()); cy1.transformPerspective(0.4); cy1.render(g,w,h); pop(); pop(); push(); translate(0.30,0.20,0); t.copy(m()); t.transformPerspective(0.4); t.render(g,w,h); pop(); pop(); animating = true; } }