From 59f9f09e5f13e07a8e50e11cde4fcccd7b616845 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Fri, 26 Aug 2011 16:59:51 +0000 Subject: [PATCH] - make OgreMeshKey-based import not fail on missing material - add actual OgreMeshKey.setMaterialName() setter git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8114 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../ogre/com/jme3/scene/plugins/ogre/MeshLoader.java | 12 ++++++++++-- .../com/jme3/scene/plugins/ogre/OgreMeshKey.java | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java index 35e705535..7a11c27a3 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java @@ -784,9 +784,17 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { String materialName = meshKey.getMaterialName(); if (materialList == null) { if (materialName != null) { - materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + materialName + ".material")); + 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}); + } } else { - materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material")); + 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}); + } } } } else { diff --git a/engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java b/engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java index 8919e0794..a2b54f087 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java @@ -65,5 +65,9 @@ public class OgreMeshKey extends ModelKey { public String getMaterialName() { return materialName; } + + public void setMaterialName(String name) { + materialName = name; + } }