/** * Read the ShaderNodesDefinitions block and internally stores a map of * ShaderNodesDefinition This method is used by the j3m loader. * * When loaded in a material, the definitions are not stored as a list, but * they are stores in Shadernodes based on this definition. * * The map is here to map the definition to the nodes, and ovoid reloading * already loaded definitions * * @param statements the list of statements to parse * @throws IOException */ public void readNodesDefinitions(List<Statement> statements) throws IOException { readNodesDefinitions(statements, new ShaderNodeDefinitionKey()); }
@Override public Object load(AssetInfo assetInfo) throws IOException { AssetKey k = assetInfo.getKey(); if (!(k instanceof ShaderNodeDefinitionKey)) { throw new IOException("ShaderNodeDefinition file must be loaded via ShaderNodeDefinitionKey"); } ShaderNodeDefinitionKey key = (ShaderNodeDefinitionKey) k; loaderDelegate = new ShaderNodeLoaderDelegate(); InputStream in = assetInfo.openStream(); List<Statement> roots = BlockLanguageParser.parse(in); if (roots.size() == 2) { Statement exception = roots.get(0); String line = exception.getLine(); if (line.startsWith("Exception")) { throw new AssetLoadException(line.substring("Exception ".length())); } else { throw new MatParseException("In multiroot shader node definition, expected first statement to be 'Exception'", exception); } } else if (roots.size() != 1) { throw new MatParseException("Too many roots in J3SN file", roots.get(0)); } return loaderDelegate.readNodesDefinitions(roots.get(0).getContents(), key); } }
initNodesLoader(); if (isUseNodes) { nodesLoaderDelegate.readNodesDefinitions(statement.getContents());
/** * Read the ShaderNodesDefinitions block and internally stores a map of * ShaderNodesDefinition This method is used by the j3m loader. * * When loaded in a material, the definitions are not stored as a list, but * they are stores in Shadernodes based on this definition. * * The map is here to map the definition to the nodes, and ovoid reloading * already loaded definitions * * @param statements the list of statements to parse * @throws IOException */ public void readNodesDefinitions(List<Statement> statements) throws IOException { readNodesDefinitions(statements, new ShaderNodeDefinitionKey()); }
@Override public Object load(AssetInfo assetInfo) throws IOException { AssetKey k = assetInfo.getKey(); if (!(k instanceof ShaderNodeDefinitionKey)) { throw new IOException("ShaderNodeDefinition file must be loaded via ShaderNodeDefinitionKey"); } ShaderNodeDefinitionKey key = (ShaderNodeDefinitionKey) k; loaderDelegate = new ShaderNodeLoaderDelegate(); InputStream in = assetInfo.openStream(); List<Statement> roots = BlockLanguageParser.parse(in); if (roots.size() == 2) { Statement exception = roots.get(0); String line = exception.getLine(); if (line.startsWith("Exception")) { throw new AssetLoadException(line.substring("Exception ".length())); } else { throw new MatParseException("In multiroot shader node definition, expected first statement to be 'Exception'", exception); } } else if (roots.size() != 1) { throw new MatParseException("Too many roots in J3SN file", roots.get(0)); } return loaderDelegate.readNodesDefinitions(roots.get(0).getContents(), key); } }
initNodesLoader(); if (isUseNodes) { nodesLoaderDelegate.readNodesDefinitions(statement.getContents());