* Remove duplicate code in MeshLoader that handles loading the material list
* Added javadoc in OgreMeshKey git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8594 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
cfd13e8d33
commit
de75b794c2
engine/src/ogre/com/jme3/scene/plugins/ogre
@ -790,36 +790,36 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
|
||||
}
|
||||
assetManager = info.getManager();
|
||||
|
||||
OgreMeshKey meshKey = null;
|
||||
if (key instanceof OgreMeshKey) {
|
||||
meshKey = (OgreMeshKey) key;
|
||||
// OgreMeshKey is being used, try getting the material list
|
||||
// from it
|
||||
OgreMeshKey meshKey = (OgreMeshKey) key;
|
||||
materialList = meshKey.getMaterialList();
|
||||
String materialName = meshKey.getMaterialName();
|
||||
if (materialList == null) {
|
||||
if (materialName != null) {
|
||||
try {
|
||||
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + materialName + ".material"));
|
||||
} catch (AssetNotFoundException e) {
|
||||
logger.log(Level.WARNING, "Cannot locate {0}{1}.material for model {2}{3}.{4}", new Object[]{folderName, materialName, folderName, meshName, ext});
|
||||
logger.log(Level.WARNING, "", e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material"));
|
||||
} catch (AssetNotFoundException e) {
|
||||
logger.log(Level.WARNING, "Cannot locate {0}{1}.material for model {2}{3}.{4}", new Object[]{folderName, meshName, folderName, meshName, ext});
|
||||
logger.log(Level.WARNING, "", e);
|
||||
}
|
||||
|
||||
// Material list not set but material name is available
|
||||
if (materialList == null && materialName != null) {
|
||||
OgreMaterialKey materialKey = new OgreMaterialKey(folderName + materialName + ".material");
|
||||
try {
|
||||
materialList = (MaterialList) assetManager.loadAsset(materialKey);
|
||||
} catch (AssetNotFoundException e) {
|
||||
logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{materialKey, key});
|
||||
logger.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material"));
|
||||
} catch (AssetNotFoundException e) {
|
||||
logger.log(Level.WARNING, "Cannot locate {0}{1}.material for model {2}{3}.{4}", new Object[]{folderName, meshName, folderName, meshName, ext});
|
||||
logger.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
// If for some reason material list could not be found through
|
||||
// OgreMeshKey, or if regular ModelKey specified, load using
|
||||
// default method.
|
||||
if (materialList == null){
|
||||
OgreMaterialKey materialKey = new OgreMaterialKey(folderName + meshName + ".material");
|
||||
try {
|
||||
materialList = (MaterialList) assetManager.loadAsset(materialKey);
|
||||
} catch (AssetNotFoundException e) {
|
||||
logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{ materialKey, key });
|
||||
logger.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Added by larynx 25.06.2011
|
||||
|
@ -35,6 +35,14 @@ package com.jme3.scene.plugins.ogre;
|
||||
import com.jme3.asset.ModelKey;
|
||||
import com.jme3.material.MaterialList;
|
||||
|
||||
/**
|
||||
* OgreMeshKey is used to load Ogre3D mesh.xml models with a specific
|
||||
* material file or list. This allows customizing from where the materials
|
||||
* are retrieved, instead of loading the material file as the same
|
||||
* name as the model (the default).
|
||||
*
|
||||
* @author Kirill Vainer
|
||||
*/
|
||||
public class OgreMeshKey extends ModelKey {
|
||||
|
||||
private MaterialList materialList;
|
||||
@ -62,6 +70,10 @@ public class OgreMeshKey extends ModelKey {
|
||||
return materialList;
|
||||
}
|
||||
|
||||
public void setMaterialList(MaterialList materialList){
|
||||
this.materialList = materialList;
|
||||
}
|
||||
|
||||
public String getMaterialName() {
|
||||
return materialName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user