Package org.sunflow
Class SunflowAPI
java.lang.Object
org.sunflow.SunflowAPI
- All Implemented Interfaces:
SunflowAPIInterface
- Direct Known Subclasses:
RealtimeBenchmark
This API gives a simple interface for creating scenes procedurally. This is
the main entry point to Sunflow. To use this class, extend from it and
implement the build method which may execute arbitrary code to create a
scene.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuild()This method does nothing, but may be overriden to create scenes procedurally.final voidDefines a camera with a given name.static SunflowAPICompile the specified code string via Janino.static SunflowAPICreate an API object from the specified file.intRead the value of the current frame.voidcurrentFrame(int currentFrame) Set the value of the current frame.final voidDefines a geometry with a given name.final BoundingBoxRetrieve the bounding box of the scene.final booleanParse the specified filename.final voidInstance the specified geometry into the scene.final voidDefines a light source with a given name.final GeometrylookupGeometry(String name) Retrieve a geometry object by its name, ornullif no geometry was found, or if the specified object is not a geometry.final ModifierlookupModifier(String name) Retrieve a modifier object by its name, ornullif no modifier was found, or if the specified object is not a modifier.final ShaderlookupShader(String name) Retrieve a shader object by its name, ornullif no shader was found, or if the specified object is not a shader.final voidDefines a modifier with a given name.final voidDefines an option object to hold the current parameters.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a color parameter in the given colorspace using the specified name and value.final voidDeclare a parameter with the specified name.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a parameter with the specified name and value.final voidDeclare a plugin of the specified type with the given name from a java code string.voidRemove the specified render object.final voidRender using the specified options and the specified display.final voidreset()Reset the state of the API completely.final StringresolveIncludeFilename(String filename) Attempts to resolve the specified filename by checking it against the include search path.final StringresolveTextureFilename(String filename) Attempts to resolve the specified filename by checking it against the texture search path.static voidThis is a quick system test which verifies that the user has launched Java properly.final voidsearchpath(String type, String path) Add the specified path to the list of directories which are searched automatically to resolve scene filenames or textures.final voidDefines a shader with a given name.static booleanTranslate specfied file into the native sunflow scene file format.
-
Field Details
-
VERSION
- See Also:
-
DEFAULT_OPTIONS
- See Also:
-
-
Constructor Details
-
SunflowAPI
public SunflowAPI()Creates an empty scene.
-
-
Method Details
-
runSystemCheck
public static void runSystemCheck()This is a quick system test which verifies that the user has launched Java properly. -
reset
public final void reset()Description copied from interface:SunflowAPIInterfaceReset the state of the API completely. The object table is cleared, and all search paths are set back to their default values.- Specified by:
resetin interfaceSunflowAPIInterface
-
plugin
Description copied from interface:SunflowAPIInterfaceDeclare a plugin of the specified type with the given name from a java code string. The code will be compiled with Janino and registered as a new plugin type upon success.- Specified by:
pluginin interfaceSunflowAPIInterface- Parameters:
type-name-code-
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a color parameter in the given colorspace using the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namecolorspace- color space ornullto assume internal color spacedata- floating point color data
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name and value. This parameter will be added to the currently active parameter list.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter namevalue- parameter value
-
parameter
Description copied from interface:SunflowAPIInterfaceDeclare a parameter with the specified name. The type may be one of the follow: "float", "point", "vector", "texcoord", "matrix". The interpolation determines how the parameter is to be interpreted over surface (seeParameterList.InterpolationType). The data is specified in a flattened float array.- Specified by:
parameterin interfaceSunflowAPIInterface- Parameters:
name- parameter nametype- parameter data typeinterpolation- parameter interpolation modedata- raw floating point data
-
remove
Description copied from interface:SunflowAPIInterfaceRemove the specified render object. Note that this may cause the removal of other objects which depended on it.- Specified by:
removein interfaceSunflowAPIInterface- Parameters:
name- name of the object to remove
-
searchpath
Description copied from interface:SunflowAPIInterfaceAdd the specified path to the list of directories which are searched automatically to resolve scene filenames or textures. Currently the supported searchpath types are: "include" and "texture". All other types will be ignored.- Specified by:
searchpathin interfaceSunflowAPIInterface- Parameters:
path-
-
resolveTextureFilename
Attempts to resolve the specified filename by checking it against the texture search path.- Parameters:
filename- filename- Returns:
- a path which matches the filename, or filename if no matches are found
-
resolveIncludeFilename
Attempts to resolve the specified filename by checking it against the include search path.- Parameters:
filename- filename- Returns:
- a path which matches the filename, or filename if no matches are found
-
shader
Description copied from interface:SunflowAPIInterfaceDefines a shader with a given name. If the shader type name is leftnull, the shader with the given name will be updated (if it exists).- Specified by:
shaderin interfaceSunflowAPIInterface- Parameters:
name- a unique name given to the shadershaderType- a shader plugin type
-
modifier
Description copied from interface:SunflowAPIInterfaceDefines a modifier with a given name. If the modifier type name is leftnull, the modifier with the given name will be updated (if it exists).- Specified by:
modifierin interfaceSunflowAPIInterface- Parameters:
name- a unique name given to the modifiermodifierType- a modifier plugin type name
-
geometry
Description copied from interface:SunflowAPIInterfaceDefines a geometry with a given name. The geometry is built from the specified type. Note that geometries may be created fromTesselatableobjects orPrimitiveListobjects. This means that two seperate plugin lists will be searched for the geometry type.Tesselatableobjects are search first. If the type name is leftnull, the geometry with the given name will be updated (if it exists).- Specified by:
geometryin interfaceSunflowAPIInterface- Parameters:
name- a unique name given to the geometrytypeName- a tesselatable or primitive plugin type name
-
instance
Description copied from interface:SunflowAPIInterfaceInstance the specified geometry into the scene. If geoname isnull, the specified instance object will be updated (if it exists). In order to change the instancing relationship of an existing instance, you should use the "geometry" string attribute.- Specified by:
instancein interfaceSunflowAPIInterface- Parameters:
name- instance namegeoname- name of the geometry to instance
-
light
Description copied from interface:SunflowAPIInterfaceDefines a light source with a given name. If the light type name is leftnull, the light source with the given name will be updated (if it exists).- Specified by:
lightin interfaceSunflowAPIInterface- Parameters:
name- a unique name given to the light sourcelightType- a light source plugin type name
-
camera
Description copied from interface:SunflowAPIInterfaceDefines a camera with a given name. The camera is built from the specified camera lens type plugin. If the lens type name is leftnull, the camera with the given name will be updated (if it exists). It is not currently possible to change the lens of a camera after it has been created.- Specified by:
camerain interfaceSunflowAPIInterface- Parameters:
name- camera namelensType- a camera lens plugin type name
-
options
Description copied from interface:SunflowAPIInterfaceDefines an option object to hold the current parameters. If the object already exists, the values will simply override previous ones.- Specified by:
optionsin interfaceSunflowAPIInterface- Parameters:
name-
-
lookupGeometry
Retrieve a geometry object by its name, ornullif no geometry was found, or if the specified object is not a geometry.- Parameters:
name- geometry name- Returns:
- the geometry object associated with that name
-
lookupShader
Retrieve a shader object by its name, ornullif no shader was found, or if the specified object is not a shader.- Parameters:
name- shader name- Returns:
- the shader object associated with that name
-
lookupModifier
Retrieve a modifier object by its name, ornullif no modifier was found, or if the specified object is not a modifier.- Parameters:
name- modifier name- Returns:
- the modifier object associated with that name
-
render
Description copied from interface:SunflowAPIInterfaceRender using the specified options and the specified display. If the specified options do not exist - defaults will be used.- Specified by:
renderin interfaceSunflowAPIInterface- Parameters:
optionsName- name of theRenderObjectwhich contains the optionsdisplay- display object
-
include
Description copied from interface:SunflowAPIInterfaceParse the specified filename. The include paths are searched first. The contents of the file are simply added to the active scene. This allows to break up a scene into parts, even across file formats. The appropriate parser is chosen based on file extension.- Specified by:
includein interfaceSunflowAPIInterface- Parameters:
filename- filename to load- Returns:
trueupon sucess,falseif an error occured.
-
getBounds
Retrieve the bounding box of the scene. This method will be valid only after a first call torender(String, Display)has been made. -
build
public void build()This method does nothing, but may be overriden to create scenes procedurally. -
create
Create an API object from the specified file. Java files are read by Janino and are expected to implement a build method (they implement a derived class of SunflowAPI. The build method is called if the code compiles succesfully. Other files types are handled by the parse method.- Parameters:
filename- filename to load- Returns:
- a valid SunflowAPI object or
nullon failure
-
translate
Translate specfied file into the native sunflow scene file format.- Parameters:
filename- input filenameoutputFilename- output filename- Returns:
trueupon success,falseotherwise
-
compile
Compile the specified code string via Janino. The code must implement a build method as described above. The build method is not called on the output, it is up the caller to do so.- Parameters:
code- java code string- Returns:
- a valid SunflowAPI object upon succes,
nullotherwise.
-
currentFrame
public int currentFrame()Read the value of the current frame. This value is intended only for procedural animation creation. It is not used by the Sunflow core in anyway. The default value is 1.- Returns:
- current frame number
-
currentFrame
public void currentFrame(int currentFrame) Description copied from interface:SunflowAPIInterfaceSet the value of the current frame. This value is intended only for procedural animation creation. It is not used by the Sunflow core in anyway. The default value is 1.- Specified by:
currentFramein interfaceSunflowAPIInterface- Parameters:
currentFrame- current frame number
-
getTextureCache
-