Problem while loading an exported material file

Hi Guys,



I wonder why my exported material ends up it this error when importing to JME:



java.lang.NullPointerException
   at com.jmex.model.ogrexml.Material.getState(Material.java:67)
   at com.jmex.model.ogrexml.MaterialLoader.readPassStatement(MaterialLoader.java:267)
   at com.jmex.model.ogrexml.MaterialLoader.readPass(MaterialLoader.java:378)
   at com.jmex.model.ogrexml.MaterialLoader.readTechnique(MaterialLoader.java:403)
   at com.jmex.model.ogrexml.MaterialLoader.readMaterial(MaterialLoader.java:467)
   at com.jmex.model.ogrexml.MaterialLoader.load(MaterialLoader.java:508)



The material is a very standard one. I've only modified the Ref., Spec. and Hard values and I've applied a UV texture. This is exactly what i've done with previous models and it worked fine, but now it obviously doesn't.

I'm importing the mesh with the following code:


      SimpleResourceLocator locator = new SimpleResourceLocator(Demo.class.getClassLoader().getResource(
            "models/"));
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, locator);
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, locator);
      
      URL material = Demo.class.getClassLoader().getResource("models/Cube.material");
      URL model = Demo.class.getClassLoader().getResource("models/Cube.mesh.xml");
      OgreLoader      loader      = new OgreLoader();   
      OgreEntityNode mesh = null;
      System.out.println("Mesh, Material: " + material + " Model: " + model);
      try
      {
         if (material != null && model != null)
         {
            
            matLoader.load(material.openStream());
            if (matLoader.getMaterials().size() > 0)
               loader.setMaterials(matLoader.getMaterials());
            mesh = loader.loadModel(model);
            
            mesh.setName("Cube");
            List<Spatial> list = mesh.getChildren();
            logger.info("In "+ mesh.getName()+" enthaltene Children"+ list.size());
            for (int i = 0; i < list.size(); i++)
            {
               logger.info("Child "+i+" : "+mesh.getChild(i).getName());
            }
            mesh.getChild(0).setModelBound(new BoundingBox());
            mesh.updateModelBound();
            mesh.updateWorldBound();
            this.mesh = mesh;
         }
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }



I've successfully used this code previously. So i dont expect any errors here.

Recently I've reinstalled my machine's OS. So i needed to reinstall Blender and Python. Since then the Ogre Scene Export option has disappeared. I'm only able to export single meshes. Maybe Python, Blender or the Orge Exorter isn't installed properly? Anyone got an Idea? I've reinstalled Python several times in different versions. Didn't help.

I've created the mesh with Blender 2.49b 64 bit, possibly this is the problem? I tried to export the mesh with the 32 bit and 64 bit version, but still the same problem.

I'll attach the .mesh, .skeleton and the .material files. Maybe one of you is able to find the problem in there.
http://rapidshare.com/files/358778199/Exports.rar.html

Thanks for your help.

Edregol

i wonder why in your code, you don't have  'new SimpleResourceLocator' surrounded by a try/catch.



It works for me with this code:


import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.logging.Logger;

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.scene.Spatial;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.model.ogrexml.MaterialLoader;
import com.jmex.model.ogrexml.OgreEntityNode;
import com.jmex.model.ogrexml.OgreLoader;


public class Demo extends SimpleGame {
   MaterialLoader matLoader = new MaterialLoader();
   
   Logger logger = Logger.getAnonymousLogger();
   @Override
   protected void simpleInitGame() {
      SimpleResourceLocator locator = null;
      try {
         locator = new SimpleResourceLocator(Demo.class.getClassLoader().getResource(
         "models/"));
      } catch (URISyntaxException e1) {
         e1.printStackTrace();
      }
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, locator);
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, locator);

      URL material = Demo.class.getClassLoader().getResource("models/Cube.material");
      URL model = Demo.class.getClassLoader().getResource("models/Cube.mesh.xml");
      OgreLoader      loader      = new OgreLoader();   
      OgreEntityNode mesh = null;
      System.out.println("Mesh, Material: " + material + " Model: " + model);
      try
      {
         if (material != null && model != null)
         {

            matLoader.load(material.openStream());
            if (matLoader.getMaterials().size() > 0)
               loader.setMaterials(matLoader.getMaterials());
            mesh = loader.loadModel(model);

            mesh.setName("Cube");
            List<Spatial> list = mesh.getChildren();
            logger.info("In "+ mesh.getName()+" enthaltene Children"+ list.size());
            for (int i = 0; i < list.size(); i++)
            {
               logger.info("Child "+i+" : "+mesh.getChild(i).getName());
            }
            mesh.getChild(0).setModelBound(new BoundingBox());
            mesh.updateModelBound();
            mesh.updateWorldBound();
         }
         rootNode.attachChild(mesh);
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
   public static void main(String[] args) {
      Demo d = new Demo();
      d.setConfigShowMode(ConfigShowMode.AlwaysShow);
      d.start();
   }
}

Eclipse sayed it has to be surrounded by a try catch^^ at least a part of it.



Tanks for that :slight_smile:



Edregol