JCanvas3D on OSX Java 7

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

JCanvas3D on OSX Java 7

joshP
I anyone using a JCanvas3D on Mac java 7?
I'm writing a netbeans platform app and I'm getting the offset problems that other people have been experiencing with a straight Canvas3D so I'm trying to use a JCanvas3D to render offscreen. The problem I'm having is that when the offscreen buffer is read back from openGL the alpha values are all set to 0. The colour components of the buffer are correct (the scene seems to have been drawn properly), but when I draw it to the screen nothing gets drawn since the alpha channel is empty.

I'm not doing any manual choosing of pixel formats or anything - just using a minimal Java3D hello world :
---------------------------------------------------------------------------
BranchGroup bg = new BranchGroup();
        ColorCube cube = new ColorCube(0.4f);
        bg.addChild(cube);

         // background colour
        Background background = new Background(new Color3f(0f, 1f, 0));        
        background.setApplicationBounds(sphere);
        bg.addChild(background);

// JCanvas
        JCanvas3D jCanvas = new JCanvas3D();
        //jCanvas.setResizeMode(JCanvas3D.RESIZE_IMMEDIATELY);
        this.add("Center", jCanvas);
        Dimension dim = new Dimension(100, 100);
        jCanvas.setPreferredSize(dim);
        jCanvas.setSize(dim);

        Canvas3D c = jCanvas.getOffscreenCanvas3D();

        SimpleUniverse u = new SimpleUniverse(c);
        u.getViewingPlatform().setNominalViewingTransform();
        bg.compile();
        u.addBranchGraph(bg);

---------------------------------------------------------------------------

I've traced it through and the data actually being returned in JoglPipeline.readOffscreenBuffer already has the alpha set to 0. The setup for the readPixels operation looks ok, so I'm assuming the issue must be in the original creation of the GL context or something?

I'm using the latest Java3D compiled from the trunk in Github and the "2.0.2-rc20130404" version of Jogl pushed to maven recently which claimed to have sorted out all Mac Java 7 issues.

Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

InteractiveMesh
All my quick offscreen tests (Java 3D exampels) were successful:
 - org.jdesktop.j3d.examples.jcanvas3d.JCanvas3DExample
 - org.jdesktop.j3d.examples.offscreen_canvas3d.OffScreenTest
 - org.jdesktop.j3d.examples.print_canvas3d.PrintCanvas3D

System:
 - Mac OS X 10.7.5, JDK 7u21
 - JOGL 2.0.2-rc-20130404
 - Harvey's 1.6.0-pre7 builds from http://jogamp.org/deployment/java3d/1.6.0-pre7/

But I can't test any netbeans platform app.

August
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

elotter
In reply to this post by joshP
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

elotter
From what I read online in mostly very old forum posts, there are some indicators that JCanvas3D will be significantly slower than Canvas3D. Is this still a valid statement, and is it so for Harvey's Java3D? Or would it be practical to in all cases use JCanvas3D instead of Canvas3D (and perhaps then solve the canvas-in-netbeans-platform-application-on-mac-on-jdk7 issue?)
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

hharrison
Nothing has really changed to make JCanvas3d more or less efficient in my version I'm afraid.

Harvey
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

InteractiveMesh
In reply to this post by joshP
JCanvas3DOB provides another lightweight 3D canvas which is similar to JCanvas3D, see:
http://www.interactivemesh.org/testspace/j3dmeetsswing.html#leightweight
Please, give it a try and check if it behaves as JCanvas3D does.

The alpha value of the framebuffer's clearing color is set per frame to 1.0 (default) or to 0.0 if the Java 3D system property "transparentOffScreen" is set to true (-Dj3d.transparentOffScreen=true). But, whenever a not transparent Shape3D is rendered it should be seen on the screen in both scenarios.

Yes, JCanvas3D and JCanvas3DOB are "significantly" slower than Canvas3D. Reading the pixels from the GPU into the CPU is the most critical bottleneck beside the time needed to write them back.

With my latest Java 3D improvements the frame rate will increase from 50 fps to 80 fps or 120 fps for a lightweight 3D canvas of size 1920x1200 pixels in Swing and JavaFX2. Even with 500 TransformInterpolators, 3,000 Shape3Ds and 7,000,000 triangles the frame rate remains above 60 fps in the faster mode on Win 7-64, JKD 7, i5-2500K, GeForce GTX 560 Ti. These performance features should also run in Harvey's fork, most likely this summer (not tested yet).

