public class FxmlModelImporter extends java.lang.Object implements ModelImporter
A JavaFX model importer for 3D FXML files.
For further details see the package page.
Import process
Prepare the importer (opt.) | Read the file | React (opt.) | Access the imported data | Clean up (recom'd) |
Sample code
Following structure of the application-jar is assumed:
../app/MyApp.class
../app/resources/MyModel.fxml
FxmlModelImporter fxmlImporter = new FxmlModelImporter(); try { URL modelUrl = this.getClass().getResource("resources/MyModel.fxml"); fxmlImporter.read(modelUrl); } catch (ImportException e) { // handle exception } Node[] rootNodes = fxmlImporter.getImport();
Constructor and Description |
---|
FxmlModelImporter()
Creates a model importer for JavaFX 3D FXML files.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Disposes of the imported data.
|
void |
close()
Disposes of the imported data and closes the importer.
|
double |
getCreaseAngle()
Gets the crease angle for normals generation measured in degrees.
|
java.util.Map<javafx.scene.image.Image,FilePath> |
getImageFilePaths()
Gets the map which contains the FilePath objects for all imported texture images.
|
javafx.scene.Node |
getImport()
Gets the root Node from the imported file.
|
java.util.Map<javafx.scene.Node,FilePath> |
getIncludedFxmlFilePaths()
Gets the map which contains the FilePath objects for all included root nodes.
|
java.util.Map<java.lang.String,javafx.scene.paint.PhongMaterial> |
getNamedMaterials()
Gets the map which contains all named and used PhongMaterial objects
from the imported file.
|
java.util.Map<java.lang.String,javafx.scene.Node> |
getNamedNodes()
Gets the map which contains all named (id property) Nodes from the imported file.
|
java.util.EnumSet<FxmlImportOption> |
getOptions()
Gets a copy of the import options enum set.
|
java.lang.String |
getResourceBasePath()
Gets the path where files associated with the imported 3D model file are located.
|
java.net.URL |
getResourceBaseUrl()
Gets the URL where files associated with the imported 3D model file are located.
|
Viewpoint[] |
getViewpoints()
Gets the viewpoints of the imported file.
|
void |
onFileImported()
Method is invoked upon completion of import.
|
void |
read(java.io.File file)
Imports a 3D model file passed as a File object.
|
void |
read(java.lang.String filePath)
Imports a 3D model file with the passed file path.
|
void |
read(java.net.URL url)
Imports a 3D model file from the passed location.
|
void |
setCreaseAngle(double degrees)
Sets the crease angle for normals generation measured in degrees.
|
void |
setOptions(java.util.EnumSet<FxmlImportOption> options)
Sets the import options.
|
void |
setOptions(FxmlImportOption... options)
Sets the import options.
|
void |
setResourceBasePath(java.lang.String path)
Sets the path where files associated with the imported 3D model file are located.
|
void |
setResourceBaseUrl(java.net.URL url)
Sets the URL where files associated with the imported 3D model file are located.
|
public FxmlModelImporter()
public java.lang.String getResourceBasePath()
null
.getResourceBasePath
in interface ModelImporter
public java.net.URL getResourceBaseUrl()
null
.getResourceBaseUrl
in interface ModelImporter
public void setResourceBasePath(java.lang.String path)
null
.setResourceBasePath
in interface ModelImporter
path
- location of associated filespublic void setResourceBaseUrl(java.net.URL url)
null
.setResourceBaseUrl
in interface ModelImporter
url
- location of associated filespublic double getCreaseAngle()
Default value: 45
getCreaseAngle
in interface Importer
public void setCreaseAngle(double degrees)
Normals are generated if the corresponding option
FxmlImportOption.NORMALS_GENERATION
is set.
Default value: 45
setCreaseAngle
in interface Importer
degrees
- crease angle for generating normalssetOptions(FxmlImportOption...)
,
FxmlImportOption.GENERATE_NORMALS
public java.util.EnumSet<FxmlImportOption> getOptions()
FxmlImportOption.NONE
.public void setOptions(FxmlImportOption... options)
FxmlImportOption.NONE
.options
- a sequence or an array of import optionsjava.lang.IllegalArgumentException
- if options is null
, its length is 0, or
FxmlImportOption.NONE
is not the sole elementpublic void setOptions(java.util.EnumSet<FxmlImportOption> options)
FxmlImportOption.NONE
.options
- enum set of import optionsjava.lang.IllegalArgumentException
- if options is null
, its size is 0, or
FxmlImportOption.NONE
is not the sole elementpublic void read(java.io.File file)
public void read(java.lang.String filePath)
public void read(java.net.URL url)
public void onFileImported()
onFileImported
in interface Importer
public javafx.scene.Node getImport()
public java.util.Map<java.lang.String,javafx.scene.Node> getNamedNodes()
null
if no imported Node is namedpublic java.util.Map<java.lang.String,javafx.scene.paint.PhongMaterial> getNamedMaterials()
getNamedMaterials
in interface ModelImporter
null
if no material is named and usedpublic java.util.Map<javafx.scene.image.Image,FilePath> getImageFilePaths()
getImageFilePaths
in interface ModelImporter
null
if no image is importedFilePath
public java.util.Map<javafx.scene.Node,FilePath> getIncludedFxmlFilePaths()
null
if no FXML file is includedFilePath
public Viewpoint[] getViewpoints()
null
if no camera element is present in the imported fileViewpoint
public void clear()
Copyright (C) 2013-2014 InteractiveMesh e.K.