File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes 3D rotating rectangle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "3D rotating rectangle" Watch "3D rotating rectangle" New topic
Author

3D rotating rectangle

Jason Barraclough
Greenhorn

Joined: Aug 19, 2013
Posts: 5
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

Joined: Jan 26, 2012
Posts: 157
    
    9
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

Joined: May 03, 2008
Posts: 4664
    
    5

John

You earn a cow for that painstakingly informative response!


luck, db
There are no new questions, but there may be new answers.
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 157
    
    9
LOL

Thanks very much Darryl!

I shall name my cow Daisy :-)
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

And another one from me for being so innovative about the cows. Moo!


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1096
    
  10

And I gave one for that incredible response!


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

And now poor John has to look for two more 'cow' names ...
Jason Barraclough
Greenhorn

Joined: Aug 19, 2013
Posts: 5
Lol! Hey great thanks very much for the response!

PS- what is all this cow business?
Jason.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Check out https://www.coderanch.com/how-to/java/RanchGuide
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 3D rotating rectangle