Un texte 2D
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Novembre 2001 */
import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class SimpleText2D extends Applet {
public BranchGroup createSceneGraph(SimpleUniverse u) {
BranchGroup objRoot = new BranchGroup();
TransformGroup objTrans = new TransformGroup();
objRoot.addChild(objTrans);
Transform3D t3D = new Transform3D();
t3D.setTranslation(new Vector3d(-0.7,-0.2,0.0)) ;
objTrans.setTransform(t3D);
Shape3D text;
text = new Text2D("IUP Info",
new Color3f(1.0f,1.0f,0.0f),
"Serif",
100,
Font.BOLD);
objTrans.addChild(text);
objRoot.compile();
return objRoot;
}
public SimpleText2D() {
setLayout(new BorderLayout());
GraphicsConfiguration config;
config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add("Center",c);
SimpleUniverse u = new SimpleUniverse(c);
BranchGroup scene = createSceneGraph(u);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(scene);
}
public static void main(String[] args) {
new MainFrame(new SimpleText2D(),300,100);
}
}
Remarques,erreurs
nicolas.janey@univ-fcomte.fr