hi,
I decided to start a new topic for my problem.
I have to very simple classes. The first one creates a simple universe. The second one extends canvas3d, so that I am able to draw in 2d on top of it. But the colors are all mixed up. Here are my two classes (they compile):
Well, if anyone could take a quick look at these short two classes (they compile and show the problem), I really would appreciate that.
Test2d.class:
import java.awt.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.swing.*;
public class Test2d extends JFrame
{
public Test2d ()
{
getContentPane().setLayout(new BorderLayout());
Canvas3D c = new Visual_Canvas3D(SimpleUniverse.getPreferredConfiguration());
getContentPane().add("Center", c);
SimpleUniverse simpleU = new SimpleUniverse(c);
BranchGroup scene = new BranchGroup();
simpleU.getViewingPlatform().setNominalViewingTransform();
scene.compile();
simpleU.addBranchGraph(scene);
}
public static void main(String[] args)
{
Test2d mainApp = new Test2d();
mainApp.setSize(800,600);
mainApp.show();
}
}
Visual_Canvas3D.class:
import java.awt.*;
import javax.media.j3d.*;
public class Visual_Canvas3D
extends Canvas3D
{
public Visual_Canvas3D(GraphicsConfiguration gc)
{
super(gc);
}
public void postRender()
{
J3DGraphics2D g = getGraphics2D();
g.setColor(Color.red);
g.drawString("red",20,320);
g.setColor(Color.green);
g.drawString("green",20,340);
g.setColor(Color.orange);
g.drawString("orange",20,360);
g.setColor(Color.yellow);
g.drawString("yellow",20,100);
g.flush(false);
}
}
I really dont know what to do. If anyone could take a quick look (maybe compile), that would really make me happy.
thanx,
Usul