Becareful when you try to just view the text. When you
disable the thread you must also comment out the
canvas.stopRender() in the lines above.... The text
will then show.
I have attached your file that I worked with.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.GraphicsEnvironment;
import java.awt.Font;
public class PureImmediate extends Applet implements Runnable {
private Canvas3D canvas;
private GraphicsContext3D gc = null;
private Geometry cube = null, cube1=null;
//private ColorCube cube = null, cube1=null;
Shape3D shape = new Shape3D();
private Transform3D cmt = new Transform3D();
Material sphereMaterial = new Material();
Appearance sphereAppearance = new Appearance();
private Alpha rotAlpha = new Alpha(-1, 6000);
private SimpleUniverse u = null;
public void render() {
if (gc == null) {
gc = canvas.getGraphicsContext3D();
gc.setBufferOverride(true);
gc.setAppearance(new Appearance());
cube = new ColorCube(0.3).getGeometry();
cube1=new ColorCube(0.2).getGeometry();
}
double angle = rotAlpha.value() * 2.0*Math.PI;
cmt.rotY(angle);
gc.setStereoMode(GraphicsContext3D.STEREO_LEFT);
gc.clear();
gc.setModelTransform(cmt);
gc.draw(cube);
canvas.swap();
gc.setStereoMode(GraphicsContext3D.STEREO_RIGHT);
gc.clear();
cmt.rotX(angle);
cmt.rotZ(angle);
gc.setModelTransform(cmt);
gc.draw(cube1);
canvas.swap();
}
public void run() {
while (true) {
render();
Thread.yield();
}
}
public PureImmediate() {
}
public void init() {
setLayout(new BorderLayout());
GraphicsConfigTemplate3D g3d = new GraphicsConfigTemplate3D();
g3d.setStereo(GraphicsConfigTemplate3D.REQUIRED);
GraphicsConfiguration config = GraphicsEnvironment.
getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getBestConfiguration(g3d);
canvas = new Canvas3D(config);
canvas.setStereoEnable(true);
canvas.stopRenderer();
add("Center", canvas);
Font3D f3d = new Font3D(new Font("TestFont", Font.PLAIN, 1),
new FontExtrusion());
Text3D txt = new Text3D(f3d, "I am here Testing",
new Point3f(0.0f, 0.0f, 0.0f));
Appearance app=new Appearance();
Material mat=new Material();
app.setMaterial(mat);
shape.setAppearance(app);
shape.addGeometry(txt);
shape.setCapability( Shape3D.ALLOW_GEOMETRY_READ );
Background background = new Background( new Color3f(1.0f,1.0f,1.0f) );
background.setApplicationBounds( new BoundingSphere ( new Point3d(0,0,0), 100.0
) );
u = new SimpleUniverse(canvas);
BranchGroup group=new BranchGroup();
group.addChild(shape);
group.addChild( new ColorCube(0.2) );
u.addBranchGraph(group);
u.getViewingPlatform().setNominalViewingTransform();
new Thread(this).start();
}
public void destroy() {
u.cleanup();
}
public static void main(String[] args) {
new MainFrame(new PureImmediate(), 500, 400);
}
}