Ejemplo n.º 1
0
  // <DEFINENAME> [ ":" <PARAMNAME> ]
  private void readDefine(String statement) throws IOException {
    String[] split = statement.split(":");
    if (split.length == 1) {
      String defineName = split[0].trim();
      presetDefines.add(defineName);
    } else if (split.length == 2) {
      String defineName = split[0].trim();
      String paramName = split[1].trim();
      MatParam param = materialDef.getMaterialParam(paramName);
      if (param == null) {
        logger.log(
            Level.WARNING,
            "In technique ''{0}'':\n"
                + "Define ''{1}'' mapped to non-existent"
                + " material parameter ''{2}'', ignoring.",
            new Object[] {technique.getName(), defineName, paramName});
        return;
      }

      VarType paramType = param.getVarType();
      technique.addShaderParamDefine(paramName, paramType, defineName);
    } else {
      throw new IOException("Define syntax incorrect");
    }
  }
Ejemplo n.º 2
0
  private void readValueParam(String statement) throws IOException {
    // Use limit=1 incase filename contains colons
    String[] split = statement.split(":", 2);
    if (split.length != 2) {
      throw new IOException("Value parameter statement syntax incorrect");
    }
    String name = split[0].trim();

    // parse value
    MatParam p = material.getMaterialDef().getMaterialParam(name);
    if (p == null) {
      throw new IOException("The material parameter: " + name + " is undefined.");
    }

    Object valueObj = readValue(p.getVarType(), split[1]);
    if (p.getVarType().isTextureType()) {
      material.setTextureParam(name, p.getVarType(), (Texture) valueObj);
    } else {
      material.setParam(name, p.getVarType(), valueObj);
    }
  }