Last active
May 7, 2022 16:26
-
-
Save Minikloon/93728e7ad494373b70753c072e36a77a to your computer and use it in GitHub Desktop.
Load gltf files but use the Lighting material
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.minikloon.jmonkeytest; | |
import com.jme3.material.Materials; | |
import com.jme3.scene.plugins.gltf.PBRMetalRoughMaterialAdapter; | |
import java.util.Set; | |
public class GltfLoadAsLightingMaterialAdapter extends PBRMetalRoughMaterialAdapter { | |
private static final Set<String> IGNORED_GLTF_PARAMS = Set.of( | |
"baseColorFactor", | |
"roughnessFactor", | |
"metallicRoughnessTexture", | |
"alphaMode", | |
"alphaCutoff", | |
"doubleSided" | |
); | |
public GltfLoadAsLightingMaterialAdapter() { | |
addParamMapping("baseColorTexture", "DiffuseMap"); | |
addParamMapping("metallicFactor", "Shininess"); | |
addParamMapping("emissiveTexture", "GlowMap"); | |
addParamMapping("emissiveFactor", "GlowColor"); | |
} | |
@Override | |
protected String getMaterialDefPath() { | |
return Materials.LIGHTING; | |
} | |
@Override | |
protected String getJmeParamName(String gltfParamName) { | |
if (IGNORED_GLTF_PARAMS.contains(gltfParamName)) { | |
return null; | |
} | |
return super.getJmeParamName(gltfParamName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment