Showing posts with label 3D. Show all posts
Showing posts with label 3D. Show all posts

Sunday, February 23, 2014

JavaFX3D and Leapmotion

Last weekend I've created a prototype application based on LeapMotion and JavaFX3D technology.





Thanks to José Pereda who generously opensourced his Leap3DFX project I was able to mash up features of ControlsFX and JavaFX3D to create the application shown above.

I wanted to explore how you could combine the JavaFX Widgets and 3D content and how you could interact between the two worlds. Furthermore it was interesting to see what is necessary to load 3D models created with Blender - for this task there exist also libraries which make it trivial to load complex models into your scene.

Check out the source at github (and also the original post about leap motion on José's blog!)

Sunday, March 31, 2013

JavaFX 3D Tree Visualization

This post shows some code to generate tree like structures in 3D using JavaFX and its 3D features coming with JDK8.

Earlier this year I've published some experiments creating 2D trees - this post shows you the same approach using 3D features of JavaFX available in JDK8. Of course, by adding a third dimension the trees look more realistic ;-)



The source for this is available at the github repo.


Sunday, February 24, 2013

Conway's Game of Life using JavaFX 3D


I didn't need to change much of the code to run it in 3D - just replace rectangles with boxes, add camera and light - that's it.



What you'll get when using 3D features (in any language) is increased complexity. You have to think about the camera's position, it's field of view, the light sources, their position, the materials, reflections, textures ...

But: What is really impressive concerning JavaFX is that from the programmers viewpoint everything stays the same - for example, you can register your mouseOver actions on a Box in 3D the same way you can use it in 2D with Rectangles. The timelining works the same no matter if you animate 3D or 2D objects etc.

Here is the code for the video above (JDK8 needed!):


JavaFX 3D Hello World

To compile JavaFX with 3D features you have to get the early access version of the JDK8.

At the moment as far as I know there is only a windows support for the 3D features, but a build for Mac and Linux will soon be released. (Luckily enough 3D support also works for a virtualized Windows running on Mac - this is how i got to the screeenshots.)

This blog entry is about a Scala version of the provided 3D examples

First, there is the class PhongMaterial, which defines some sort of "Phong shaded material". Basically you can create a material which can have a color or some texture. 

a red box and a blue sphere rendered with JavaFX

This is a screenshot of the same program, different colors, with a bumpmap applied:

example using a bump map
Here is the code:




With a little imagination you can surely think of many ways to use this features in your applications. At the moment PhongMaterial is the only implementation of the abstract Material class. 

In the above example, Sphere and Box classes are used to represent 3D shapes, but there are also other primitives provided, like Cylinder or MeshView.

You may also want to peek into the sources on the openjfx repository:

hg clone http://hg.openjdk.java.net/openjfx/8/graphics/rt/