Java Code Examples for com.jme3.material.MatParam#getName()

The following examples show how to use com.jme3.material.MatParam#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialPropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the material parameter to editable property.
 *
 * @param param    the material parameter.
 * @param material the material.
 * @return the editable property or null.
 */
@FxThread
private @Nullable EditableProperty<?, Material> convert(@NotNull MatParam param, @NotNull Material material) {

    var propertyType = convert(param.getVarType());
    if (propertyType == null) {
        return null;
    }

    return new SimpleProperty<>(propertyType, param.getName(), 0.1F, material,
            object -> getParamValue(param, object), (object, newValue) -> applyParam(param, object, newValue));
}
 
Example 2
Source File: MaterialSettingsPropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the material parameter to an editable property.
 *
 * @param param    the material parameter.
 * @param material the material.
 * @param settings the settings.
 * @return the editable property or null.
 */
@FxThread
private @Nullable EditableProperty<?, ?> convert(@NotNull final MatParam param, @NotNull final Material material,
                                                 @NotNull final MaterialSettings settings) {

    final EditablePropertyType propertyType = convert(param.getVarType());
    if (propertyType == null) {
        return null;
    }

    return new SimpleProperty<>(propertyType, param.getName(), 0.1F, settings,
            object -> getParamValue(param, material),
            (object, newValue) -> applyParam(param, material, newValue));
}
 
Example 3
Source File: J3mdTechniqueDefWriter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getMatParamNameForDefineId(TechniqueDef techniqueDef, Collection<MatParam> matParams, int defineId) {
    for (MatParam matParam : matParams) {
        Integer id = techniqueDef.getShaderParamDefineId(matParam.getName());
        if(id !=null && id == defineId){
            return matParam.getName();
        }
    }
    return null;
}
 
Example 4
Source File: ShaderNodeLoaderDelegate.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Updates the right variable of the given mapping from a {@link MatParam} (a
 * WorldParam) it checks if the uniform hasn't already been loaded, add it
 * to the maps if not.
 *
 * @param param   the mat param.
 * @param mapping the mapping.
 * @param map     the map of uniforms to search into.
 * @return true if the param was added to the map.
 */
public boolean updateRightFromUniforms(MatParam param, VariableMapping mapping, Map<String, DeclaredVariable> map,
                                       Statement statement) throws MatParseException {

    final ShaderNodeVariable left = mapping.getLeftVariable();
    final ShaderNodeVariable right = mapping.getRightVariable();

    DeclaredVariable dv = map.get(param.getName());

    if (dv == null) {

        right.setType(param.getVarType().getGlslType());
        right.setName(param.getName());
        right.setPrefix("m_");

        if (left.getMultiplicity() != null) {

            if (!param.getVarType().name().endsWith("Array")) {
                throw new MatParseException(param.getName() + " is not of Array type", statement);
            }

            String multiplicity = left.getMultiplicity();
            try {
                Integer.parseInt(multiplicity);
            } catch (final NumberFormatException nfe) {
                // multiplicity is not an int attempting to find for a material parameter.
                MatParam mp = findMatParam(multiplicity);
                if (mp != null) {
                    // It's tied to a material param, let's create a define and use this as the multiplicity
                    addDefine(multiplicity, VarType.Int);
                    multiplicity = multiplicity.toUpperCase();
                    left.setMultiplicity(multiplicity);
                    // only declare the variable if the define is defined.
                    left.setCondition(mergeConditions(left.getCondition(), "defined(" + multiplicity + ")", "||"));
                } else {
                    throw new MatParseException("Wrong multiplicity for variable" + left.getName() + ". " +
                            multiplicity + " should be an int or a declared material parameter.", statement);
                }
            }

            // the right variable must have the same multiplicity and the same condition.
            right.setMultiplicity(multiplicity);
            right.setCondition(left.getCondition());
        }

        dv = new DeclaredVariable(right);
        map.put(right.getName(), dv);
        dv.addNode(shaderNode);
        mapping.setRightVariable(right);
        return true;
    }

    dv.addNode(shaderNode);
    mapping.setRightVariable(dv.var);

    return false;
}
 
Example 5
Source File: MaterialProperty.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public MaterialProperty(MatParam param) {
    this.type = param.getVarType().name();
    this.name = param.getName();
    Object obj = param.getValue();
    this.value = param.getValueAsString();
}