Skip to main content

Java 3D meets JavaFX !

24 replies [Last post]
interactivemesh
Offline
Joined: 2006-06-07

Hi,

Java3D seems to be able to provide 3D rendering capabilities for JavaFX applications.

A JCanas3D encapsulated by a subclass of 'javafx.ext.swing.SwingComponent' can be added as a resizeable Node to a JavaFX Scene. So, an Effect can be associated to a JCanvas3D by setting the Node.effect attribute respectivally a JCanvas3D can be content of a parent's Effect.

A first sample is now available for launching and download at http://interactivemesh.org/testspace/j3dmeetsjfx.html.

So far, I saw a major issue concerning multithreadding. In JCanvas3D the Java3D rendering thread and the JavaFX/Swing event-dispatching thread (EDT) have access to a common BufferedImage object for rendering into resp. for reading from. To prevent deadlocks (EDT falls asleep !?) following settings are to be done:

- myView.setMinimumFrameCycleTime(30)
- myJCanvas3D.setResizeMode(JCanvas3D.RESIZE_DELAYED).

The heavyweight component Canvas3D is no alternative. It resides on top of the JavaFX scene nodes and is dragged involuntarily by the mouse.

August

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
interactivemesh
Offline
Joined: 2006-06-07

Hi, following text was posted on the JavaFX forum http://forums.sun.com/thread.jspa?threadID=5373702&start=15 , August

[b]A. JavaFX/Java 3D samples run on JavaFX runtime 1.3.1[/b]

Even if the FXCanvas3D APIs are not affected six out of seven sample programs were updated due to a new bug in the latest JavaFX release 1.3.1: The logical cross platform fonts (Dialog, Serif, etc.) overruns, although the text doesn't exceed the available space (Bug RT-9312). So, I switched to the JavaFX font 'Amble Cn'. The downloads include the updated sources. http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

[b]B. Extensible 3D / X3D-models integrated
[/b]
All 3D-models based on the external 3D file format VRML (*.wrl) were replaced with the successor format Extensible 3D (X3D, *.x3d). The new corresponding importer API XModelImporter J3D is of smaller size and loads significantly faster which results in shorter startup times. The downloads of FXScreenFlight, FXTuxInTheBox, FXPropellerPuzzle, and FXTuxInStereo include the new X3D-models and the importer API. For more details see http://forums.java.net/jive/thread.jspa?threadID=153078&tstart=0.

[b]C. JavaFX/Java 3D beats Flash/Papervision3D and Silverlight/Kit3D
[/b]
JavaFX, Flash and Silverlight were also tested concerning their 3D performances in the recently published diploma thesis 'Performance Analysis and Acceleration for Rich Internet Application Technologies' by Timo Ernst. On Windows JavaFX/Java 3D ran the 3D-test at 97 frames per second followed by Flash/Papervision3D at 19 fps and Silverlight/Kit3D at 2 fps. All results are available here http://www.timo-ernst.net/2010/09/a-scientific-performance-comparison-fl....

[b]D. JavaFX 2.0 : 3D ?[/b]

All 3D Java APIs which provide 3D capabilities in JavaFX 1.x applications depend on the package 'javafx.ext.swing'. This method of integrating Swing components will be not available anymore in JavaFX 2.0.

The published details about 3D support in JavaFX 2.0 during JavaOne 2010 are lacking the necessary substance to draw any serious conclusions yet.

"Judge us by what we ship, not what we say" Richard Bair wrote in his JavaFX 2.0 blog http://fxexperience.com/2010/09/javafx-2-0/. So, we have to wait for the first shipments in 2011. In the meantime we can keep 3D running with best performance in Java/Scala Swing and Eclipse/SWT.

interactivemesh
Offline
Joined: 2006-06-07

[b]Java 3D meets JavaFX 1.3.0[/b]

The [b]FXCanvas3D APIs[/b] are not affected and their current releases can still be used. 3D rendering into a BufferedImage object was improved in FXCanvas3DImage 2.0.

All [b]sample programs[/b] were 'broken' due to the incompatible JavaFX API-changes concerning layout. They are now released according to the 1.3 layout rules. Some samples have a new look (CSS) and they all use the new Tooltip and the preview of the PopupMenu. Just click through all of them to discover your favorite features. http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

August

interactivemesh
Offline
Joined: 2006-06-07

Hi,

[b]- Faster JavaFX 3D rendering[/b]

