colors are mixed up when drawing 2d on a canvas3d

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

Hmmm, I tested it and it runs good with proper colors! Thus the problem doesn’t seem to be with Java3D! Do you have this occur with other applications too? When drawing a colored geometry?

well, thats strange. but with normal 2d-jcomponent applications everything is fine. i am only having this problem with the canvas3d. ???

Here is my output:

http://www.steffen-kobilke.de/problem.jpg

Edit: As you can see, I added some colors, but otherwise it is still exactly the same sourcecode.

Why don’t you try an applet like HelloUniverse and see wether the color cube is ok or not? It should show the basic colors.

P.S.: Greetings from Germany to Germany :smiley:

The path betrayed me ;D . Gruesse zurueck.

Well, the HelloUniverse example that comes with Java3D shows the cube rotating with the colors yellow, green, blue and red (in that order), and I cant view the top or the bottom in that example. Are these the right colors?

But I already messed around with Java3D a litte, and it seems that the colors are allright, when using pure 3D.

Could you e-mail me your compiled *.class files? Then I could see if maybe my java compiler is messed up. I guess I should re-install it then. Or its something else on my computer, which interfers with java. Hmm. Strange. But plz, e-mail me the compiled *.class files
skobilke@gmx.de

Thanx for helping, in case I havent mentioned.