Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  colors are mixed up when drawing 2d on a canvas3d  (Read 724 times)
0 Members and 1 Guest are viewing this topic.
Offline Usul

Senior Newbie




I hunt bugs


« Posted 2004-09-22 12:58:22 »

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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
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

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
Offline cweila2s

Senior Newbie




Java games rock!


« Reply #1 - Posted 2004-09-22 14:12:20 »

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?

Offline Usul

Senior Newbie




I hunt bugs


« Reply #2 - Posted 2004-09-22 14:39:50 »

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

Here is my output:



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

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cweila2s

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-09-23 08:15:16 »

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  Cheesy

Offline Usul

Senior Newbie




I hunt bugs


« Reply #4 - Posted 2004-09-23 09:44:28 »

The path betrayed me  Grin .  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.

It's times like this that I wish I'd listened to what my dad used to tell me.
Yeah? What was that?
I don't know. I never listened. 
- Dr. Venkman and Mr. Zeddemore
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!