A different approach to synchronize Java 3D and JavaFX rendering can now be tested with the sample program [b]FXCharacterCube SB 4.0[/b]. A more serialized graphics device access of both pipelines reduces the time-consuming native 3D context switches. In addition, the two off-screen buffers can be replaced by a single one. This saves the time it takes to copy the buffer data.

Even if the public APIs of Java 3D and JavaFX provide only limited or no rendering callbacks the above mentioned approach results in a faster running rendering loop in comparison to the current FXCanvas3D API 2.0.

[b]- Stereoscopic JavaFX 3D rendering[/b]

The Swing based stereoscopic API JCanvas3DAnaglyph was ported to JavaFX: [b]FXCanvas3DAnaglyph[/b]. The sample program [b]FXTuxInStereo[/b] allows to switch from stereoscopic to monoscopic viewing. When rendering is in monoscopic mode the prototype of the new single buffer FXCanvas3D API is used.

[b]- Multiple simultaneous views [/b]

Sources, apidoc etc. of the multiple views API [b]FXCanvas3DMV[/b] and the corresponding sample [b]FXTuxInTheBox[/b] are now available for download.

This API is a derived work of the Java 3D utility class JCanvas3D and includes the Java classes FXCanvas3DMV and FXCanvas3DMVControl as well as the Java interface FXCanvas3DMVRepainter.

The following two objectives determine the current approach of the FXCanvas3DMV API:
- Java 3D renders off-screen simultaneously into several lightweight components which are added via a resizable JavaFX SwingComponent to a JavaFX Scene.
- The Java 3D rendering loop runs in parallel to the JavaFX painting loop with minimal synchronized overlap.

Each FXCanvas3DMV object provides two off-screen buffers to ensure that the threads of both loops can independently access the common image data. These two buffers consist of a BufferedImage which Java 3D is rendering into and a BufferedImage which JavaFX is drawing.

A FXCanvas3DMVControl object controls repainting and resizing of the FXCanvas3DMV objects with the help of a Lock with two Conditions. As soon as Java 3D has finished rendering into all attached and active FXCanvas3DMV objects for a single frame the FXCanvas3DMVControl object requests JavaFX to copy the image data and to repaint all corresponding SwingComponent objects in a single loop.

Only for the period of time it takes to copy the image data from one buffer into the other buffer the loops interrupt their regular tasks controlled by one of the two Lock's Conditions. The other Condition guarantees that during resizing of a FXCanvas3DMV panel the Java 3D renderer thread isn't blocked.

See http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

August

venacon
Offline
Joined: 2009-07-08

The instructions for Mac OS X aren't very good ones. I followed them, have tested the 3-D on the interactivemesh site, but I get the following error:

