Can we implement our own stuff in JavaFX?

JavaFX has abstract class Material

to represent materials of three-dimensional surfaces. The current JDK only provides PhongMaterial

. I was looking into adding my own stuff (like Lambert or Blinn, etc.) by expanding Material

, in a similar way to how it is implemented PhongMaterial

.

There are two problems I am facing:

  • The behavior (color calculation) mentioned in the documentation PhongMaterial

    is nowhere to be found - not in the class itself, not in the inner classes I was looking at. It's in the JDK somewhere, but not so exposed. The class PhongMaterial

    only contains properties, not behavior, which I find strange to start with.

  • PhongMaterial

    turns out to be deeply related to inner classes:

    • com.sun.javafx.sg.prism.NGPhongMaterial

      which according to some documentation is a peer node created by a graphical toolkit / pipeline implementation. This class does not specify behavior.
    • com.sun.prism.PhongMaterial

      which is the stock rendering material for the saved mode.
    • com.sun.prism.TextureMap

      is a wrapper class for storing map-related information for a PhongMaterial.

    None of them determine the behavior of the material.

What are the steps to implement my own stuff? What classes do I need to write? For example, do I need a new class TextureMap

that I will somehow inform Prism about?

+3


source to share


2 answers


This is the answer on the OpenJFX mailing list about creating stuff:

We are not planning any 3D rendering improvements at this time. Even if we did, by allowing applications specific to applications, it would take some way for the application to provide the necessary shader support to provide such material.



So the answer to the question is no, and there are no plans to change that in the future.

+3


source


As far as I can tell, the class is Material

not (currently) intended to be subclassed. This is likely due to the fact that the fixed public API has not yet been agreed upon.

Material

contains two abstract methods. In JavaFX 8 this is

public abstract void impl_updatePG(); 

      

and

public abstract NGPhongMaterial impl_getNGMaterial();

      

They are marked with @Deprecated

and @treatAsPrivate implementation detail

.



In JavaFX 9, names change and visibility changes to private-package:

abstract void updatePG(); 

      

and

abstract NGPhongMaterial getNGMaterial();

      

So it looks like the goal here is not to allow subclasses, but to have a design that will allow future (> 9) versions to allow subclassing after the API has been defined. Again, here I am reading between the lines pretty much: users who are closer to the JavaFX team may have more complete information. FWIW, the current version of the source contains the following comment:

Material not paint
PhongMaterial may be the first and only material in FX8 (see 3D conceptual implementation for details)
Bump Map: Normal map and height map. Can we create a normal map if DEM
map is Displacement map? Not in FX8 - Can perform Parallex mapping adjustments to improve quality at performance cost
Auto-generated Mipmap
support No Multi-texture support plan

+3


source







All Articles