August
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

joshp
well - I'm back. Sorry for the silence, It's been a hectic week for me.

I'll try JCanvas3DOB again  - I tried it before without luck, but maybe I have a better understanding now (it was late at night last time, and I'm afraid I can't remember what the problem was).

In the meantime I have to admit that I tried to get JMonkeyEngine to work - I'm afraid my project is getting a bit urgent and I'm looking for anything that will help me out of a tight spot at the moment. The LWJGL renderer in JME does seem to work ok in when embedded in a netbeans canvas - at least on my laptop, but for some reason, even with an apparently identical java/gl environment on my desktop machine it fails with an error about loading the jawt native libraries.

I then tried JMonkeyEngine with GouesseJ's Jogl renderer - interestingly, even though it appears to be based on Newt, it seems to have exactly the same behaviour as Canvas3D when running in netbeans - i.e. the 3d canvas always appears at the bottom left of the parent window.

I'd really rather not use JMonkeyEngine if I could use Java3D - apart from the apparently rather obnoxious attitude of the user community it really doesn't seem architected for anything other than running a single window game engine, and I really just want a fairly simple scenegraph 3d view as part of a larger application. So I'll give it one more go to get Java3D working again....
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

hharrison
Any chance you can just use plain swing instead of netbeans?

Harvey
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

gouessej
Administrator
In reply to this post by joshp
joshp wrote
In the meantime I have to admit that I tried to get JMonkeyEngine to work - I'm afraid my project is getting a bit urgent and I'm looking for anything that will help me out of a tight spot at the moment. The LWJGL renderer in JME does seem to work ok in when embedded in a netbeans canvas - at least on my laptop, but for some reason, even with an apparently identical java/gl environment on my desktop machine it fails with an error about loading the jawt native libraries.

I then tried JMonkeyEngine with GouesseJ's Jogl renderer - interestingly, even though it appears to be based on Newt, it seems to have exactly the same behaviour as Canvas3D when running in netbeans - i.e. the 3d canvas always appears at the bottom left of the parent window.
I agree with Harvey (but it should work with Netbeans RCP too) and I would prefer bugs and performance improvements on the basic canvases of Java3D to be done directly in Java3D rather than in a third party library. It doesn't mean that libraries written above Java3D have no interest but they shouldn't become an absolute necessity. I highly encourage August to contribute and he already helped us a lot in the past :)

@joshp please use the very latest version of JOGL 2.0, recompile Java3D if necessary. If there is still a problem with the position of the canvas, write a bug report, provide a small test case.

In my humble opinion, it will be difficult to make Java3D evolve, some design flaws complicates this task. A merge of Java3D with Xith3D would be interesting but I don't advise to use Java3D on the long term in industrial applications. You can try Ardor3D too and I remind you that JMonkeyEngine 3 still uses an "old" build of JOGL 2.0, I haven't updated for several weeks or months. Tell me what you need to do with a scenegraph.

The JOGL renderer of JMonkeyEngine 3 can use both AWT or NEWT. Ardor3D offers a bigger choice, you can use the NEWT AWT bridge too.

If you really want to have serious troubles on some hardware, switch to the competitor of JOGL but you will lose the advantages of the render quirks and you will have to explain to your customers why your software crashes and why you can't do anything to solve their problems. Moreover, the renderer that relies on our competitor doesn't use its third version, expect a major rewrite in some months (at least before the release of the stable release) with possible regressions. Then, the renderer based on JOGL 2 will be already more stable than this. I'm not here to defend our competitor. We sometimes collaborate but I know why I have used JOGL since 2006.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JCanvas3D on OSX Java 7

InteractiveMesh
In reply to this post by joshp
 - Does the Java 3D example "org.jdesktop.j3d.examples.jcanvas3d.JCanvas3DExample" run properly on your Mac/JDK 7? Download last zip-file on https://java3d.java.net/binary-builds.html .
 
 - Could you make your "hello world" Netbeans project available here for download? Would like to test it on my Mac.
 
August