init:
deps-jar:
compile:
jar:
standard-run:
FXDistortString : Copyright (c) 2009 August Lammersdorf, www.InteractiveMesh.com.
Exception in thread "AWT-EventQueue-1" java.lang.IllegalStateException: Canvas3D: Illegal operation in off-screen mode
at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1679)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.createOffScreenBuffer(FXCanvas3D.java:605)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.access$2(FXCanvas3D.java:602)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$1.run(FXCanvas3D.java:409)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.sun.embeddedswing.EmbeddedEventQueue.dispatchEvent(EmbeddedEventQueue.java:440)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in trigger:
java.lang.IllegalStateException: Canvas3D: Illegal operation in off-screen mode
at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1679)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.createOffScreenBuffer(FXCanvas3D.java:605)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.access$2(FXCanvas3D.java:602)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.createCanvas(FXCanvas3D.java:404)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.setBounds(FXCanvas3D.java:373)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:809)
at java.awt.Container.layout(Container.java:1401)
at java.awt.Container.doLayout(Container.java:1390)
at java.awt.Container.validateTree(Container.java:1473)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validate(Container.java:1448)
at java.awt.Window.show(Window.java:516)
at java.awt.Component.show(Component.java:1302)
at java.awt.Component.setVisible(Component.java:1255)
at com.sun.javafx.tk.swing.WindowStage.setVisible(WindowStage.java:291)
at javafx.stage.Stage$_SBECL.onChange(Stage.fx:392)
at com.sun.javafx.runtime.location.BooleanVariable.notifyListeners(BooleanVariable.java:146)
at com.sun.javafx.runtime.location.BooleanVariable.replaceValue(BooleanVariable.java:94)
at com.sun.javafx.runtime.location.BooleanVariable.setAsBoolean(BooleanVariable.java:113)
at javafx.stage.Stage.set$visible(Stage.fx:391)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.lambda(DistortStringMain.fx:115)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.lambda(DistortStringMain.fx:115)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.invoke(DistortStringMain.fx:111)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.invoke(DistortStringMain.fx:111)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.invoke(DistortStringMain.fx:111)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringMain$1.invoke(DistortStringMain.fx:111)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.lambda(DistortStringUniverseFX.fx:66)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.lambda(DistortStringUniverseFX.fx:66)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.invoke(DistortStringUniverseFX.fx:65)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.invoke(DistortStringUniverseFX.fx:65)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.invoke(DistortStringUniverseFX.fx:65)
at com.interactivemesh.j3d.testspace.jfx.distortstring.DistortStringUniverseFX$1.invoke(DistortStringUniverseFX.fx:65)
at javafx.async.Task.impl_setDone(Task.fx:214)
at com.sun.javafx.async.CallbackHandler.setDone(CallbackHandler.fx:26)
at com.sun.javafx.async.TaskImpl$4.invoke(TaskImpl.java:77)
at com.sun.javafx.async.TaskImpl$4.invoke(TaskImpl.java:75)
at com.sun.javafx.runtime.Entry$2.run(Entry.java:105)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.sun.embeddedswing.EmbeddedEventQueue.dispatchEvent(EmbeddedEventQueue.java:440)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-1" java.lang.IllegalStateException: Canvas3D: Illegal operation in off-screen mode
at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1679)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.createOffScreenBuffer(FXCanvas3D.java:605)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.access$2(FXCanvas3D.java:602)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.createCanvas(FXCanvas3D.java:404)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.setBounds(FXCanvas3D.java:373)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:809)
at java.awt.Container.layout(Container.java:1401)
at java.awt.Container.doLayout(Container.java:1390)
at java.awt.Container.validateTree(Container.java:1473)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validate(Container.java:1448)
at com.sun.embeddedswing.EmbeddedPeer$Shell.validate(EmbeddedPeer.java:325)
at com.sun.embeddedswing.EmbeddedPeer$Shell$1.run(EmbeddedPeer.java:273)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.sun.embeddedswing.EmbeddedEventQueue.dispatchEvent(EmbeddedEventQueue.java:440)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
browser-run:
jws-run:
midp-run:
run:
BUILD SUCCESSFUL (total time: 1 minute 36 seconds)

interactivemesh
Offline
Joined: 2006-06-07

[b]To venacon[/b]

The thrown IllegalStateException "Canvas3D: Illegal operation in off-screen mode at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1679)" is an indication that an installed Java 3D version less than 1.5.x is used on your system.

Please, run the applet 'Check for Java 3D installation: JNLP Text3D' on my web page http://www.interactivemesh.org/testspace/jnlpappletlauncher.html. It prints a lot of properties into the Java console.

Also check if Apple's out-dated Java 3D version 1.3 is installed in System/Library/Java/Extensions/ on your Mac and have a look at the following

Links concerning Java 3D installation on Macs:

Java 3D Forum
- Newbie Mac owner: http://forums.java.net/jive/thread.jspa?messageID=353167
- Java3d and OS X: http://forums.java.net/jive/thread.jspa?messageID=334842

Java 3D 1.5.2 Release Notes: https://j3d-core.dev.java.net/j3d1_5_2/RELEASE-NOTES.html
- System Requirements Mac OS X
- JOGL Rendering Pipeline

Java3DInstallation: http://wiki.java.net/bin/view/Javadesktop/Java3DInstallation
- Installing Java3D for Mac OS X 10.4

Download Java 3D: https://java3d.dev.java.net/binary-builds.html
- Zip binaries j3d-1_5_2-macosx.zip (includes 'Instructions for Unzipping the Java 3D 1.5.2 Release' in README-unzip.html)

Download JOGL: https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=11509&ex...
- jogl-1.1.1a-macosx-universal.zip

[b]To all[/b]

- Please, could someone who ran these JavaFX/Java3D samples successfully on a Mac post here how Java 3D is installed. Thanks.

- Since my last post here I posted my "Thoughts about JavaFX 3D Rendering" in the sibling thread "JavaFX 3D powered by Java 3D" http://forums.sun.com/thread.jspa?threadID=5373702.

- Latest news: Ken Russell (kbr), JOGL API project owner, is leaving Sun. See Chris Oliver's Weblog http://blogs.sun.com/chrisoliver/

