import java.applet.Applet; import java.awt.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.SimpleUniverse; import com.sun.j3d.utils.image.*; import javax.media.j3d.*; import javax.vecmath.*; public class Muster2 extends Applet { public Muster2() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); Appearance a=new Appearance(); TextureLoader mustrilugeja=new TextureLoader("taust1.gif", this); ImageComponent2D pilt=mustrilugeja.getImage(); Texture2D muster = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, pilt.getWidth(), pilt.getHeight()); muster.setImage(0, pilt); a.setTexture(muster); juur.addChild(new Sphere(0.5f, Primitive.GENERATE_TEXTURE_COORDS, a)); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } public static void main(String[] args) { Frame f=new Frame("Mustriga kera"); f.add(new Muster2()); f.setSize(300, 300); f.setVisible(true); } }