Skip to content

Instantly share code, notes, and snippets.

@Minikloon
Last active May 7, 2022 16:26
Show Gist options
  • Save Minikloon/93728e7ad494373b70753c072e36a77a to your computer and use it in GitHub Desktop.
Save Minikloon/93728e7ad494373b70753c072e36a77a to your computer and use it in GitHub Desktop.
Load gltf files but use the Lighting material
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