August

interactivemesh
Offline
Joined: 2006-06-07

Hi,

some JavaFX related issues concerning the sample program [b]FXPropellerPuzzle[/b] are now solved. Please, see the JavaFX forum for more details: http://forums.sun.com/thread.jspa?threadID=5373702&tstart=150 .

The Java 3D feature 'multiple Views / Canvas3Ds' requires a specific approach to synchronize the loops of Java 3D and JavaFX. A new sample program [b]FXTuxInTheBox[/b] is now available as an 'early access' version.

See http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

August

interactivemesh
Offline
Joined: 2006-06-07

Hi,

a new sample program is now available (early access): [b]FXPropellerPuzzle[/b]. The 3D scene of an animated propeller engine is rendered into several puzzle pieces. The puzzle board is resizeable from 2x2 up to 8x8 pieces on a screen of 1200 pixels height.

The underlying lightweight canvas [b]API FXCanvas3DImage[/b] provides access to the off-screen buffer image. This BufferedImage object is not drawn into the corresponding JPanel and therefore can be used by the application directly.

See http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

August

zesharp
Offline
Joined: 2006-12-21

Hi August

I'm having the following exception:

[code]
java.lang.NoClassDefFoundError: com/sun/j3d/loaders/ParsingErrorException
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.start$impl(PropellerUniverseFX.fx:64)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.start(PropellerUniverseFX.fx:27)
at javafx.async.AbstractAsyncOperation.userInit$(Unknown Source)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.userInit$(PropellerUniverseFX.fx:27)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.initialize$(PropellerUniverseFX.fx:27)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerPuzzleMain.javafx$run$(PropellerPuzzleMain.fx:295)
Caused by: java.lang.ClassNotFoundException: com.sun.j3d.loaders.ParsingErrorException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.start$impl(PropellerUniverseFX.fx:64)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.start(PropellerUniverseFX.fx:27)
at javafx.async.AbstractAsyncOperation.userInit$(Unknown Source)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.userInit$(PropellerUniverseFX.fx:27)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerUniverseFX.initialize$(PropellerUniverseFX.fx:27)
at com.interactivemesh.j3d.testspace.jfx.propellerpuzzle.PropellerPuzzleMain.javafx$run$(PropellerPuzzleMain.fx:295)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.runtime.provider.AWT_EDT_RuntimeProvider$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

[/code]

interactivemesh
Offline
Joined: 2006-06-07

Hi zesharp,

please check all your Java 3D installations if the Java 3D utilities archive 'j3dutils.jar' is available in '../jre/lib/ext/'. I got the identical exception when I removed this file. Did you start the sample program per [launch incl. Java 3D] as well? Did it run?

Good luck! August

zesharp
Offline
Joined: 2006-12-21

Thanks!
This is amazing !! Congratulations ;)

interactivemesh
Offline
Joined: 2006-06-07

Hi,

current improvements within the lightweight Java 3D rendering loop also effect JavaFX applications and applets.

[b]FXCanvas3D 2.0[/b] speeds up its lightweight 3D rendering.

The java.awt.Graphics class provides a 'drawImage()' method which flips the image vertically on the fly while drawing. This allows to choose off-screen buffers in 'yUp' mode. In consequence the memory for an image is saved as well as the time required to copy it within the ImageComponent2D object which Java 3D is directly rendering into.

This new version and updated sample programs are now available at http://www.interactivemesh.org/testspace/j3dmeetsjfx.html

August

chebetos
Offline
Joined: 2009-04-06

Hi,

I download and execute the examples, and I made my own JavaFX stage with a color cube; as a stand alone application ran perfectly, but as an applet threw the following exception in the java console:

