本文整理匯總了Java中com.jme3.material.Material.getMaterialDef方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.getMaterialDef方法的具體用法?Java Material.getMaterialDef怎麽用?Java Material.getMaterialDef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.material.Material
的用法示例。
在下文中一共展示了Material.getMaterialDef方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startProcessing
import com.jme3.material.Material; //導入方法依賴的package包/類
@Override
public void startProcessing(@NotNull final Object object) {
super.startProcessing(object);
final TextureLayerSettings settings = getTextureLayerSettings();
final Terrain terrain = (Terrain) object;
final Material material = terrain.getMaterial();
final MaterialDef materialDef = material.getMaterialDef();
if (materialDef.getAssetName().equals("Common/MatDefs/Terrain/TerrainLighting.j3md")) {
settings.setLayerToScaleName(LAYER_TO_SCALE_NAME);
settings.setLayerToAlphaName(LAYER_TO_ALPHA_NAME);
settings.setLayerToDiffuseName(LAYER_TO_DIFFUSE_NAME);
settings.setLayerToNormalName(LAYER_TO_NORMAL_NAME);
settings.setMaxLevels(12);
}
refreshProperties();
settings.refresh();
}
示例2: reload
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Reload the material.
*/
@FXThread
private void reload(@NotNull final Material material) {
setCurrentMaterial(material);
setIgnoreListeners(true);
try {
final MaterialEditor3DState editor3DState = getEditor3DState();
editor3DState.updateMaterial(material);
getSettingsTree().fill(new RootMaterialSettings(material));
final ComboBox<String> materialDefinitionBox = getMaterialDefinitionBox();
final ObservableList<String> items = materialDefinitionBox.getItems();
items.clear();
items.addAll(RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION));
final MaterialDef materialDef = material.getMaterialDef();
materialDefinitionBox.getSelectionModel().select(materialDef.getAssetName());
} finally {
setIgnoreListeners(false);
}
}
示例3: validate
import com.jme3.material.Material; //導入方法依賴的package包/類
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {
final ComboBox<String> comboBox = getTextureParamNameComboBox();
final ObservableList<String> items = comboBox.getItems();
items.clear();
final Path file = element == null ? null : element.getFile();
if (file != null && !Files.isDirectory(file)) {
final AssetManager assetManager = EDITOR.getAssetManager();
final Path assetFile = getAssetFile(file);
if (assetFile == null) {
throw new RuntimeException("AssetFile can't be null.");
}
final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));
final Material material = assetManager.loadAsset(materialKey);
final MaterialDef materialDef = material.getMaterialDef();
final Collection<MatParam> materialParams = materialDef.getMaterialParams();
materialParams.stream()
.filter(param -> param.getVarType() == VarType.Texture2D)
.filter(matParam -> material.getTextureParam(matParam.getName()) != null)
.forEach(filtred -> items.add(filtred.getName()));
final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();
if (!items.isEmpty()) {
selectionModel.select(0);
} else {
selectionModel.select(null);
}
}
super.validate(warningLabel, element);
}
示例4: getProperties
import com.jme3.material.Material; //導入方法依賴的package包/類
@Override
@FXThread
protected @Nullable List<EditableProperty<?, ?>> getProperties(@NotNull final Object object) {
if(!(object instanceof Material)) return null;
final Material material = (Material) object;
final MaterialDef definition = material.getMaterialDef();
final Collection<MatParam> materialParams = definition.getMaterialParams();
return materialParams.stream()
.sorted(MAT_PARAM_COMPARATOR)
.map(param -> convert(param, material))
.filter(Objects::nonNull)
.collect(toList());
}
示例5: getProperties
import com.jme3.material.Material; //導入方法依賴的package包/類
@Override
@FXThread
protected @Nullable List<EditableProperty<?, ?>> getProperties(@NotNull final Object object) {
if (!(object instanceof MaterialSettings) || object instanceof RootMaterialSettings) {
return null;
}
final MaterialSettings settings = (MaterialSettings) object;
final Material material = settings.getMaterial();
if(object instanceof RenderSettings) {
final RenderState renderState = material.getAdditionalRenderState();
final List<EditableProperty<?, ?>> result = new ArrayList<>();
result.add(new SimpleProperty<>(BOOLEAN, Messages.MATERIAL_RENDER_STATE_COLOR_WRITE, settings,
sett -> renderState.isColorWrite(),
(sett, property) -> renderState.setColorWrite(property)));
result.add(new SimpleProperty<>(BOOLEAN, Messages.MATERIAL_RENDER_STATE_DEPTH_WRITE, settings,
sett -> renderState.isDepthWrite(),
(sett, property) -> renderState.setDepthWrite(property)));
result.add(new SimpleProperty<>(BOOLEAN, Messages.MATERIAL_RENDER_STATE_DEPTH_TEST, settings,
sett -> renderState.isDepthTest(),
(sett, property) -> renderState.setDepthTest(property)));
result.add(new SimpleProperty<>(BOOLEAN, Messages.MATERIAL_RENDER_STATE_WIREFRAME, settings,
sett -> renderState.isWireframe(),
(sett, property) -> renderState.setWireframe(property)));
result.add(new SimpleProperty<>(ENUM, Messages.MATERIAL_RENDER_STATE_FACE_CULL_MODE, settings,
sett -> renderState.getFaceCullMode(),
(sett, property) -> renderState.setFaceCullMode(property)));
result.add(new SimpleProperty<>(ENUM, Messages.MATERIAL_RENDER_STATE_BLEND_MODE, settings,
sett -> renderState.getBlendMode(),
(sett, property) -> renderState.setBlendMode(property)));
result.add(new SimpleProperty<>(ENUM, Messages.MATERIAL_RENDER_STATE_BLEND_EQUATION, settings,
sett -> renderState.getBlendEquation(),
(sett, property) -> renderState.setBlendEquation(property)));
result.add(new SimpleProperty<>(ENUM, Messages.MATERIAL_RENDER_STATE_BLEND_EQUATION_ALPHA, settings,
sett -> renderState.getBlendEquationAlpha(),
(sett, property) -> renderState.setBlendEquationAlpha(property)));
result.add(new SimpleProperty<>(FLOAT, Messages.MATERIAL_RENDER_STATE_POLY_OFFSET_FACTOR, 0.1F, settings,
sett -> renderState.getPolyOffsetFactor(),
(sett, property) -> renderState.setPolyOffset(property, renderState.getPolyOffsetUnits())));
result.add(new SimpleProperty<>(FLOAT, Messages.MATERIAL_RENDER_STATE_POLY_OFFSET_UNITS, 0.1F, settings,
sett -> renderState.getPolyOffsetUnits(),
(sett, property) -> renderState.setPolyOffset(renderState.getPolyOffsetFactor(), property)));
return result;
}
final MaterialDef materialDef = material.getMaterialDef();
return materialDef.getMaterialParams()
.stream()
.filter(param -> filter(param, object))
.sorted(MAT_PARAM_NAME_COMPARATOR)
.map(param -> convert(param, material, settings))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
示例6: applyTexture
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Try to apply dropped texture.
*
* @param editor the editor.
* @param dragEvent the drag event.
* @param path the path to the texture.
*/
private void applyTexture(@NotNull final MaterialFileEditor editor, @NotNull final DragEvent dragEvent,
@NotNull final Path path) {
final String textureName = path.getFileName().toString();
final int textureType = MaterialUtils.getPossibleTextureType(textureName);
if (textureType == 0) {
return;
}
final String[] paramNames = MaterialUtils.getPossibleParamNames(textureType);
final Material currentMaterial = getCurrentMaterial();
final MaterialDef materialDef = currentMaterial.getMaterialDef();
final Optional<MatParam> param = Arrays.stream(paramNames)
.map(materialDef::getMaterialParam)
.filter(Objects::nonNull)
.filter(p -> p.getVarType() == VarType.Texture2D)
.findAny();
if (!param.isPresent()) {
return;
}
final MatParam matParam = param.get();
EXECUTOR_MANAGER.addJMETask(() -> {
final EditorConfig config = EditorConfig.getInstance();
final Path assetFile = notNull(getAssetFile(path));
final TextureKey textureKey = new TextureKey(toAssetPath(assetFile));
textureKey.setFlipY(config.isDefaultUseFlippedTexture());
final AssetManager assetManager = EDITOR.getAssetManager();
final Texture texture = assetManager.loadTexture(textureKey);
texture.setWrap(Texture.WrapMode.Repeat);
final String paramName = matParam.getName();
final MatParamTexture textureParam = currentMaterial.getTextureParam(paramName);
final Texture currentTexture = textureParam == null? null : textureParam.getTextureValue();
PropertyOperation<ChangeConsumer, Material, Texture> operation =
new PropertyOperation<>(currentMaterial, paramName, texture, currentTexture);
operation.setApplyHandler((material, newTexture) -> material.setTexture(paramName, newTexture));
execute(operation);
});
}
示例7: serializeToString
import com.jme3.material.Material; //導入方法依賴的package包/類
/**
* Serialize to string string.
*
* @param material the material
* @return the string
*/
public static String serializeToString(@NotNull final Material material) {
final MaterialDef materialDef = material.getMaterialDef();
final Collection<MatParam> params = material.getParams();
final StringBuilder builder = new StringBuilder();
builder.append("Material MyMaterial : ").append(materialDef.getAssetName()).append(" {\n");
builder.append(" MaterialParameters {\n");
params.forEach(matParam -> {
final String value = toString(matParam.getVarType(), matParam.getValue());
builder.append(" ").append(matParam.getName()).append(" : ").append(value).append('\n');
});
builder.append(" }\n");
builder.append(" AdditionalRenderState {\n");
final RenderState renderState = material.getAdditionalRenderState();
final RenderState.BlendMode blendMode = renderState.getBlendMode();
final RenderState.FaceCullMode faceCullMode = renderState.getFaceCullMode();
if (blendMode != RenderState.BlendMode.Off) {
builder.append(" Blend ").append(blendMode.name()).append('\n');
}
if (faceCullMode != RenderState.FaceCullMode.Back) {
builder.append(" FaceCull ").append(faceCullMode.name()).append('\n');
}
if (renderState.isWireframe()) builder.append(" Wireframe On\n");
if (!renderState.isDepthTest()) builder.append(" DepthTest Off\n");
if (!renderState.isDepthWrite()) builder.append(" DepthWrite Off\n");
if (!renderState.isColorWrite()) builder.append(" ColorWrite Off\n");
final float polyOffsetFactor = renderState.getPolyOffsetFactor();
final float polyOffsetUnits = renderState.getPolyOffsetUnits();
if (polyOffsetFactor != 0 || polyOffsetUnits != 0) {
builder.append(" PolyOffset ").append(polyOffsetFactor).append(' ').append(polyOffsetUnits).append('\n');
}
builder.append(" }\n");
builder.append("}");
return builder.toString();
}