public class ColModelImporter extends java.lang.Object implements ModelImporter
A JavaFX model importer for COLLADA 1.4.1 and 1.5.0 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.dae
ColModelImporter colImporter = new ColModelImporter();
try {
URL modelUrl = this.getClass().getResource("resources/MyModel.dae");
colImporter.read(modelUrl);
}
catch (ImportException e) {
// handle exception
}
Node[] rootNodes = colImporter.getImport();
| Constructor and Description |
|---|
ColModelImporter()
Creates a COLLADA 1.4.1 and 1.5.0 model importer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Disposes of the imported data.
|
void |
close()
Disposes of the imported data and closes the importer.
|
ColAsset |
getAsset()
Gets the asset attributes of the imported COLLADA root element.
|
FilePath[] |
getColladaFilePaths()
Gets the paths of included COLLADA files which are used for external referencing.
|
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 array of Nodes from the imported file.
|
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<ColImportOption> |
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(ColImportOption... options)
Sets the import options.
|
void |
setOptions(java.util.EnumSet<ColImportOption> 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 ColModelImporter()
public java.lang.String getResourceBasePath()
null.getResourceBasePath in interface ModelImporterpublic java.net.URL getResourceBaseUrl()
null.getResourceBaseUrl in interface ModelImporterpublic void setResourceBasePath(java.lang.String path)
null.setResourceBasePath in interface ModelImporterpath - location of associated filespublic void setResourceBaseUrl(java.net.URL url)
null.setResourceBaseUrl in interface ModelImporterurl - location of associated filespublic double getCreaseAngle()
Default value: 45
getCreaseAngle in interface Importerpublic void setCreaseAngle(double degrees)
Normals are generated if the corresponding option
ColImportOption.NORMALS_GENERATION is set or
normals are not provided in the imported file.
Default value: 45
setCreaseAngle in interface Importerdegrees - crease angle for generating normalssetOptions(ColImportOption...),
ColImportOption.GENERATE_NORMALSpublic java.util.EnumSet<ColImportOption> getOptions()
ColImportOption.NONE.public void setOptions(ColImportOption... options)
ColImportOption.NONE.options - a sequence or an array of import optionsjava.lang.IllegalArgumentException - if options is null, its length is 0, or
ColImportOption.NONE is not the sole elementpublic void setOptions(java.util.EnumSet<ColImportOption> options)
ColImportOption.NONE.options - enum set of import optionsjava.lang.IllegalArgumentException - if options is null, its size is 0, or
ColImportOption.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 Importerpublic ColAsset getAsset()
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 ModelImporternull if no material is named and usedpublic java.util.Map<javafx.scene.image.Image,FilePath> getImageFilePaths()
getImageFilePaths in interface ModelImporternull if no image is importedFilePathpublic FilePath[] getColladaFilePaths()
null if COLLADA files aren't includedFilePathpublic Viewpoint[] getViewpoints()
null if no camera element is present in the imported fileViewpointpublic void clear()
Copyright (C) 2013-2014 InteractiveMesh e.K.