Java Code Examples for com.jme3.shader.VarType#Texture2D
The following examples show how to use
com.jme3.shader.VarType#Texture2D .
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: MaterialUtils.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Check a material on containing a texture. * * @param material the material. * @param assetPath the path of the texture. * @return true if the material definition contains the texture. */ @FromAnyThread private static boolean containsTexture(@NotNull Material material, @NotNull String assetPath) { var materialParams = material.getParams(); for (var materialParam : materialParams) { if (materialParam.getVarType() != VarType.Texture2D) { continue; } var value = (Texture) materialParam.getValue(); var textureKey = value == null ? null : (TextureKey) value.getKey(); if (textureKey != null && StringUtils.equals(textureKey.getName(), assetPath)) { return true; } } return false; }
Example 2
Source File: MaterialAdapter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setParam(String gltfParamName, Object value) { String name = getJmeParamName(gltfParamName); if (name == null || value == null) { //no mapping registered or value is null, let's ignore this param return; } MatParam param; if (value instanceof Texture) { MatParam defParam = getMaterial().getMaterialDef().getMaterialParam(name); if (defParam == null) { throw new AssetLoadException("Material definition " + getMaterialDefPath() + " has not param with name" + name); } if (!(defParam instanceof MatParamTexture)) { throw new AssetLoadException("param with name" + name + "in material definition " + getMaterialDefPath() + " should be a texture param"); } param = new MatParamTexture(VarType.Texture2D, name, (Texture) value, ((MatParamTexture) defParam).getColorSpace()); param = adaptMatParam(param); if (param != null) { getMaterial().setTextureParam(param.getName(), param.getVarType(), (Texture) param.getValue()); } } else { param = new MatParam(getVarType(value), name, value); param = adaptMatParam(param); if (param != null) { getMaterial().setParam(param.getName(), param.getVarType(), param.getValue()); } } }
Example 3
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Pass a texture to the material shader. * * @param name the name of the texture defined in the material definition * (j3md) (for example Texture for Lighting.j3md) * @param value the Texture object previously loaded by the asset manager */ public void setTexture(String name, Texture value) { if (value == null) { // clear it clearTextureParam(name); return; } VarType paramType = null; switch (value.getType()) { case TwoDimensional: paramType = VarType.Texture2D; break; case TwoDimensionalArray: paramType = VarType.TextureArray; break; case ThreeDimensional: paramType = VarType.Texture3D; break; case CubeMap: paramType = VarType.TextureCubeMap; break; default: throw new UnsupportedOperationException("Unknown texture type: " + value.getType()); } setTextureParam(name, paramType, value); }
Example 4
Source File: MPOTestUtils.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static MatParamOverride mpoTexture2D(String name, Texture2D texture) { return new MatParamOverride(VarType.Texture2D, name, texture); }