• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

3D rotating rectangle

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Rancher
Posts: 387
30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John

You earn a cow for that painstakingly informative response!
 
John Damien Smith
Rancher
Posts: 387
30
  • Likes 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL

Thanks very much Darryl!

I shall name my cow Daisy :-)
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And another one from me for being so innovative about the cows. Moo!
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And I gave one for that incredible response!
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lol! Hey great thanks very much for the response!

PS- what is all this cow business?
Jason.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out https://coderanch.com/how-to/java/RanchGuide
 
My cellmate was this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic