import com.sun.j3d.utils.image.TextureLoader; import com.sun.j3d.utils.behaviors.mouse.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; public class nagu extends Applet { private java.net.URL texImage = null; public BranchGroup createSceneGraph() { BranchGroup juur = new BranchGroup(); TransformGroup keerd = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setScale(0.5); keerd.setTransform(t3d); juur.addChild(keerd); TransformGroup keerd1 = new TransformGroup(); keerd1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); keerd1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); keerd.addChild(keerd1); Sphere keer = new Sphere(1.0f, Sphere.GENERATE_TEXTURE_COORDS, 50); Appearance ap = keer.getAppearance(); keerd1.addChild(keer); TextureLoader pilt = new TextureLoader(texImage, this); ap.setTexture(pilt.getTexture()); BoundingSphere p = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); MouseRotate liiguta = new MouseRotate(keerd1); keerd1.addChild(liiguta); liiguta.setSchedulingBounds(p); juur.compile(); return juur; } public nagu (){ } public nagu(java.net.URL foto) { texImage = foto; } public void init() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup se = createSceneGraph(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(se); } public static void main(String args[]) { java.net.URL foto = null; try { foto = new java.net.URL("file:asi.jpg"); } catch (java.net.MalformedURLException ex){} new MainFrame(new nagu(foto), 750, 750); } }