// <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [-LINEAR] [ ":" <DEFAULTVAL> ] private void readParam(String statement) throws IOException { String name; String defaultVal = null; ColorSpace colorSpace = null; String[] split = statement.split(":"); // Parse default val if (split.length == 1) { // Doesn't contain default value } else { if (split.length != 2) { throw new IOException("Parameter statement syntax incorrect"); } statement = split[0].trim(); defaultVal = split[1].trim(); } if (statement.endsWith("-LINEAR")) { colorSpace = ColorSpace.Linear; statement = statement.substring(0, statement.length() - "-LINEAR".length()); } // Parse ffbinding int startParen = statement.indexOf("("); if (startParen != -1) { // get content inside parentheses int endParen = statement.indexOf(")", startParen); String bindingStr = statement.substring(startParen + 1, endParen).trim(); // don't care about bindingStr statement = statement.substring(0, startParen); } // Parse type + name split = statement.split(whitespacePattern); if (split.length != 2) { throw new IOException("Parameter statement syntax incorrect"); } VarType type; if (split[0].equals("Color")) { type = VarType.Vector4; } else { type = VarType.valueOf(split[0]); } name = split[1]; Object defaultValObj = null; if (defaultVal != null) { defaultValObj = readValue(type, defaultVal); } if (type.isTextureType()) { materialDef.addMaterialParamTexture(type, name, colorSpace); } else { materialDef.addMaterialParam(type, name, defaultValObj); } }