Examples of MatParam


Examples of com.jme3.material.MatParam

    return grassPatch;
  }

  private static boolean isGrassLayer(Vector3f pos, Geometry terrain,
      float intensitiyThreshold, float scaledWidth, int channelId) {
    MatParam matParam = terrain.getMaterial().getParam("AlphaMap");
    if (matParam == null)// try to get the default one..
      matParam = terrain.getMaterial().getParam("DiffuseMap");
    if (matParam == null)
      return false;
    Texture tex = (Texture) matParam.getValue();
    Image image = tex.getImage();
    Vector2f uv = getPointPercentagePosition(terrain, pos, scaledWidth);

    ByteBuffer buf = image.getData(0);
    int width = image.getWidth();
View Full Code Here

Examples of com.jme3.material.MatParam

    public boolean equalsParams(ListMap params, TechniqueDef def) {
       
        int size = 0;

        for(int i = 0; i < params.size() ; i++ ) {
            MatParam param = (MatParam)params.getValue(i);
            String key = def.getShaderParamDefine(param.getName());
            if (key != null) {
                Object val = param.getValue();
                if (val != null) {

                    switch (param.getVarType()) {
                    case Boolean: {
                        String current = defines.get(key);
                        if (((Boolean) val).booleanValue()) {
                            if (current == null || current != ONE) {
                                return false;
View Full Code Here

Examples of com.jme3.material.MatParam

                String multiplicity = mapping.getLeftVariable().getMultiplicity();
                try {
                    Integer.parseInt(multiplicity);
                } catch (NumberFormatException nfe) {
                    //multiplicity is not an int attempting to find for a material parameter.
                    MatParam mp = findMatParam(multiplicity);
                    if (mp != null) {
                        addDefine(multiplicity);
                        multiplicity = multiplicity.toUpperCase();
                    } else {
                        throw new MatParseException("Wrong multiplicity for variable" + mapping.getLeftVariable().getName() + ". " + multiplicity + " should be an int or a declared material parameter.", statement);
View Full Code Here

Examples of com.jme3.material.MatParam

     * @throws IOException
     */
    public void extractCondition(String cond, Statement statement) throws IOException {
        List<String> defines = conditionParser.extractDefines(cond);
        for (String string : defines) {
            MatParam param = findMatParam(string);
            if (param != null) {
                addDefine(param.getName());
            } else {
                throw new MatParseException("Invalid condition, condition must match a Material Parameter named " + cond, statement);
            }
        }
    }
View Full Code Here

Examples of com.jme3.material.MatParam

            }
            updateVarFromAttributes(mapping.getRightVariable(), mapping);
            //          updateCondition(mapping.getRightVariable(), mapping);
            storeAttribute(mapping.getRightVariable());
        } else if (right.getNameSpace().equals("MatParam")) {
            MatParam param = findMatParam(right.getName());
            if (param == null) {
                throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1);
            }
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
                if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) {                 
                    storeVertexUniform(mapping.getRightVariable());
                }
            } else {
                if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement1)) {
                    if (mapping.getRightVariable().getType().contains("|")) {
                        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(), statement1);
                        }
                    }               
                    storeFragmentUniform(mapping.getRightVariable());
                }
            }
View Full Code Here

Examples of com.jme3.material.MatParam

        }
        needRefresh = false;
    }

    private ColorRGBA getColor( Material mat, String name ) {
        MatParam mp = mat.getParam(name);
        if( mp == null ) {
            return null;
        }
        return (ColorRGBA)mp.getValue();
    }
View Full Code Here

Examples of com.jme3.material.MatParam

     */
    public Material getParticlesMaterial(Material material, Integer alphaMaskIndex, BlenderContext blenderContext) {
        Material result = new Material(blenderContext.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");

        // copying texture
        MatParam diffuseMap = material.getParam("DiffuseMap");
        if (diffuseMap != null) {
            Texture texture = ((Texture) diffuseMap.getValue()).clone();

            // applying alpha mask to the texture
            Image image = texture.getImage();
            ByteBuffer sourceBB = image.getData(0);
            sourceBB.rewind();
            int w = image.getWidth();
            int h = image.getHeight();
            ByteBuffer bb = BufferUtils.createByteBuffer(w * h * 4);
            IAlphaMask iAlphaMask = alphaMasks.get(alphaMaskIndex);
            iAlphaMask.setImageSize(w, h);

            for (int x = 0; x < w; ++x) {
                for (int y = 0; y < h; ++y) {
                    bb.put(sourceBB.get());
                    bb.put(sourceBB.get());
                    bb.put(sourceBB.get());
                    bb.put(iAlphaMask.getAlpha(x, y));
                }
            }

            image = new Image(Format.RGBA8, w, h, bb);
            texture.setImage(image);

            result.setTextureParam("Texture", VarType.Texture2D, texture);
        }

        // copying glow color
        MatParam glowColor = material.getParam("GlowColor");
        if (glowColor != null) {
            ColorRGBA color = (ColorRGBA) glowColor.getValue();
            result.setParam("GlowColor", VarType.Vector3, color);
        }
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.