Search in sources :

Example 1 with IMaterialPlugin

use of org.rajawali3d.materials.plugins.IMaterialPlugin in project Rajawali by Rajawali.

the class Material method checkForPlugins.

/**
     * Checks if any {@link IMaterialPlugin}s have been added. If so they will be added
     * to the vertex and/or fragment shader.
     *
     * @param location Where to insert the vertex and/or fragment shader
     */
private void checkForPlugins(PluginInsertLocation location) {
    if (mPlugins == null)
        return;
    for (IMaterialPlugin plugin : mPlugins) {
        if (plugin.getInsertLocation() == location) {
            mVertexShader.addShaderFragment(plugin.getVertexShaderFragment());
            mFragmentShader.addShaderFragment(plugin.getFragmentShaderFragment());
        }
    }
}
Also used : IMaterialPlugin(org.rajawali3d.materials.plugins.IMaterialPlugin)

Example 2 with IMaterialPlugin

use of org.rajawali3d.materials.plugins.IMaterialPlugin in project Rajawali by Rajawali.

the class Material method addPlugin.

/**
     * Add a material plugin. A material plugin is basically
     * a class that contains a vertex shader fragment and a fragment shader fragment. Material
     * plugins can be used for custom shader effects.
     *
     * @param plugin
     */
public void addPlugin(IMaterialPlugin plugin) {
    if (mPlugins == null) {
        mPlugins = new ArrayList<IMaterialPlugin>();
    } else {
        for (IMaterialPlugin p : mPlugins) {
            if (plugin.getClass().getSimpleName().equals(p.getClass().getSimpleName()))
                return;
        }
    }
    mPlugins.add(plugin);
    mIsDirty = true;
}
Also used : IMaterialPlugin(org.rajawali3d.materials.plugins.IMaterialPlugin)

Example 3 with IMaterialPlugin

use of org.rajawali3d.materials.plugins.IMaterialPlugin in project Rajawali by Rajawali.

the class VertexAnimationObject3D method setMaterial.

@Override
public void setMaterial(Material material) {
    super.setMaterial(material);
    IMaterialPlugin plugin = material.getPlugin(VertexAnimationMaterialPlugin.class);
    if (plugin == null) {
        mMaterialPlugin = new VertexAnimationMaterialPlugin();
        material.addPlugin(mMaterialPlugin);
    } else {
        mMaterialPlugin = (VertexAnimationMaterialPlugin) plugin;
    }
}
Also used : IMaterialPlugin(org.rajawali3d.materials.plugins.IMaterialPlugin) VertexAnimationMaterialPlugin(org.rajawali3d.materials.plugins.VertexAnimationMaterialPlugin)

Example 4 with IMaterialPlugin

use of org.rajawali3d.materials.plugins.IMaterialPlugin in project Rajawali by Rajawali.

the class Material method unbindTextures.

/**
     * Unbinds the texture from an OpenGL texturing target.
     */
public void unbindTextures() {
    int num = mTextureList.size();
    if (mPlugins != null)
        for (IMaterialPlugin plugin : mPlugins) plugin.unbindTextures();
    for (int i = 0; i < num; i++) {
        ATexture texture = mTextureList.get(i);
        GLES20.glBindTexture(texture.getGLTextureType(), 0);
    }
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
}
Also used : IMaterialPlugin(org.rajawali3d.materials.plugins.IMaterialPlugin) ATexture(org.rajawali3d.materials.textures.ATexture)

Aggregations

IMaterialPlugin (org.rajawali3d.materials.plugins.IMaterialPlugin)4 VertexAnimationMaterialPlugin (org.rajawali3d.materials.plugins.VertexAnimationMaterialPlugin)1 ATexture (org.rajawali3d.materials.textures.ATexture)1