import java.applet.Applet; import java.awt.*; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.SimpleUniverse; import com.sun.j3d.utils.behaviors.keyboard.*; import javax.media.j3d.*; import javax.vecmath.*; public class Plaat2 extends Applet { public Plaat2() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); juur.addChild(looSein(2, -10, -2, -10)); //x1, z1, x2, z2 juur.addChild(looSein(3, -7, 3, -12)); AmbientLight taustavalgus=new AmbientLight(); taustavalgus.setInfluencingBounds(new BoundingSphere(new Point3d(), 1000)); juur.addChild(taustavalgus); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } Shape3D looSein(double x1, double z1, double x2, double z2){ QuadArray nurgad=new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS); nurgad.setCoordinate(0, new Point3d( x1, 0, z1)); nurgad.setCoordinate(1, new Point3d( x1, 5, z1)); nurgad.setCoordinate(2, new Point3d( x2, 5, z2)); nurgad.setCoordinate(3, new Point3d( x2, 0, z2)); Shape3D kujund=new Shape3D(); kujund.setGeometry(nurgad); Appearance a=new Appearance(); a.setMaterial(new Material()); kujund.setAppearance(a); return kujund; } public static void main(String[] args) { Frame f=new Frame("Plaat"); f.add(new Plaat2()); f.setSize(300, 300); f.setVisible(true); } }