material: warn / ignore fixed function techniques

cleanup_build_scripts
Kirill Vainer 9 years ago
parent b6729c46d4
commit 8bd5b59a0e
  1. 5
      jme3-core/src/main/java/com/jme3/material/TechniqueDef.java
  2. 22
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java
  3. 15
      jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java

@ -134,13 +134,12 @@ public class TechniqueDef implements Savable {
* <p>
* Used internally by the J3M/J3MD loader.
*
* @param name The name of the technique, should be set to <code>null</code>
* for default techniques.
* @param name The name of the technique
*/
public TechniqueDef(String name, int sortId){
this();
this.sortId = sortId;
this.name = name == null ? TechniqueDef.DEFAULT_TECHNIQUE_NAME : name;
this.name = name;
}
/**

@ -590,18 +590,19 @@ public class J3MLoader implements AssetLoader {
private void readTechnique(Statement techStat) throws IOException{
isUseNodes = false;
String[] split = techStat.getLine().split(whitespacePattern);
String name;
if (split.length == 1) {
String techniqueUniqueName = materialDef.getAssetName() + "@Default";
technique = new TechniqueDef(null, techniqueUniqueName.hashCode());
name = TechniqueDef.DEFAULT_TECHNIQUE_NAME;
} else if (split.length == 2) {
String techName = split[1];
String techniqueUniqueName = materialDef.getAssetName() + "@" + techName;
technique = new TechniqueDef(techName, techniqueUniqueName.hashCode());
name = split[1];
} else {
throw new IOException("Technique statement syntax incorrect");
}
String techniqueUniqueName = materialDef.getAssetName() + "@" + name;
technique = new TechniqueDef(name, techniqueUniqueName.hashCode());
for (Statement statement : techStat.getContents()){
readTechniqueStatement(statement);
}
@ -619,6 +620,15 @@ public class J3MLoader implements AssetLoader {
if (shaderNames.containsKey(Shader.ShaderType.Vertex) && shaderNames.containsKey(Shader.ShaderType.Fragment)) {
technique.setShaderFile(shaderNames, shaderLanguages);
} else {
technique = null;
shaderLanguages.clear();
shaderNames.clear();
presetDefines.clear();
logger.log(Level.WARNING, "Fixed function technique was ignored");
logger.log(Level.WARNING, "Fixed function technique ''{0}'' was ignored for material {1}",
new Object[]{name, key});
return;
}
technique.setShaderPrologue(createShaderPrologue(presetDefines));

@ -55,6 +55,21 @@ public class J3MLoaderTest {
j3MLoader = new J3MLoader();
}
@Test
public void noDefaultTechnique_shouldBeSupported() throws IOException {
when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-default-technique.j3md"));
MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo);
assertEquals(1, def.getTechniqueDefs("Test").size());
}
@Test
public void fixedPipelineTechnique_shouldBeIgnored() throws IOException {
when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-shader-specified.j3md"));
MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo);
assertEquals(null, def.getTechniqueDefs("A"));
assertEquals(1, def.getTechniqueDefs("B").size());
}
@Test
public void multipleSameNamedTechniques_shouldBeSupported() throws IOException {
when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/same-name-technique.j3md"));

Loading…
Cancel
Save