⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sunflowapi.java

📁 Sunflow是一个照片级的渲染系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */
    public void remove(String name) {
        renderObjects.remove(name);
    }

    /**
     * Update the specfied object using the currently active parameter list. The
     * object is removed if the update fails to avoid leaving inconsistently set
     * objects in the list.
     * 
     * @param name name of the object to update
     * @return <code>true</code> if the update was succesfull, or
     *         <code>false</code> if the update failed
     */
    public boolean update(String name) {
        boolean success = renderObjects.update(name, parameterList, this);
        parameterList.clear(success);
        return success;
    }

    /**
     * Add the specified path to the list of directories which are searched
     * automatically to resolve scene filenames.
     * 
     * @param path
     */
    public final void addIncludeSearchPath(String path) {
        includeSearchPath.addSearchPath(path);
    }

    /**
     * Adds the specified path to the list of directories which are searched
     * automatically to resolve texture filenames.
     */
    public final void addTextureSearchPath(String path) {
        textureSearchPath.addSearchPath(path);
    }

    /**
     * Attempts to resolve the specified filename by checking it against the
     * texture search path.
     * 
     * @param filename filename
     * @return a path which matches the filename, or filename if no matches are
     *         found
     */
    public final String resolveTextureFilename(String filename) {
        return textureSearchPath.resolvePath(filename);
    }

    /**
     * Attempts to resolve the specified filename by checking it against the
     * include search path.
     * 
     * @param filename filename
     * @return a path which matches the filename, or filename if no matches are
     *         found
     */
    public final String resolveIncludeFilename(String filename) {
        return includeSearchPath.resolvePath(filename);
    }

    /**
     * Defines a shader with a given name. If the shader object is
     * <code>null</code>, the shader with the given name will be updated (if
     * it exists).
     * 
     * @param name a unique name given to the shader
     * @param shader a shader object
     */
    public final void shader(String name, Shader shader) {
        if (shader != null) {
            // we are declaring a shader for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare shader \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, shader);
        }
        // update existing shader (only if it is valid)
        if (lookupShader(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update shader \"%s\" - shader object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Defines a modifier with a given name. If the modifier object is
     * <code>null</code>, the modifier with the given name will be updated
     * (if it exists).
     * 
     * @param name a unique name given to the modifier
     * @param modifier a modifier object
     */
    public final void modifier(String name, Modifier modifier) {
        if (modifier != null) {
            // we are declaring a shader for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare modifier \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, modifier);
        }
        // update existing shader (only if it is valid)
        if (lookupModifier(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update modifier \"%s\" - modifier object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Defines a geometry with a given name. The geometry is built from the
     * specified {@link PrimitiveList}. If the primitives object is
     * <code>null</code>, the geometry with the given name will be updated
     * (if it exists).
     * 
     * @param name a unique name given to the geometry
     * @param primitives primitives to create the geometry from
     */
    public final void geometry(String name, PrimitiveList primitives) {
        if (primitives != null) {
            // we are declaring a geometry for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare geometry \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, primitives);
        }
        if (lookupGeometry(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update geometry \"%s\" - geometry object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Defines a geometry with a given name. The geometry is built from the
     * specified {@link Tesselatable}. If the object is <code>null</code>,
     * the geometry with the given name will be updated (if it exists).
     * 
     * @param name a unique name given to the geometry
     * @param tesselatable the tesselatable object to create the geometry from
     */
    public final void geometry(String name, Tesselatable tesselatable) {
        if (tesselatable != null) {
            // we are declaring a geometry for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare geometry \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, tesselatable);
        }
        if (lookupGeometry(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update geometry \"%s\" - geometry object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Instance the specified geometry into the scene. If geoname is
     * <code>null</code>, the specified instance object will be updated (if
     * it exists). It is not possible to change the instancing relationship
     * after the instance has been created.
     * 
     * @param name instance name
     * @param geoname name of the geometry to instance
     */
    public final void instance(String name, String geoname) {
        if (geoname != null) {
            // we are declaring this instance for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare instance \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            parameter("geometry", geoname);
            renderObjects.put(name, new Instance());
        }
        if (lookupInstance(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update instance \"%s\" - instance object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Adds the specified light to the scene.
     * 
     * @param light light source object
     */
    public final void light(String name, LightSource light) {
        if (light != null) {
            // we are declaring this light for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare light \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, light);
        }
        if (lookupLight(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update instance \"%s\" - instance object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Defines a camera with a given name. The camera is built from the
     * specified {@link CameraLens}. If the lens object is <code>null</code>,
     * the camera with the given name will be updated (if it exists). It isn't
     * possible to change the lens of an existing camera.
     * 
     * @param name camera name
     * @param lens camera lens to use
     */
    public final void camera(String name, CameraLens lens) {
        if (lens != null) {
            // we are declaring this camera for the first time
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare camera \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, new Camera(lens));
        }
        // update existing shader (only if it is valid)
        if (lookupCamera(name) != null)
            update(name);
        else {
            UI.printError(Module.API, "Unable to update camera \"%s\" - camera object was not found", name);
            parameterList.clear(true);
        }
    }

    /**
     * Defines an option object to hold the current parameters. If the object
     * already exists, the values will simply override previous ones.
     * 
     * @param name
     */
    public final void options(String name) {
        if (lookupOptions(name) == null) {
            if (renderObjects.has(name)) {
                UI.printError(Module.API, "Unable to declare options \"%s\", name is already in use", name);
                parameterList.clear(true);
                return;
            }
            renderObjects.put(name, new Options());
        }
        assert lookupOptions(name) != null;
        update(name);
    }

    /**
     * Retrieve a geometry object by its name, or <code>null</code> if no
     * geometry was found, or if the specified object is not a geometry.
     * 
     * @param name geometry name
     * @return the geometry object associated with that name
     */
    public final Geometry lookupGeometry(String name) {
        return renderObjects.lookupGeometry(name);
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -