Search in sources :

Example 26 with Statement

use of com.jme3.util.blockparser.Statement in project jmonkeyengine by jMonkeyEngine.

the class MaterialLoader method load.

private MaterialList load(AssetManager assetManager, AssetKey key, InputStream in) throws IOException {
    folderName = key.getFolder();
    this.assetManager = assetManager;
    MaterialList list = null;
    List<Statement> statements = BlockLanguageParser.parse(in);
    for (Statement statement : statements) {
        if (statement.getLine().startsWith("import")) {
            MaterialExtensionSet matExts = null;
            if (key instanceof OgreMaterialKey) {
                matExts = ((OgreMaterialKey) key).getMaterialExtensionSet();
            }
            if (matExts == null) {
                throw new IOException("Must specify MaterialExtensionSet when loading\n" + "Ogre3D materials with extended materials");
            }
            list = new MaterialExtensionLoader().load(assetManager, key, matExts, statements);
            break;
        } else if (statement.getLine().startsWith("material")) {
            if (list == null) {
                list = new MaterialList();
            }
            String[] split = statement.getLine().split(" ", 2);
            matName = split[1].trim();
            if (matName.startsWith("\"") && matName.endsWith("\"")) {
                matName = matName.substring(1, matName.length() - 1);
            }
            readMaterial(statement);
            Material mat = compileMaterial();
            list.put(mat.getName(), mat);
        }
    }
    return list;
}
Also used : MaterialExtensionLoader(com.jme3.scene.plugins.ogre.matext.MaterialExtensionLoader) Statement(com.jme3.util.blockparser.Statement) MaterialList(com.jme3.material.MaterialList) OgreMaterialKey(com.jme3.scene.plugins.ogre.matext.OgreMaterialKey) Material(com.jme3.material.Material) IOException(java.io.IOException) MaterialExtensionSet(com.jme3.scene.plugins.ogre.matext.MaterialExtensionSet)

Example 27 with Statement

use of com.jme3.util.blockparser.Statement in project jmonkeyengine by jMonkeyEngine.

the class MaterialLoader method readTextureUnit.

private void readTextureUnit(Statement statement) {
    String[] split = statement.getLine().split(" ", 2);
    // name is optional
    if (split.length == 2) {
        texName = split[1];
    } else {
        texName = null;
    }
    textures[texUnit] = new Texture2D();
    for (Statement texUnitStat : statement.getContents()) {
        readTextureUnitStatement(texUnitStat);
    }
    if (textures[texUnit].getImage() != null) {
        texUnit++;
    } else {
        // no image was loaded, ignore
        textures[texUnit] = null;
    }
}
Also used : Texture2D(com.jme3.texture.Texture2D) Statement(com.jme3.util.blockparser.Statement)

Example 28 with Statement

use of com.jme3.util.blockparser.Statement in project jmonkeyengine by jMonkeyEngine.

the class MaterialLoader method readPass.

private void readPass(Statement statement) {
    String name;
    String[] split = statement.getLine().split(" ", 2);
    if (split.length == 1) {
        // no name
        name = null;
    } else {
        name = split[1];
    }
    for (Statement passStat : statement.getContents()) {
        readPassStatement(passStat);
    }
    texUnit = 0;
}
Also used : Statement(com.jme3.util.blockparser.Statement)

Aggregations

Statement (com.jme3.util.blockparser.Statement)16 IOException (java.io.IOException)10 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)4 ShaderNodeVariable (com.jme3.shader.ShaderNodeVariable)4 VariableMapping (com.jme3.shader.VariableMapping)4 ShaderNodeDefinitionKey (com.jme3.asset.ShaderNodeDefinitionKey)3 Material (com.jme3.material.Material)3 MaterialList (com.jme3.material.MaterialList)3 ShaderNodeDefinition (com.jme3.shader.ShaderNodeDefinition)3 MatParam (com.jme3.material.MatParam)2 ShaderNode (com.jme3.shader.ShaderNode)2 Image (com.jme3.texture.Image)2 Texture2D (com.jme3.texture.Texture2D)2 InputStream (java.io.InputStream)2 AssetKey (com.jme3.asset.AssetKey)1 AssetLoadException (com.jme3.asset.AssetLoadException)1 TextureKey (com.jme3.asset.TextureKey)1 ShaderGenerationInfo (com.jme3.material.ShaderGenerationInfo)1 LightMode (com.jme3.material.TechniqueDef.LightMode)1 ShadowMode (com.jme3.material.TechniqueDef.ShadowMode)1