本文整理匯總了Java中com.jme3.material.Material.getParam方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.getParam方法的具體用法?Java Material.getParam怎麽用?Java Material.getParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.material.Material
的用法示例。
在下文中一共展示了Material.getParam方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDiffuse
import com.jme3.material.Material; //導入方法依賴的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();
}
示例2: setDiffuse
import com.jme3.material.Material; //導入方法依賴的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);
}
示例3: getNormal
import com.jme3.material.Material; //導入方法依賴的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();
}
示例4: setNormal
import com.jme3.material.Material; //導入方法依賴的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);
}
示例5: getAlpha
import com.jme3.material.Material; //導入方法依賴的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();
}
示例6: changePaintControlShininess
import com.jme3.material.Material; //導入方法依賴的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);
}
示例7: refreshProperties
import com.jme3.material.Material; //導入方法依賴的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);
}
}
示例8: updateTexture
import com.jme3.material.Material; //導入方法依賴的package包/類
private void updateTexture(@Nullable final Texture texture, @NotNull final String paramName,
@NotNull final Geometry geometry) {
final Material material = geometry.getMaterial();
final MatParam matParam = material.getParam(paramName);
if (matParam == null && texture == null) return;
if (texture == null) {
material.clearParam(matParam.getName());
} else {
material.setTexture(paramName, texture);
}
}
示例9: getTextureScale
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Get a texture scale of the level.
*
* @param layer the layer.
* @return the texture scale or -1.
*/
@FromAnyThread
public float getTextureScale(final int layer) {
final Function<Integer, String> layerToScaleName = getLayerToScaleName();
if (layerToScaleName == null) return -1F;
final Terrain terrain = getTerrain();
final Material material = terrain.getMaterial();
final MatParam matParam = material.getParam(layerToScaleName.apply(layer));
return matParam == null ? -1F : (float) matParam.getValue();
}
示例10: setTextureScale
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Set a new texture scale to a level.
*
* @param scale the texture scale.
* @param layer the layer.
*/
@FromAnyThread
public void setTextureScale(final float scale, final int layer) {
final Function<Integer, String> layerToScaleName = getLayerToScaleName();
if (layerToScaleName == null) return;
final Terrain terrain = getTerrain();
final Material material = terrain.getMaterial();
final String paramName = layerToScaleName.apply(layer);
final MatParam matParam = material.getParam(paramName);
final Float current = matParam == null ? null : (Float) matParam.getValue();
final PropertyOperation<ChangeConsumer, Node, Float> operation =
new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, scale, current);
operation.setApplyHandler((node, newScale) -> {
NodeUtils.visitGeometry(getTerrainNode(), geometry -> {
final Material geometryMaterial = geometry.getMaterial();
final MatParam param = geometryMaterial.getParam(paramName);
if (param == null && (newScale == null || newScale == -1F)) return;
if (newScale == null || newScale == -1F) {
geometryMaterial.clearParam(paramName);
} else {
geometryMaterial.setFloat(paramName, newScale);
}
});
});
final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
changeConsumer.execute(operation);
}
示例11: getParamValue
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Get relevant value of the material parameter.
*
* @param param the material parameter.
* @param material the material.
* @return the relevant value.
*/
@FXThread
protected @Nullable Object getParamValue(@NotNull final MatParam param, @NotNull final Material material) {
final MatParam currentParam = material.getParam(param.getName());
return currentParam == null ? null : currentParam.getValue();
}