- add support for material name to OgreMeshKey

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8107 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent ab5541f08d
commit fab0c6d73c
  1. 13
      engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java
  2. 18
      engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java
  3. 2
      engine/src/test/jme3test/material/TestBumpModel.java

@ -88,10 +88,8 @@ import static com.jme3.util.xml.SAXUtil.*;
public class MeshLoader extends DefaultHandler implements AssetLoader { public class MeshLoader extends DefaultHandler implements AssetLoader {
private static final Logger logger = Logger.getLogger(MeshLoader.class.getName()); private static final Logger logger = Logger.getLogger(MeshLoader.class.getName());
public static boolean AUTO_INTERLEAVE = true; public static boolean AUTO_INTERLEAVE = true;
public static boolean HARDWARE_SKINNING = false; public static boolean HARDWARE_SKINNING = false;
private static final Type[] TEXCOORD_TYPES = private static final Type[] TEXCOORD_TYPES =
new Type[]{ new Type[]{
Type.TexCoord, Type.TexCoord,
@ -101,14 +99,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
Type.TexCoord5, Type.TexCoord5,
Type.TexCoord6, Type.TexCoord6,
Type.TexCoord7, Type.TexCoord7,
Type.TexCoord8, Type.TexCoord8,};
};
private String meshName; private String meshName;
private String folderName; private String folderName;
private AssetManager assetManager; private AssetManager assetManager;
private MaterialList materialList; private MaterialList materialList;
// Data per submesh/sharedgeom // Data per submesh/sharedgeom
private ShortBuffer sb; private ShortBuffer sb;
private IntBuffer ib; private IntBuffer ib;
@ -121,13 +116,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
private int vertCount; private int vertCount;
private boolean usesSharedVerts; private boolean usesSharedVerts;
private boolean usesBigIndices; private boolean usesBigIndices;
// Global data // Global data
private Mesh sharedMesh; private Mesh sharedMesh;
private int meshIndex = 0; private int meshIndex = 0;
private int texCoordIndex = 0; private int texCoordIndex = 0;
private String ignoreUntilEnd = null; private String ignoreUntilEnd = null;
private List<Geometry> geoms = new ArrayList<Geometry>(); private List<Geometry> geoms = new ArrayList<Geometry>();
private IntMap<List<VertexBuffer>> lodLevels = new IntMap<List<VertexBuffer>>(); private IntMap<List<VertexBuffer>> lodLevels = new IntMap<List<VertexBuffer>>();
private AnimData animData; private AnimData animData;
@ -788,6 +781,10 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
if (key instanceof OgreMeshKey) { if (key instanceof OgreMeshKey) {
meshKey = (OgreMeshKey) key; meshKey = (OgreMeshKey) key;
materialList = meshKey.getMaterialList(); materialList = meshKey.getMaterialList();
String materialName = meshKey.getMaterialName();
if (materialList == null && materialName != null) {
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + materialName + ".material"));
}
} else { } else {
try { try {
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material")); materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material"));

@ -38,18 +38,32 @@ import com.jme3.material.MaterialList;
public class OgreMeshKey extends ModelKey { public class OgreMeshKey extends ModelKey {
private MaterialList materialList; private MaterialList materialList;
private String materialName;
public OgreMeshKey(){
super();
}
public OgreMeshKey(String name){
super(name);
}
public OgreMeshKey(String name, MaterialList materialList){ public OgreMeshKey(String name, MaterialList materialList){
super(name); super(name);
this.materialList = materialList; this.materialList = materialList;
} }
public OgreMeshKey(){ public OgreMeshKey(String name, String materialName){
super(); super(name);
this.materialName = materialName;
} }
public MaterialList getMaterialList() { public MaterialList getMaterialList() {
return materialList; return materialList;
} }
public String getMaterialName() {
return materialName;
}
} }

@ -59,7 +59,7 @@ public class TestBumpModel extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml", null)); Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml"));
signpost.setMaterial( (Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m")); signpost.setMaterial( (Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"));
TangentBinormalGenerator.generate(signpost); TangentBinormalGenerator.generate(signpost);
rootNode.attachChild(signpost); rootNode.attachChild(signpost);

Loading…
Cancel
Save