DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Java
  4. 3D Capabilities in JavaFX 1.3 Release

3D Capabilities in JavaFX 1.3 Release

Peter Pilgrim user avatar by
Peter Pilgrim
CORE ·
Apr. 30, 10 · Interview
Like (0)
Save
Tweet
Share
10.47K Views

Join the DZone community and get the full member experience.

Join For Free

Last week on the 22nd April 2010, JavaFX 1.3 Release was released to the general public. I immediately scanned the release notes and was intrigued by the 3D capabilities. Congratulations to the SDK team for listening to criticism and improvements, mine included. I suggested in an AudioBoo that we needed a Capabilities API for the platform. It is now included there.

So if you do have accelerated GPU chip as your graphic card and you run the follow application with the JVM argument -Xtoolkit prism you will be surprised.

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.control.Slider;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.layout.Tile;
import javafx.scene.control.Label;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.PerspectiveCamera;
import javafx.scene.transform.*;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;


var fieldOfView = 200.0 on replace {
println("fieldOfView={fieldOfView}");
};

var rotateX: Number on replace {
println("rotateX={%5.2f rotateX}")
};
var rotateY: Number on replace {
println("rotateY={%5.2f rotateY}")
};
var rotateZ: Number on replace {
println("rotateZ={%5.2f rotateZ}")
};

var scene: Scene;
var rect: Rectangle;


/**
* Research JavaFX 3D with a basic 2D rectangle
* www.xenonique.co.uk
* 27th April 2010
* @author Peter Pilgrim
*/
Stage {
title: "Peter Pilgrim:: Research JavaFX 1.3 Release :: XeNoNiQUe :: London, UK"
scene: scene =Scene {
camera: PerspectiveCamera {
fieldOfView: bind fieldOfView
}

fill: LinearGradient {
startX: 0.0 startY: 0.0
endX: 0.0 endY : 1.0
stops: [
Stop {
color : Color.LIGHTGRAY
offset: 0.0
},
Stop {
color : Color.DARKGRAY
offset: 0.25
},
Stop {
color : Color.GRAY
offset: 1.0
},
]
}


width: 500
height: 500
content: [
Text {
layoutX: 50
layoutY: bind scene.height - 150
font : Font { size : 12 }
content:
"Rectangle rotation in X,Y and Z manipulate with Slider\n"
"No Graphics 3D Primitives in FX 1.3 release!\n"
"You can translate 2D SG object in 3D space\n"
"No yet ready for 3D graphic application then."
},
rect = Rectangle {
translateX: 200
translateY: 200
translateZ: 100
transforms: [
Rotate {
axis: Rotate.Y_AXIS
angle: bind rotateX
},
Rotate {
axis: Rotate.X_AXIS
angle: bind rotateY
},
Rotate {
axis: Rotate.Z_AXIS
angle: bind rotateZ
}
]


x: -100, y: -100
width: 200, height: 200
arcWidth: 10 arcHeight: 10
fill: Color.web("#ff9900")
strokeWidth: 2
stroke: Color.web("#FF0000")
},
Tile {
layoutX: 10
layoutY: 10
columns: 2
hgap: 3
vgap: 6

content: [
Label {
layoutInfo: LayoutInfo { width: 200 }
text: "Rotate X:"
},
Slider {
layoutInfo: LayoutInfo { width: 200 }
min: 0
max: 360
vertical: false
value: bind rotateX with inverse
},
Label {
layoutInfo: LayoutInfo { width: 200 }
text: "Rotate Y:"
},
Slider {
layoutInfo: LayoutInfo { width: 200 }
min: 0
max: 360
vertical: false
value: bind rotateY with inverse
},
Label {
layoutInfo: LayoutInfo { width: 200 }
text: "Rotate Z:"
},
Slider {
layoutInfo: LayoutInfo { width: 200 }
min: 0
max: 360
vertical: false
value: bind rotateZ with inverse
},
Label {
layoutInfo: LayoutInfo { width: 200 }
text: "Field of View:"
},
Slider {
layoutInfo: LayoutInfo { width: 200 }
min: 0
max: 360
vertical: false
value: bind fieldOfView with inverse;
},
]
}


]
}
}

  • JavaFX 1.3 release has no 3D graphics primitives (yet).
  • There is however javafx.geometry.Point3D and that seems to be defining rotation around an arbitary axis in 3D space
  • There is no way to find out the world view transform or even the perspective transform through the API. (Pick up an educational computer graphics book, like James D. Foley's or Dr. Alan Watts to understand these concepts 4 dimensional matrix transformations. )
  • There is a way to translate 2D shapes into 3D cartesian space as the code above illustrates
  • The rotation of objects in the 3D world of JavaFX is a little weird at the moment. (From the example of code above, I am unsure, if I got it completely correct)

The new grahics stack is decent proof of concept and more importantly proof of delivery of the new architecture. So my worries aside of the Oracle acquisition of Sun, I know that my next great space 3D game will not be written with JavaFX 1.3, however the speed and the runtime performance are most welcome.

Peter Pilgrim. Fast tracked blog entry. Out

PS: I believe change the field-of-view dynamically does not work in the example. However I may have written it wrong? Have a pop yourself.

 

From http://www.jroller.com/peter_pilgrim/entry/3d_capabilities_in_javafx_1

JavaFX Release (agency)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Key Elements of Site Reliability Engineering (SRE)
  • Tracking Software Architecture Decisions
  • How To Build a Spring Boot GraalVM Image
  • Create Spider Chart With ReactJS

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: