Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

3D rotating rectangle

 
Jason Barraclough
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey folks! I've seen a few things online using webGL. I have scanned 6 sides of a rectangular block. I was wondering how one would go about painting the images on a 3D rectangle (not a cube) and whether rotating it is possible in JavaFX... ie have JavaFX do the transformations...

Did this make sense?

I have good knowledge of regular Java but not FX...
 
John Damien Smith
Ranch Hand
Posts: 299
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java 8 may be used for 3D work.

You can download a Java 8 preview version.

3D features in Java 8 are not officially documented yet, but there is a good overview with usage notes in the open-jfx wiki:
https://wiki.openjdk.java.net/display/OpenJFX/3D+Features

To display a rectangle with an image on it, you could use a MeshView with a texture set on the Material attached to the MeshView.
http://download.java.net/jdk8/jfxdocs/javafx/scene/shape/MeshView.html
http://download.java.net/jdk8/jfxdocs/javafx/scene/paint/PhongMaterial.html#setDiffuseMap%28javafx.scene.image.Image%29

Java 8 also includes a Box which you could use to model your cube, but using different materials (texture images in your case) for different sides, might be simpler with multiple MeshViews.
http://download.java.net/jdk8/jfxdocs/javafx/scene/shape/Box.html

Here is sample code for using a MeshView in Java 8 (it is early access, so you may need to make some modifications for it to work with the latest Java 8 version):
https://wiki.openjdk.java.net/display/OpenJFX/SimpleMeshView.java

The sample program provides high level settings for the MeshView within the JavaFX scene graph.

Animating portions of a 3D scene graph can use standard JavaFX transitions.

JavaFX is handling the transformations for the SceneGraph and offloading some of the MeshView geometry math and rendering to the GPU via internal OpenGL or DirectX implementations.

If your 3D model is defined in a standard 3D modeling format, such as .obj, you can directly import it into Java 8's 3D system using the Interactive Mesh 3D model importer:
http://www.interactivemesh.org/models/jfx3dimporter.html

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

You can do 3D in JavaFX 2.2 (Java 7), but the API is a bit clunky, largely incomplete and pretty buggy.

A JavaFX 2 implementation of a cube with mapped images on its sides:
http://learnjavafx.typepad.com/weblog/2011/07/earthcubefx-on-javafx-20-download-from-osconjava-2011-keynote.html
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John

You earn a cow for that painstakingly informative response!
 
John Damien Smith
Ranch Hand
Posts: 299
14
  • Likes 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL

Thanks very much Darryl!

I shall name my cow Daisy :-)
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And another one from me for being so innovative about the cows. Moo!
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I gave one for that incredible response!
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now poor John has to look for two more 'cow' names ...
 
Jason Barraclough
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lol! Hey great thanks very much for the response!

PS- what is all this cow business?
Jason.
 
Maneesh Godbole
Saloon Keeper
Posts: 11331
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic