import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.geometry.Box;
import javax.media.j3d.BranchGroup;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.image.*;
public class DreiD {
public DreiD() {
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
Appearance BoxAppearance = new Appearance();
TransformGroup BoxTG = new TransformGroup(),RotTG = new TransformGroup();
Transform3D BoxT3D = new Transform3D();
AmbientLight ALgt = new AmbientLight(new Color3f(0f,1f,0f));
BoundingSphere BigBounds = new BoundingSphere(new Point3d(),2000000000);
ALgt.setInfluencingBounds(BigBounds);
group.addChild(ALgt);
BoxT3D.setTranslation(new Vector3f(0,0,0));
BoxAppearance.setMaterial(new Material(new Color3f(0f,0f,1f),new Color3f(1f,0f,0f),new Color3f(1f,0f,0f),new Color3f(1f,1f,1f), 1f));
BoxAppearance.setTexture((new TextureLoader("Kachel.jpg",null)).getTexture());
BoxAppearance.setTexCoordGeneration(new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,TexCoordGeneration.TEXTURE_COORDINATE_2));
BoxAppearance.setTextureAttributes(new TextureAttributes(TextureAttributes.REPLACE,new Transform3D(),new Color4f(),TextureAttributes.NICEST));
BoxAppearance.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_FRONT, 0f));
BoxTG.setTransform(BoxT3D);
BoxTG.addChild(RotTG);
RotTG.addChild(new Box(10,2,20,Box.GENERATE_NORMALS_INWARD,BoxAppearance));
group.addChild(BoxTG);
universe.getViewingPlatform().setNominalViewingTransform();
TransformGroup ViewTG;
Transform3D ViewT3D = new Transform3D();
ViewTG = universe.getViewingPlatform().getViewPlatformTransform();
ViewTG.getTransform(ViewT3D);
ViewT3D.setTranslation(new Vector3f(0,0,5f));
ViewT3D.setRotation(new AxisAngle4f(0,1,0,(float)Math.toRadians(20)));
ViewTG.setTransform(ViewT3D);
KeyBehavior KeyCtrl = new KeyBehavior(universe.getViewingPlatform().getViewPlatformTransform());
KeyCtrl.setSchedulingBounds(BigBounds);
group.addChild(KeyCtrl);
universe.addBranchGraph(group);
}
public static void main(String[] args) {
new DreiD();
}
}