Skip to main content

Simple box example - background problem jre7

2 replies [Last post]
tomtem
Offline
Joined: 2012-02-15
Points: 0

Hi,
I'm using java 3D to display a simple wireframe box, on a red background. Problems are:
- sometimes the entire canvas is colored in red, the box seems to disappear behind the background color
- sometimes only the box is visible on a black background (instead of red)
- when i resize the frame a little, the image changes between one of the above states ...
my code:

SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
Appearance app = new Appearance();
//Create the polygon attributes
PolygonAttributes polyAttr = new PolygonAttributes();
//Set them so that the draw mode is polygon line
polyAttr.setPolygonMode(PolygonAttributes.POLYGON_LINE);
//Use these in the appearance
app.setPolygonAttributes(polyAttr);
Box box = new Box(0.1f, 0.1f, 0.1f, app);
group.addChild(box);
universe.getCanvas().setBackground(Color.red);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);

i want a cube on a red background, but i randomly get one of following states:
http://www.ttweb.be/problem.jpg

what am i doing wrong ? any help would be appreciated

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mikelizzi2
Offline
Joined: 2011-10-13
Points: 0

Ouch !!!

I just updated to jre7 and got the same errors on my long standing GOOD app.

I switched back to jre6 and the errors went away.

How do we tell Oracle that jre7 breaks Java3D when they don't support it anymore?

tomtem
Offline
Joined: 2012-02-15
Points: 0

i ran my simple example with jre6 and it worked perfectly, thx for solving it!,
but you are also saying Java3D doesnt work with jre7 ?? so basicly i shouldn't use Java3D anymore in the future ?

(btw i also changed my code a little, to use a background color do:
Background background = new Background();
background.setColor(255, 0, 0);
background.setCapability(Background.ALLOW_COLOR_WRITE);
group.addChild(background);
)