@Override public int hashCode() { int hash = 7; hash = 59 * hash + (this.type != null ? this.type.hashCode() : 0); hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 59 * hash + (this.value != null ? this.value.hashCode() : 0); return hash; }
private Object readValue(final VarType type, final String value) throws IOException{ if (type.isTextureType()) { return parseTextureType(type, value); } else {
type = VarType.Vector4; }else{ type = VarType.valueOf(split[0]); defaultValObj = readValue(type, defaultVal); if(type.isTextureType()){ materialDef.addMaterialParamTexture(type, name, colorSpace); }else{
/** * Updates the material texture type of the variable mapping. * * @param statement the statement. * @param mapping the variable mapping. * @param left the left variable. * @param param the material parameter. * @throws MatParseException if the texture type isn't valid. */ private void updateMaterialTextureType(final Statement statement, final VariableMapping mapping, final ShaderNodeVariable left, final MatParam param) throws MatParseException { if (!mapping.getRightVariable().getType().contains("|")) { return; } final String type = fixSamplerType(left.getType(), mapping.getRightVariable().getType()); if (type != null) { mapping.getRightVariable().setType(type); } else { throw new MatParseException(param.getVarType().toString() + " can only be matched to one of " + param.getVarType().getGlslType().replaceAll("\\|", ",") + " found " + left.getType(), statement); } }
right.setType(param.getVarType().getGlslType()); right.setName(param.getName()); right.setPrefix("m_"); if (!param.getVarType().name().endsWith("Array")) { throw new MatParseException(param.getName() + " is not of Array type", statement);
type = VarType.Vector4; }else{ type = VarType.valueOf(split[0]);
DeclaredVariable dv = map.get(param.getName()); if (dv == null) { right.setType(param.getVarType().getGlslType()); right.setName(param.getName()); right.setPrefix("m_"); if(mapping.getLeftVariable().getMultiplicity() != null){ if(!param.getVarType().name().endsWith("Array")){ throw new MatParseException(param.getName() + " is not of Array type", statement);
type = VarType.Vector4; }else{ type = VarType.valueOf(split[0]); defaultValObj = readValue(type, defaultVal); if(type.isTextureType()){ materialDef.addMaterialParamTexture(type, name, colorSpace); }else{
/** * Updated the material texture type of the variable mapping. * * @param statement the statement. * @param mapping the variable mapping. * @param left the left variable. * @param param the material parameter. * @throws MatParseException */ private void updateMaterialTextureType(final Statement statement, final VariableMapping mapping, final ShaderNodeVariable left, final MatParam param) throws MatParseException { if (!mapping.getRightVariable().getType().contains("|")) { return; } final String type = fixSamplerType(left.getType(), mapping.getRightVariable().getType()); if (type != null) { mapping.getRightVariable().setType(type); } else { throw new MatParseException(param.getVarType().toString() + " can only be matched to one of " + param.getVarType().getGlslType().replaceAll("\\|", ",") + " found " + left.getType(), statement); } }
public void setVector4InArray(float x, float y, float z, float w, int index){ if (location == -1) { return; } if (varType != null && varType != VarType.Vector4Array) { throw new IllegalArgumentException("Expected a " + varType.name() + " value!"); } multiData.position(index * 4); multiData.put(x).put(y).put(z).put(w); multiData.rewind(); updateNeeded = true; setByCurrentMaterial = true; }
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); } }
@Override public int hashCode() { int hash = 5; hash = 31 * hash + (this.value != null ? this.value.hashCode() : 0); hash = 31 * hash + (this.varType != null ? this.varType.hashCode() : 0); hash = 31 * hash + (this.binding != null ? this.binding.hashCode() : 0); return hash; }
public void write(MatParam param, OutputStreamWriter out) throws IOException { out.write(" "); out.write(param.getVarType().name()); out.write(" "); out.write(param.getName()); if (param instanceof MatParamTexture) { MatParamTexture paramTex = (MatParamTexture) param; String space = paramTex.getColorSpace() == ColorSpace.Linear ? "-LINEAR" : null; if (space != null) { out.write(" "); out.write(space); } } String value = formatValue(param); if (value != null) { out.write(" : "); out.write(value); } out.write("\n"); }
/** * Pass a parameter to the material shader. * * @param name the name of the parameter defined in the material definition (j3md) * @param type the type of the parameter {@link VarType} * @param value the value of the parameter */ public void setParam(String name, VarType type, Object value) { checkSetParam(type, name); if (type.isTextureType()) { setTextureParam(name, type, (Texture)value); } else { MatParam val = getParam(name); if (val == null) { MatParam paramDef = def.getMaterialParam(name); paramValues.put(name, new MatParam(type, name, value)); } else { val.setValue(value); } if (technique != null) { technique.notifyParamChanged(name, type, value); } } }
@Override public int hashCode() { int hash = 5; hash = 17 * hash + (this.type != null ? this.type.hashCode() : 0); hash = 17 * hash + (this.name != null ? this.name.hashCode() : 0); return hash; }
/** * Check if setting the parameter given the type and name is allowed. * @param type The type that the "set" function is designed to set * @param name The name of the parameter */ private void checkSetParam(VarType type, String name) { MatParam paramDef = def.getMaterialParam(name); if (paramDef == null) { throw new IllegalArgumentException("Material parameter is not defined: " + name); } if (type != null && paramDef.getVarType() != type) { logger.log(Level.WARNING, "Material parameter being set: {0} with " + "type {1} doesn''t match definition types {2}", new Object[]{name, type.name(), paramDef.getVarType()}); } }
for (int i = 0; i < paramValues.size(); i++) { MatParam param = paramValues.getValue(i); if (!param.getVarType().isTextureType()) { continue;
@Override public int hashCode() { int hash = 7; hash = 59 * hash + (this.type != null ? this.type.hashCode() : 0); hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 59 * hash + (this.value != null ? this.value.hashCode() : 0); return hash; }
throw new IllegalArgumentException("Expected a " + varType.name() + " value!");