当前位置: 首页>>代码示例>>Java>>正文


Java MatParam类代码示例

本文整理汇总了Java中com.jme3.material.MatParam的典型用法代码示例。如果您正苦于以下问题:Java MatParam类的具体用法?Java MatParam怎么用?Java MatParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MatParam类属于com.jme3.material包,在下文中一共展示了MatParam类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDiffuse

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Get a diffuse texture of the level.
 *
 * @param layer the layer.
 * @return the diffuse texture or null.
 */
@FromAnyThread
public @Nullable Texture getDiffuse(final int layer) {

    final Function<Integer, String> layerToDiffuseName = getLayerToDiffuseName();
    if (layerToDiffuseName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToDiffuseName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:TextureLayerSettings.java

示例2: setDiffuse

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Set a new diffuse texture to a level.
 *
 * @param texture the new texture.
 * @param layer   the layer.
 */
@FromAnyThread
public void setDiffuse(@Nullable final Texture texture, final int layer) {

    final Function<Integer, String> layerToDiffuseName = getLayerToDiffuseName();
    if (layerToDiffuseName == null) return;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final String paramName = layerToDiffuseName.apply(layer);
    final MatParam matParam = material.getParam(paramName);
    final Texture current = matParam == null ? null : (Texture) matParam.getValue();

    if (texture != null) {
        texture.setWrap(Texture.WrapMode.Repeat);
    }

    final PropertyOperation<ChangeConsumer, Node, Texture> operation =
            new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, texture, current);

    operation.setApplyHandler((node, newTexture) ->
            NodeUtils.visitGeometry(node, geometry -> updateTexture(newTexture, paramName, geometry)));

    final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
    changeConsumer.execute(operation);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:32,代码来源:TextureLayerSettings.java

示例3: getNormal

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Get a diffuse normal of the level.
 *
 * @param layer the layer.
 * @return the normal texture or null.
 */
@FromAnyThread
public @Nullable Texture getNormal(final int layer) {

    final Function<Integer, String> layerToNormalName = getLayerToNormalName();
    if (layerToNormalName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToNormalName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:TextureLayerSettings.java

示例4: setNormal

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Set a new normal texture to a level.
 *
 * @param texture the normal texture.
 * @param layer   the layer.
 */
@FromAnyThread
public void setNormal(@Nullable final Texture texture, final int layer) {

    final Function<Integer, String> layerToNormalName = getLayerToNormalName();
    if (layerToNormalName == null) return;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final String paramName = layerToNormalName.apply(layer);
    final MatParam matParam = material.getParam(paramName);
    final Texture current = matParam == null ? null : (Texture) matParam.getValue();

    if (texture != null) {
        texture.setWrap(Texture.WrapMode.Repeat);
    }

    final PropertyOperation<ChangeConsumer, Node, Texture> operation =
            new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, texture, current);

    operation.setApplyHandler((node, newTexture) ->
            NodeUtils.visitGeometry(node, geometry -> updateTexture(newTexture, paramName, geometry)));

    final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
    changeConsumer.execute(operation);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:32,代码来源:TextureLayerSettings.java

示例5: getAlpha

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Get a alpha texture of the level.
 *
 * @param layer the layer.
 * @return the alpha texture or null.
 */
@FromAnyThread
public @Nullable Texture getAlpha(final int layer) {

    final Function<Integer, String> layerToAlphaName = getLayerToAlphaName();
    if (layerToAlphaName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToAlphaName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:TextureLayerSettings.java

示例6: changePaintControlShininess

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Change the shininess value.
 */
@FromAnyThread
private void changePaintControlShininess(@NotNull final Float newValue) {
    if (isIgnoreListeners()) return;

    final TerrainQuad processedObject = getProcessedObject();
    final Material mat = processedObject.getMaterial();
    final MatParam param = mat.getParam("Shininess");
    final float shininess = param == null ? 0F : (float) param.getValue();

    final PropertyOperation<ChangeConsumer, TerrainQuad, Float> operation =
            new PropertyOperation<>(processedObject, TERRAIN_PARAM, newValue, shininess);

    operation.setApplyHandler((terrainQuad, value) -> {
        NodeUtils.visitGeometry(terrainQuad, geometry -> {
            final Material material = geometry.getMaterial();
            material.setFloat("Shininess", value);
        });
    });

    final ModelChangeConsumer changeConsumer = getChangeConsumer();
    changeConsumer.execute(operation);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:TerrainEditingComponent.java

示例7: refreshProperties

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Refresh terrain properties.
 */
private void refreshProperties() {
    setIgnoreListeners(true);
    try {

        final Terrain terrain = getProcessedObject();
        final Material material = terrain.getMaterial();
        final FloatTextField shininessField = getShininessField();
        final CheckBox triPlanarCheckBox = getTriPlanarCheckBox();
        final MatParam shininess = material.getParam("Shininess");
        final MatParam useTriPlanarMapping = material.getParam("useTriPlanarMapping");

        shininessField.setValue(shininess == null ? 0F : (float) shininess.getValue());
        triPlanarCheckBox.setSelected(useTriPlanarMapping != null && (boolean) useTriPlanarMapping.getValue());

    } finally {
        setIgnoreListeners(false);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:TerrainEditingComponent.java

示例8: updateLookupWithMaterialData

import com.jme3.material.MatParam; //导入依赖的package包/类
private void updateLookupWithMaterialData(MatDefDataObject obj) {
    obj.getLookupContents().add(materialDef);
    material = new Material(materialDef);

    try {
        //material.selectTechnique("Default", SceneApplication.getApplication().getRenderManager());
        if (matToRemove != null) {
            for (MatParam matParam : matToRemove.getParams()) {
                try {
                    material.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue());
                } catch (IllegalArgumentException ie) {
                    matToRemove.clearParam(matParam.getName());
                }

            }
            obj.getLookupContents().remove(matToRemove);
            matToRemove = null;
        }
        obj.getLookupContents().add(material);
    } catch (Exception e) {
        Logger.getLogger(EditableMatDefFile.class.getName()).log(Level.WARNING, "Error making material {0}", e.getMessage());
        material = matToRemove;
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:25,代码来源:EditableMatDefFile.java

示例9: getAlphaTexture

import com.jme3.material.MatParam; //导入依赖的package包/类
private Texture getAlphaTexture(Terrain terrain, int alphaLayer) {
    if (terrain == null)
        return null;
    MatParam matParam = null;
    if (alphaLayer == 0)
        matParam = terrain.getMaterial(null).getParam("AlphaMap");
    else if(alphaLayer == 1)
        matParam = terrain.getMaterial(null).getParam("AlphaMap_1");
    else if(alphaLayer == 2)
        matParam = terrain.getMaterial(null).getParam("AlphaMap_2");
    
    if (matParam == null || matParam.getValue() == null) {
        return null;
    }
    Texture tex = (Texture) matParam.getValue();
    return tex;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:18,代码来源:PaintTerrainToolAction.java

示例10: setColor

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * 给指定的spatial指定一个颜色,该方法主要改变spatial的material的Color
 * 属性,当没有该属性时会偿试添加一个,这要求该material的原形必须有一
 * 个"Color"属性的定义,该属性的verType必须是vector4.
 * @param spatial
 * @param color 
 */
public static void setColor(Spatial spatial, final ColorRGBA color) {
    spatial.depthFirstTraversal(new SceneGraphVisitorAdapter() {
        @Override
        public void visit(Geometry geom) {
            // 存在Color属性时更改颜色。
            Material mat = geom.getMaterial();
            if (mat != null) {
                MatParam colorParam = mat.getParam("Color");
                if (colorParam != null && colorParam.getVarType() == VarType.Vector4) {
                    ((ColorRGBA)colorParam.getValue()).set(color);
                    return;
                }
                // 不存在Color颜色时先看是否有Color属性的定义,如果有则添加该属性。
                MatParam colorDef = mat.getMaterialDef().getMaterialParam("Color");
                if (colorDef != null && colorDef.getVarType() == VarType.Vector4) {
                    // 这里需要重新创建一个,否则会引用同一个实例。
                    mat.setColor("Color", new ColorRGBA(color));
                }
            }
        }
    });
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:30,代码来源:GeometryUtils.java

示例11: doGetAlphaTexture

import com.jme3.material.MatParam; //导入依赖的package包/类
public final static Texture doGetAlphaTexture(Terrain terrain, int alphaLayer) {
    if (terrain == null)
        return null;
    MatParam matParam = null;
    if (alphaLayer == 0)
        matParam = terrain.getMaterial().getParam("AlphaMap");
    else if(alphaLayer == 1)
        matParam = terrain.getMaterial().getParam("AlphaMap_1");
    else if(alphaLayer == 2)
        matParam = terrain.getMaterial().getParam("AlphaMap_2");
    
    if (matParam == null || matParam.getValue() == null) {
        return null;
    }
    Texture tex = (Texture) matParam.getValue();
    return tex;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:18,代码来源:TerrainUtils.java

示例12: getDiffuseTexture

import com.jme3.material.MatParam; //导入依赖的package包/类
public final static Texture getDiffuseTexture(Terrain terrain, int layer) {
    if (terrain == null)
        return null;
    
    MatParam matParam;
    
    if (layer == 0)
        matParam = terrain.getMaterial().getParam("DiffuseMap");
    else
        matParam = terrain.getMaterial().getParam("DiffuseMap_"+ layer);
    
    if (matParam == null || matParam.getValue() == null) {
        return null;
    }
    Texture tex = (Texture) matParam.getValue();
    return tex;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:18,代码来源:TerrainUtils.java

示例13: controlRenderHardware

import com.jme3.material.MatParam; //导入依赖的package包/类
private void controlRenderHardware() {
        offsetMatrices = skeleton.computeSkinningMatrices();
        for (Material m : materials) {
            MatParam currentParam = m.getParam("BoneMatrices");
            if (currentParam != null) {
                if (currentParam.getValue() != offsetMatrices) {
                    // Check to see if other SkeletonControl
                    // is operating on this material, in that case, user
                    // is sharing materials between models which is NOT allowed
                    // when hardware skinning used.
//                    throw new UnsupportedOperationException(
//                            "Material instances cannot be shared when hardware skinning is used. " +
//                            "Ensure all models use unique material instances : " + m.getName()
//                    );
                	Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Material instances cannot be shared when hardware skinning is used. " +
                            "Ensure all models use unique material instances : " + m.getName());
                }
            }            
            m.setParam("BoneMatrices", VarType.Matrix4Array, offsetMatrices);
        }
    }
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:22,代码来源:SkeletonControl_31.java

示例14: destroy

import com.jme3.material.MatParam; //导入依赖的package包/类
@Override
public void destroy() {
    super.destroy();
    for (Spatial childSpatial : this.characterNode.getChildren()) {
        if (!(childSpatial instanceof Geometry)) {
            continue;
        }

        Geometry childGeometry = (Geometry) childSpatial;
        Material material = childGeometry.getMaterial();
        // TODO: Investingate if there is better solution for "Material parameter not defined"
        MatParam param = material.getParam("Diffuse");
        if (param != null) {
            material.setColor("Diffuse", ColorRGBA.White);
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:18,代码来源:BacklashInfo.java

示例15: setAsMaterial

import com.jme3.material.MatParam; //导入依赖的package包/类
/**
 * Creates the data from a material
 * @param mat
 */
public void setAsMaterial(Material mat) throws IOException {
    assert (mat.getMaterialDef().getAssetName() != null);
    setName("MyMaterial");
    setMatDefName(mat.getMaterialDef().getAssetName());
    createBaseMaterialFile();
    materialParameters.clear();
    Collection<MatParam> params = mat.getParams();
    for (Iterator<MatParam> it = params.iterator(); it.hasNext();) {
        MatParam matParam = it.next();
        materialParameters.put(matParam.getName(), new MaterialProperty(matParam));
    }
    additionalRenderStates.put("Wireframe", new MaterialProperty("OnOff", "Wireframe", mat.getAdditionalRenderState().isWireframe() ? "On" : "Off"));
    additionalRenderStates.put("DepthWrite", new MaterialProperty("OnOff", "DepthWrite", mat.getAdditionalRenderState().isDepthWrite() ? "On" : "Off"));
    additionalRenderStates.put("DepthTest", new MaterialProperty("OnOff", "DepthTest", mat.getAdditionalRenderState().isDepthTest() ? "On" : "Off"));
    additionalRenderStates.put("ColorWrite", new MaterialProperty("OnOff", "ColorWrite", mat.getAdditionalRenderState().isColorWrite() ? "On" : "Off"));
    additionalRenderStates.put("PointSprite", new MaterialProperty("OnOff", "PointSprite", mat.getAdditionalRenderState().isPointSprite() ? "On" : "Off"));
    additionalRenderStates.put("FaceCull", new MaterialProperty("FaceCullMode", "FaceCull", mat.getAdditionalRenderState().getFaceCullMode().name()));
    additionalRenderStates.put("Blend", new MaterialProperty("BlendMode", "Blend", mat.getAdditionalRenderState().getBlendMode().name()));
    additionalRenderStates.put("AlphaTestFalloff", new MaterialProperty("Float", "AlphaTestFalloff", mat.getAdditionalRenderState().getAlphaFallOff() + ""));
    additionalRenderStates.put("PolyOffset", new MaterialProperty("Float,Float", "PolyOffset", mat.getAdditionalRenderState().getPolyOffsetUnits() + " " + mat.getAdditionalRenderState().getPolyOffsetFactor()));
    checkWithMatDef();
    setAsText(getUpdatedContent());
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:28,代码来源:EditableMaterialFile.java


注:本文中的com.jme3.material.MatParam类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。