sábado, 26 de marzo de 2011

GRAFICAS PRIMER CUBO

import com.sun.j3d.utils.applet.MainFrame;
import javax.swing.*;
import java.awt.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.*;
import java.applet.Applet;
public final class CUBO extends Applet
{
    public CUBO()
    {
        setLayout(new BorderLayout());
        GraphicsConfiguration config=SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas=new Canvas3D(config);
        add("Center",canvas);
        BranchGroup escena=createsceneGraph();
        escena.compile();
        SimpleUniverse simple_uni=new SimpleUniverse(canvas);
        simple_uni.getViewingPlatform().setNominalViewingTransform();
        simple_uni.addBranchGraph(escena);
    }//fin del constructor
   
    public BranchGroup createsceneGraph()
    {
        BranchGroup obj=new BranchGroup();
        obj.addChild(new ColorCube(0.5));
       
        return obj;
     
    }
    public static void main(String args[])
    {
        Frame frame= new MainFrame(new CUBO(),400,400);
    }
}
//RECORDAR INSTALAR LA API
//http://www.oracle.com/technetwork/java/javase/tech/index-jsp-138252.html

No hay comentarios:

Publicar un comentario