- fix +material issue for .scene loader
- check for actual name in AssetKey when warning about missing ogre material file

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9559 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
nor..67 2012-07-11 14:39:07 +00:00
parent 6c12291559
commit 558dc2bcbb
2 changed files with 13 additions and 11 deletions

View File

@ -61,17 +61,15 @@ public class OgreSceneDataObject extends SpatialAssetDataObject {
return null;
}
String name = getPrimaryFile().getName();
FileObject sourceMatFile = getPrimaryFile().getParent().getFileObject(name, "material");
if (sourceMatFile != null && sourceMatFile.isValid()) {
try {
sourceMatFile.copy(sourceMatFile.getParent(), "+" + sourceMatFile.getName(), sourceMatFile.getExt());
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
} else {
String matName = null;//((OgreSceneKey)getAssetKey()).getMaterialName();
if(matName == null){
matName = name;
}
FileObject sourceMatFile = getPrimaryFile().getParent().getFileObject(matName, "material");
if (sourceMatFile == null || !sourceMatFile.isValid()) {
Confirmation msg = new NotifyDescriptor.Confirmation(
"No material file found for " + getPrimaryFile().getNameExt() + "\n"
+ "A file named " + name + ".material should be in the same folder.\n"
+ "A file named " + matName + ".material should be in the same folder.\n"
+ "Press OK to import mesh only.",
NotifyDescriptor.OK_CANCEL_OPTION,
NotifyDescriptor.WARNING_MESSAGE);

View File

@ -85,11 +85,15 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
if(idx!=-1){
name = name.substring(0, idx);
}
FileObject sourceMatFile = getPrimaryFile().getParent().getFileObject(name, "material");
String matName = ((OgreMeshKey)getAssetKey()).getMaterialName();
if(matName == null){
matName = name;
}
FileObject sourceMatFile = getPrimaryFile().getParent().getFileObject(matName, "material");
if (sourceMatFile == null || !sourceMatFile.isValid()) {
Confirmation msg = new NotifyDescriptor.Confirmation(
"No material file found for " + getPrimaryFile().getNameExt() + "\n"
+ "A file named " + name + ".material should be in the same folder.\n"
+ "A file named " + matName + ".material should be in the same folder.\n"
+ "Press OK to import mesh only.",
NotifyDescriptor.OK_CANCEL_OPTION,
NotifyDescriptor.WARNING_MESSAGE);