import java.applet.Applet; import java.awt.*; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.SimpleUniverse; import javax.media.j3d.*; import javax.vecmath.*; public class Kuupkeerdnihe2 extends Applet { public Kuupkeerdnihe2() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); Transform3D t3d1=new Transform3D(); t3d1.setTranslation(new Vector3f(0.5f, 0, 0)); Transform3D keerd1=new Transform3D(); keerd1.rotX(Math.PI/4); t3d1.mul(keerd1); TransformGroup tg1=new TransformGroup(t3d1); juur.addChild(tg1); tg1.addChild(new ColorCube(0.5)); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } public static void main(String[] args) { Frame f=new Frame("Nihutatud ja keeratud kuup"); f.add(new Kuupkeerdnihe2()); f.setSize(300, 300); f.setVisible(true); } }