Package org.web3d.x3d.jsail
Class BlenderLauncher
java.lang.Object
org.web3d.x3d.jsail.BlenderLauncher
public class BlenderLauncher
extends java.lang.Object
Utility class for invoking and launching Blender via local operating system to perform a variety of conversion tasks. Note use of static methods.
- See Also:
- Blender, Blender Quickstart Introduction, Blender API Introduction, Blender Python API Documentation, Scripting & Extending Blender, Blender 3D: Noob to Pro, Blender 3D: Noob to Pro/Advanced Tutorials/Python Scripting/Introduction, Video: Blender Tutorial Introduction to Python Scripting: Writing a Script That Makes a Simple 3D Model, Java Tutorials: Understanding (Static) Class Members, X3D Scene Authoring Hints
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBLENDER_PATH_DEFAULT_LINUXDefault Blender path default for Linux operating system, possibly unneeded ifblenderis in path already.static java.lang.StringBLENDER_PATH_DEFAULT_MACOSDefault Blender path default for macOS operating system, possibly unneeded ifblenderis in path already.static java.lang.StringBLENDER_PATH_DEFAULT_WINDOWSDefault Blender path default for Windows 7 or 10 operating system, possibly unneeded ifblenderis in path already.static java.lang.StringBLENDER_PYTHON_SCRIPT_STL_TO_X3DBlender python script for converting STL model into X3D model.static java.lang.StringBLENDER_PYTHON_SCRIPT_X3D_TO_PNGBlender python script for converting X3D model into PNG image.static java.lang.StringBLENDER_URLBlender website URLstatic java.lang.StringUSAGEUsage:java [-classpath X3DJSAIL.*.jar] org.web3d.x3d.jsail.BlenderLauncher sourceFile [-convert [resultFile]] [-toImage [snapshotName.*]] [-home | -help | -version | -properties fileName.properties | -BLENDER_PATH directoryPath] -
Constructor Summary
Constructors Constructor Description BlenderLauncher() -
Method Summary
Modifier and Type Method Description static voidcheckBlenderPath()Check Blender local path and reset to operating system default, if necessary.static booleanconvertModel(java.lang.String inputFileName, java.lang.String outputFileName)TODO: Use Blender to convert model from one file to another.static booleanconvertModel(java.lang.String path, java.lang.String inputFileName, java.lang.String outputFileName)TODO: Use Blender to convert model from one file to another based on filename extensions.protected static java.lang.StringexecuteCommand(java.lang.String command)Launch blender in operating system and run command.static java.lang.StringexportSTL(X3DObject modelToExport)TODO: Use blender to export geometry to STLstatic booleanexportSTLtoFile(X3DObject modelToExport, java.lang.String path, java.lang.String fileName)TODO: Use blender to export geometry to filestatic java.lang.StringgetBlenderAnalytics(X3DObject modelOfInterest)TODO: Get Blender metrics for X3D model of interest.static MetadataSetObjectgetBlenderAnalyticsX3dMetadataSet(X3DObject modelOfInterest)TODO: Get Blender metrics as MetadataSet object.static java.lang.StringgetBlenderExecutableName()Get directory path for location ofblenderprogram:blender.exeon Windows,blenderotherwise.static java.lang.StringgetBlenderHelp()Get Blender help.static java.lang.StringgetBlenderPath()Get preference for XSLT transformation engine to use:ConfigurationProperties.XSLT_ENGINE_SAXONorConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA.static java.lang.StringgetBlenderVersion()Get Blender version.static booleanhasBlender()Determine if Blender is locally available.static X3DObjectimportModel(java.lang.String path, java.lang.String fileName)TODO: Use blender to import model to X3Dstatic X3DObjectimportSTL(java.lang.String path, java.lang.String fileName)TODO finish: Use blender to import STL geometry as X3D modelstatic voidinitialize()Initialize this BlenderLauncher instance to default values.static voidlaunchBlenderWebPage()Open Blender pagestatic voidmain(java.lang.String[] args)Default main() method provided for test and debugging purposes, invoking run() method.static voidrun(java.lang.String singleStringArguments)Utility run() method provided for test and debugging purposes, allowing invocation with a single String (rather than a String[] array).static voidrun(java.lang.String[] args)Default run() method provided for test and debugging purposes, first initializing ConfigurationProperties then reading properties file (if any) and processing arguments.static voidsetBlenderPath(java.lang.String newValue)Set preference for XSLT transformation engine to use:ConfigurationProperties.XSLT_ENGINE_SAXONorConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA.static booleanwasPriorCommandSuccessful()Report whether prior command execution was successful.
-
Field Details
-
BLENDER_URL
public static final java.lang.String BLENDER_URLBlender website URL- See Also:
launchBlenderWebPage(), Constant Field Values
-
BLENDER_PATH_DEFAULT_WINDOWS
public static final java.lang.String BLENDER_PATH_DEFAULT_WINDOWSDefault Blender path default for Windows 7 or 10 operating system, possibly unneeded ifblenderis in path already. Warning: local settings vary, configure path if necessary. -
BLENDER_PATH_DEFAULT_MACOS
public static final java.lang.String BLENDER_PATH_DEFAULT_MACOSDefault Blender path default for macOS operating system, possibly unneeded ifblenderis in path already. Warning: local settings vary, configure path if necessary. -
BLENDER_PATH_DEFAULT_LINUX
public static final java.lang.String BLENDER_PATH_DEFAULT_LINUXDefault Blender path default for Linux operating system, possibly unneeded ifblenderis in path already. Warning: local settings vary, configure path if necessary. -
BLENDER_PYTHON_SCRIPT_X3D_TO_PNG
public static final java.lang.String BLENDER_PYTHON_SCRIPT_X3D_TO_PNGBlender python script for converting X3D model into PNG image.- See Also:
- Constant Field Values
-
BLENDER_PYTHON_SCRIPT_STL_TO_X3D
public static final java.lang.String BLENDER_PYTHON_SCRIPT_STL_TO_X3DBlender python script for converting STL model into X3D model.- See Also:
- Constant Field Values
-
USAGE
public static final java.lang.String USAGEUsage:java [-classpath X3DJSAIL.*.jar] org.web3d.x3d.jsail.BlenderLauncher sourceFile [-convert [resultFile]] [-toImage [snapshotName.*]] [-home | -help | -version | -properties fileName.properties | -BLENDER_PATH directoryPath]- See Also:
- Constant Field Values
-
-
Constructor Details
-
BlenderLauncher
public BlenderLauncher()
-
-
Method Details
-
getBlenderExecutableName
public static final java.lang.String getBlenderExecutableName()Get directory path for location ofblenderprogram:blender.exeon Windows,blenderotherwise.- Returns:
- name of blender program
- See Also:
checkBlenderPath(),setBlenderPath(String)
-
getBlenderPath
public static final java.lang.String getBlenderPath()Get preference for XSLT transformation engine to use:ConfigurationProperties.XSLT_ENGINE_SAXONorConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA.- Returns:
- String constant regarding current configuration: XSLT_ENGINE_SAXON (default) or XSLT_ENGINE_NATIVE_JAVA
-
setBlenderPath
public static final void setBlenderPath(java.lang.String newValue)Set preference for XSLT transformation engine to use:ConfigurationProperties.XSLT_ENGINE_SAXONorConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA.- Parameters:
newValue- is new value to assign
-
initialize
public static final void initialize()Initialize this BlenderLauncher instance to default values. -
main
public static void main(java.lang.String[] args)Default main() method provided for test and debugging purposes, invoking run() method.- Parameters:
args- the command line arguments- See Also:
run(String[]),X3DObject.handleArguments(String[])
-
run
public static void run(java.lang.String singleStringArguments)Utility run() method provided for test and debugging purposes, allowing invocation with a single String (rather than a String[] array). When invoked without parameters then reports results of validate() self-checks to system output.- Parameters:
singleStringArguments- the command line arguments- See Also:
run(String[])
-
run
public static void run(java.lang.String[] args)Default run() method provided for test and debugging purposes, first initializing ConfigurationProperties then reading properties file (if any) and processing arguments. When invoked without parameters then reports results of validate() self-checks to system output.- Parameters:
args- the command line arguments- See Also:
main(String[]),ConfigurationProperties,X3DObject.handleArguments(String[])
-
launchBlenderWebPage
public static void launchBlenderWebPage()Open Blender page- See Also:
- Blender,
Wikipedia: Blender (software),
BLENDER_URL
-
checkBlenderPath
public static void checkBlenderPath()Check Blender local path and reset to operating system default, if necessary. -
wasPriorCommandSuccessful
public static boolean wasPriorCommandSuccessful()Report whether prior command execution was successful.- Returns:
- whether prior command execution was successful.
- See Also:
- StackOverflow: possible to capture pop-up message box?
-
executeCommand
protected static java.lang.String executeCommand(java.lang.String command)Launch blender in operating system and run command.- Parameters:
command- Blender invocation- Returns:
- console results
- See Also:
- Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments, Blender Manual: Importing and Exporting Files, Why does Runtime.exec(String) work for some but not all commands?, StackOverflow: Runtime.getRuntime().exec(cmd) hanging, StackOverflow: Executing another application from Java, java.lang.Runtime, java.lang.ProcessBuilder
-
convertModel
public static boolean convertModel(java.lang.String inputFileName, java.lang.String outputFileName)TODO: Use Blender to convert model from one file to another.- Parameters:
inputFileName- for input fileoutputFileName- for output file- Returns:
- whether successful
- See Also:
- MeshLab, Wikipedia: MeshLab
-
convertModel
public static boolean convertModel(java.lang.String path, java.lang.String inputFileName, java.lang.String outputFileName)TODO: Use Blender to convert model from one file to another based on filename extensions.- Parameters:
path- directory path to file of interestinputFileName- for input fileoutputFileName- for output file- Returns:
- whether successful
- See Also:
- MeshLab, Wikipedia: MeshLab
-
importModel
TODO: Use blender to import model to X3D- Parameters:
path- directory path to file of interestfileName- for input file- Returns:
- result, null if unsuccessful
- See Also:
- Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments, Blender Manual: Importing and Exporting Files
-
importSTL
TODO finish: Use blender to import STL geometry as X3D model- Parameters:
path- directory path to file of interestfileName- for input file- Returns:
- result, null if unsuccessful
- See Also:
- Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments, Blender Manual: Importing and Exporting Files
-
exportSTL
TODO: Use blender to export geometry to STL- Parameters:
modelToExport- X3D model of interest- Returns:
- plain-text STL file
- See Also:
- STL (file format), Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments, Blender Manual: Importing and Exporting Files
-
exportSTLtoFile
public static boolean exportSTLtoFile(X3DObject modelToExport, java.lang.String path, java.lang.String fileName)TODO: Use blender to export geometry to file- Parameters:
modelToExport- X3D model of interestpath- directory path to file of interestfileName- for output file- Returns:
- whether successful
- See Also:
- STL (file format), Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments, Blender Manual: Importing and Exporting Files
-
getBlenderAnalytics
TODO: Get Blender metrics for X3D model of interest.- Parameters:
modelOfInterest- X3D model to analyze- Returns:
- Blender output
- See Also:
- Blender, Blender Manual: Command Line, Blender Manual: Command Line Arguments
-
getBlenderAnalyticsX3dMetadataSet
TODO: Get Blender metrics as MetadataSet object.- Parameters:
modelOfInterest- X3D model to analyze- Returns:
- Blender output
- See Also:
- Blender Manual: Command Line, Blender Manual: Command Line Arguments
-
getBlenderVersion
public static java.lang.String getBlenderVersion()Get Blender version. Warning: ensure BLENDER_HOME or local path is set correctly, especially if more than one version is installed.- Returns:
- Blender version.
- See Also:
- www.blender.org, Blender Manual: Command Line, Blender Manual: Command Line Arguments
-
getBlenderHelp
public static java.lang.String getBlenderHelp()Get Blender help. Warning: ensure BLENDER_HOME or local path is set correctly, especially if more than one version is installed.- Returns:
- Blender version.
- See Also:
- www.blender.org, Blender Manual: Command Line, Blender Manual: Command Line Arguments
-
hasBlender
public static boolean hasBlender()Determine if Blender is locally available. Warning: ensure BLENDER_HOME or local path is set correctly, especially if more than one version is installed.- Returns:
- whether Blender is found.
- See Also:
- www.blender.org, Blender Manual: Command Line, Blender Manual: Command Line Arguments
-