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 Vahetus extends Applet { public Vahetus() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); Switch vaheti=new Switch(); vaheti.addChild(new ColorCube(0.2)); Cone cn=new Cone(0.2f, 0.4f); Cone cn2=new Cone(0.6f, 0.4f); cn.setAppearance(new Appearance()); cn2.setAppearance(new Appearance()); vaheti.addChild(cn); vaheti.addChild(cn2); SwitchValueInterpolator ip1= new SwitchValueInterpolator(new Alpha(), vaheti); vaheti.setCapability(Switch.ALLOW_SWITCH_WRITE); ip1.setSchedulingBounds(new BoundingSphere()); juur.addChild(vaheti); juur.addChild(ip1); ip1.setLastChildIndex(2); ip1.setFirstChildIndex(0); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } public static void main(String[] args) { Frame f=new Frame("Kujundite vahetus"); f.add(new Vahetus()); f.setSize(300, 300); f.setVisible(true); } }