[code]
Exception in thread "AWT-EventQueue-8" java.lang.IllegalStateException: Canvas3D: Illegal operation in off-screen mode
at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1775)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.createOffScreenBuffer(FXCanvas3D.java:583)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.access$200(FXCanvas3D.java:540)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$1.run(FXCanvas3D.java:397)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
getFXCanvas3D();
Exception in thread "AWT-EventQueue-8" java.lang.IllegalStateException: Canvas3D: Illegal operation in off-screen mode
at javax.media.j3d.Canvas3D.stopRenderer(Canvas3D.java:1775)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.createOffScreenBuffer(FXCanvas3D.java:583)
at com.interactivemesh.j3d.community.gui.FXCanvas3D$InternalCanvas3D.access$200(FXCanvas3D.java:540)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.createCanvas(FXCanvas3D.java:392)
at com.interactivemesh.j3d.community.gui.FXCanvas3D.ancestorAdded(FXCanvas3D.java:307)
at javax.swing.AncestorNotifier.fireAncestorAdded(Unknown Source)
at javax.swing.AncestorNotifier.propertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.awt.Component.firePropertyChange(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at firstjavafxsphere.FXCanvas3DComp.initFXCanvas3D$impl(FXCanvas3DComp.fx:66)
at firstjavafxsphere.FXCanvas3DComp.initFXCanvas3D(FXCanvas3DComp.fx:37)
at firstjavafxsphere.Main$1.lambda(Main.fx:54)
at firstjavafxsphere.Main$1.invoke(Main.fx:52)
at firstjavafxsphere.Main$1.invoke(Main.fx:52)
at firstjavafxsphere.MainUniverseFX.onCompletion$impl(MainUniverseFX.fx:50)
at firstjavafxsphere.MainUniverseFX.onCompletion(MainUniverseFX.fx:27)
at javafx.async.AbstractAsyncOperation$1AsyncOperationListener$anon11.onCompletion(Unknown Source)
at com.sun.javafx.runtime.async.AbstractAsyncOperation$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
[/code]

How could I do to run the examples and my javafx stages as applets?

interactivemesh
Offline
Joined: 2006-06-07

Hi chebetos,

my assumption is that applets on your system are using a different Java installation with an older Java 3D version. Please, could you check which Java version is assigned to applications resp. applets in the 'Java Control Panel'. Alternatively, run the applet 'Check for Java 3D installation: JNLP Text3D' on my web page http://www.interactivemesh.org/testspace/jnlpappletlauncher.html. It prints a lot of properties into the Java console. Java 3D version 1.5.0 or better 1.5.2 should be installed.

If your applets still don't run, please provide us with the Java related console output. Good luck!

August

chebetos
Offline
Joined: 2009-04-06

Thanks very much!!!

I had an older version of Java3D installed (1.4.0); I upgrade and now it's works.

tmilard
Offline
Joined: 2004-03-25

> I had an older version of Java3D installed (1.4.0); upgrade and now it's works.

==> Oh boy how long will we have to wait java 7 to avoid this type of dum but so x$@@@!!!!!????? issues. I think java3D will benefits greatly ....

cheers

interactivemesh
Offline
Joined: 2006-06-07

Hi,

thanks a lot to all of you for testing the samples and sending your feedback. Below I describe how Java 3D can provide 3D rendering in JavaFX 1.1 applications and applets. For more details see also the source code and the apidoc which are now available for download: http://interactivemesh.org/testspace/j3dmeetsjfx.html.

[b]FXCanvas3D enables JavaFX to draw the Virtual Universe.[/b]

The following two objectives determine the current approach of the FXCanvas3D API:

1. Java 3D renders offscreen into a lightweight component which is added via a resizable JavaFX SwingComponent to a JavaFX Scene.
2. The Java 3D rendering loop runs in parallel to the JavaFX painting loop with synchronized minimal overlapping.

The Java class [b]FXCanvas3D[/b] and the Java interface [b]FXCanvas3DRepainter[/b] are the sources of this API.

Since Java 3D 1.5 lightweight 3D rendering is available through JCanvas3D as a subclass of JPanel. JCanvas3D is designed for the Swing painting loop but doesn't interact very well with JavaFX resp. vice versa (see posts above).

The implementation of FXCanvas3D is a derived work (not a subclass) of JCanvas3D and is available under its license conditions (BSD).

A [b]Double Offscreen Buffer[/b] and a controlling [b]Lock with two Conditions[/b] were introduced to ensure that the threads of both loops access the common image data deadlock-free. These two buffers consist of a BufferedImage which Java 3D is rendering into and a BufferedImage which JavaFX is drawing. Both images have an identical format type. Only for the period of time to copy integer values from the first into the second image the loops interrupt their regular tasks controlled by one of the two Lock's Condition. The other Condition guarantees that during resizing of a FXCanvas3D panel the Java 3D renderer thread isn't blocked.

The web page samples provide an implementation of the corresponding SwingComponent named as FXCanvas3DComp. This JavaFX class has the interface FXCanvas3DRepainter implemented and allows a FXCanvas3D object to call 'repaintFXCanvas3D()' from its 'postSwap()' method. The repaint request is handled by a [b]FX.deferAction() [/b]- an equivalent to SwingUtilities.invokeLater() - and will be executed on the EDT. The assigned function calls firstly 'copyOffScreenBuffer()' while the Java 3D renderer thread is waiting and secondly 'repaint()' on the FXCanvas3D object.

This completes the cycle of 3D offscreen rendering and image drawing. The duration of one cyle on a multi-core system can be estimated at [i]( max(Java 3D loop, JavaFX loop) + image copying + thread handling ) ms[/i]. The cost of the extra BufferedImage in comparison to JCanvas3D is about [i]( image.width x image.height x 4 ) bytes[/i] of CPU memory.

[b]Notes[/b]

To initiate the Java 3D engine, the 3D scene, and the FXCanvas3D object asynchronously per 'async operation' (see reference) seems to be reliable and effective. Both samples are implemented in this way.

The JavaFX loop is not yet synchronized with the monitor's vertical refresh. Therefore, visual artifacts might appear on the display. The JVM argument '-Dcom.sun.scenario.animation.vsync=true' may solve this (JavaFX bugs RT-1088/1198).

The samples' JavaFX script coding should not be considered as best practice. I'm really missing my beloved BoxLayout.

[b]References[/b]

Deploy A Rich Internet Application Developed With JavaFX Technology, Cindy Castillo
http://javafx.com/docs/tutorials/deployment

JavaFX Async operations, James Clarke
http://blogs.sun.com/clarkeman/entry/javafx_async_operations

Using Java Objects Within JavaFX Programs, Michael Heinrichs
http://java.sun.com/developer/technicalArticles/scripting/javafx/javafx_...

August

interactivemesh
Offline
Joined: 2006-06-07

Hi,

while I'm preparing the description of my implementation you are invited to run a new and an updated sample as a Java Web Start application resp. as a browser applet on the brand new JavaFX Runtime 1.1. Please be so kind as to report every single issue.

The new sample 'FXCharacterCube' allows to apply several JavaFX effects to the 3D scene and to pick a single character and the cube (as long as it is visible). Both samples display the 'frames per second' rate during 3D interaction/animation. So influences of effects and frame sizes can be easily seen. Enjoy. http://interactivemesh.org/testspace/j3dmeetsjfx.html

August

darwinjob
Offline
Joined: 2004-11-16

Works perfect!
I'm deadly curious about the description :)

DD

interactivemesh
Offline
Joined: 2006-06-07

Hi,

version 2 of 'FXDistortString' is now available for testing. Please, do some stress-tests: 3D scene rotation, state changes, and resizing. Fortunately, I can't generate deadlocks anymore.

Thanks in advance for posting your issues.

August

darwinjob
Offline
Joined: 2004-11-16

[b]WOW![/b]
It works! No deadlocks anymore!

interactivemesh
Offline
Joined: 2006-06-07

Hi,

a second sample 'FXDistortString' has been published. The 3D scene consistent of a continually distorted text string will be reflected by applying the JavaFX Reflection effect. The 3D geometry is generated by the factory String3D/AWTShapeExtruder and morphed by a derived version of the DistortBehavior (Java 3D example DistortGlyph).

To prevent deadlocks two further measures were taken:

- Reducing priority for all Java 3D threads: VirtualUniverse.setJ3DThreadPriority(3).

- JavaFX asynchronous operation: the Java 3D engine, the 3D scene, and the JCanvas3D are initialized asynchronously according to the sample in Clarkeman's Weblog http://blogs.sun.com/clarkeman/entry/javafx_async_operations.

Unfortunately, an user interaction can still result in a frozen window. So, further hints how to improve interoperation of JavaFX 1.0 and Java 3D are welcome.

See http://interactivemesh.org/testspace/j3dmeetsjfx.html

August

zesharp
Offline
Joined: 2006-12-21

I say WOW !!!

Works fine in my XP with NVidia vcard ;)

darwinjob
Offline
Joined: 2004-11-16

Hmm...

My config is:
XP Pro SP2
GeForce 7600 GS 256M
ForceWare 169.21
JRE version 1.6.0_05 Java HotSpot(TM) Client VM
Java3d - as specified in jnlp file (not installed).

I'm going to upgrade to everything latest and try again.

darwinjob
Offline
Joined: 2004-11-16

I was going to say WOW... The radio buttons work fine, but when I rotate the scene with the mouse it freezes after random amount of time. The only way out is Task Manager - End Task. I guess that is the issue you have described.