- add support for material name mappings to MaterialExtensionLoader
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7997 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
59d7bcdee6
commit
3081862ced
@ -40,6 +40,7 @@ import com.jme3.scene.plugins.ogre.MaterialLoader;
|
|||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.texture.Texture.WrapMode;
|
import com.jme3.texture.Texture.WrapMode;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -79,10 +80,9 @@ public class MaterialExtensionLoader {
|
|||||||
key.setGenerateMips(true);
|
key.setGenerateMips(true);
|
||||||
key.setAsCube(false);
|
key.setAsCube(false);
|
||||||
Texture tex = assetManager.loadTexture(key);
|
Texture tex = assetManager.loadTexture(key);
|
||||||
// XXX: Is this really neccessary?
|
|
||||||
tex.setWrap(WrapMode.Repeat);
|
|
||||||
if (tex == null)
|
if (tex == null)
|
||||||
throw new IOException("Cannot load texture: " + texturePath);
|
throw new IOException("Cannot load texture: " + texturePath);
|
||||||
|
tex.setWrap(WrapMode.Repeat);
|
||||||
|
|
||||||
material.setTexture(jmeParamName, tex);
|
material.setTexture(jmeParamName, tex);
|
||||||
|
|
||||||
@ -140,6 +140,12 @@ public class MaterialExtensionLoader {
|
|||||||
|
|
||||||
Material material = readExtendingMaterial();
|
Material material = readExtendingMaterial();
|
||||||
list.put(matName, material);
|
list.put(matName, material);
|
||||||
|
List<String> matAliases = matExts.getNameMappings(matName);
|
||||||
|
if(matAliases != null){
|
||||||
|
for (String string : matAliases) {
|
||||||
|
list.put(string, material);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -32,7 +32,9 @@
|
|||||||
|
|
||||||
package com.jme3.scene.plugins.ogre.matext;
|
package com.jme3.scene.plugins.ogre.matext;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>MaterialExtensionSet</code> is simply a container for several
|
* <code>MaterialExtensionSet</code> is simply a container for several
|
||||||
@ -42,6 +44,7 @@ import java.util.HashMap;
|
|||||||
public class MaterialExtensionSet {
|
public class MaterialExtensionSet {
|
||||||
private HashMap<String, MaterialExtension> extensions
|
private HashMap<String, MaterialExtension> extensions
|
||||||
= new HashMap<String, MaterialExtension>();
|
= new HashMap<String, MaterialExtension>();
|
||||||
|
private HashMap<String, List<String>> nameMappings = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new material extension to the set of extensions.
|
* Adds a new material extension to the set of extensions.
|
||||||
@ -61,4 +64,22 @@ public class MaterialExtensionSet {
|
|||||||
public MaterialExtension getMaterialExtension(String baseMatName){
|
public MaterialExtension getMaterialExtension(String baseMatName){
|
||||||
return extensions.get(baseMatName);
|
return extensions.get(baseMatName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an alternative name for a material
|
||||||
|
* @param name The material name to be found in a .mesh.xml file
|
||||||
|
* @param alias The material name to be found in a .material file
|
||||||
|
*/
|
||||||
|
public void setNameMapping(String name, String alias){
|
||||||
|
List<String> list = nameMappings.get(name);
|
||||||
|
if(list==null){
|
||||||
|
list = new ArrayList<String>();
|
||||||
|
nameMappings.put(name, list);
|
||||||
|
}
|
||||||
|
list.add(alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getNameMappings(String name){
|
||||||
|
return nameMappings.get(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user