import java.applet.Applet; import java.awt.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.SimpleUniverse; import javax.media.j3d.*; import javax.vecmath.*; public class Valgus5a extends Applet { public Valgus5a() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); Appearance a=new Appearance(); a.setMaterial(new Material()); BranchGroup juur = new BranchGroup(); Transform3D t31=new Transform3D(); t31.setTranslation(new Vector3f(0, 0.3f, 0)); TransformGroup tg1=new TransformGroup(t31); tg1.addChild(new Sphere(0.2f, Sphere.GENERATE_NORMALS, a)); juur.addChild(tg1); Transform3D t32=new Transform3D(); t32.setTranslation(new Vector3f(0, -0.4f, 0)); TransformGroup tg2=new TransformGroup(t32); tg2.addChild(new Sphere(0.2f, Sphere.GENERATE_NORMALS, a)); juur.addChild(tg2); SpotLight kohtvalgus=new SpotLight( new Color3f(Color.green), new Point3f(-0.5f, -0.7f, 0), new Point3f(0, 0, 1), new Vector3f(1, 1, 0), (float)Math.PI/8, 0.5f ); kohtvalgus.setInfluencingBounds(new BoundingSphere()); juur.addChild(kohtvalgus); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } public static void main(String[] args) { Frame f=new Frame("Kohtvalgus kahele kerale"); f.add(new Valgus5a()); f.setSize(300, 300); f.setVisible(true); } }