3D Scene Support in JavaFX TV

Did you know JavaFX TV supports 3D?

JavaFX TV is built on the new Prism toolkit that is built for 3D accelerated graphics hardware. There is new API in JavaFX 1.3 that takes advantage of the 3D features. Transforms like Translate and Rotate now have the third coordinate: "z". They can be used to transform the scene graph nodes in three dimensions. Additionally there is a Scene camera API which can be used to set perspective or parallel camera for the scene.

Here is a sample application demonstrating the 3D scene features. In this sample a single text node is rotated around the "y" axis and is shown using the perspective camera. A simple timeline is used to animate the rotation.

To rotate the node in 3D I use the old familiar Rotate transform, but specify "Y_AXIS" for rotation:

    transforms: Rotate {
        axis: Rotate.Y_AXIS
        angle: bind angle
        pivotX: width/2
    }

Perspective camera for the scene is defined like this:

     camera: PerspectiveCamera{fieldOfView: 60}

Note that you can add effects to the node, just like you would with a 2D node. In this example I used a reflection effect.

Download the sample source code: Main.fx. The app can be run in JavaFX TV emulator or on JavaFX desktop using Prism toolkit (javafx -Xtoolkit prism).

JavaFX does not yet support 3D nodes so you are limited to 3D transformations of 2D nodes. You may also have to write your own z-ordering logic to make the nodes display correctly.

Comments:

netbeans 6.8

cannot find symbol
symbol : variable camera
location: class javafx.scene.Scene
camera: PerspectiveCamera{fieldOfView: 60}
D:\\src\\javafx\\edu\\EarthCubeFX\\src\\javafxpert\\earthcube\\main.fx:39: cannot find symbol
symbol : class PerspectiveCamera
location: class javafxpert.earthcube.main
camera: PerspectiveCamera{fieldOfView: 60}
D:\\src\\javafx\\edu\\EarthCubeFX\\src\\javafxpert\\earthcube\\main.fx:39: Invalid assignment
camera: PerspectiveCamera{fieldOfView: 60}
D:\\src\\javafx\\edu\\EarthCubeFX\\src\\javafxpert\\earthcube\\main.fx:49: cannot find symbol
symbol : variable axis
location: class javafx.scene.transform.Rotate
axis: Rotate.Y_AXIS
D:\\src\\javafx\\edu\\EarthCubeFX\\src\\javafxpert\\earthcube\\main.fx:49: cannot find symbol
symbol : variable Y_AXIS
location: class javafx.scene.transform.Rotate
axis: Rotate.Y_AXIS
5 errors
ERROR: javafxc execution failed, exit code: 1
D:\\src\\javafx\\edu\\EarthCubeFX\\nbproject\\build-impl.xml:149: exec returned: -1
BUILD FAILED (total time: 0 seconds)

Posted by Bogdan on June 26, 2010 at 02:53 PM PDT #

Bogdan, you need to upgrade to JavaFX SDK 1.3 for the 3D APIs to work.
It is integrated with Netbeans 6.9 or you can install it as a new JavaFX platform in Netbeans 6.8.

Posted by Mikhail Gorshenev on June 27, 2010 at 03:05 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

user12608660

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
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
29
30
   
       
Today