Error while loading Orge Exporter generated *.material File

Hi Guys,



got a strange Error if I load a *.material File, generated by Orge Exporter. During the exporting process out of Blender, everything works fine, no error and stuff.

But, if I load the generated File into JME I get this error:



12.01.2010 18:13:43 com.jmex.model.ogrexml.MaterialLoader readColor
WARNING: Reverting alpha value from 0.0 to 1.0f
12.01.2010 18:13:43 com.jmex.model.ogrexml.MaterialLoader readColor
WARNING: Reverting alpha value from 0.0 to 1.0f
java.io.IOException: Expected 'material', got: texture_unit
   at com.jmex.model.ogrexml.MaterialLoader.readMaterial(MaterialLoader.java:426)



The exported mesh has 3 uv textures applied. I've downloaded the OrgeXMLConverter Tool to calculate tangents etc. but it doesn't help.

Got anyone an idea?

Thanks
Edregol

Please post the problematic .material file.

Momoko_Fan said:

Please post the problematic .material file.

Here it is: http://rapidshare.com/files/334272677/Skink.material.html

greetings
Edregol

Okay I see what the problem is. You're exporting a model with normal and specular mapping, this is not supported by the OgreXML importer since it requires shaders.

Okay thanks for that.

you can implement that feature yourself, the ogrexml importer and more specifically the MaterialLoader is not that complex. Should be done in a few hours.  :wink:

That would be rather difficult actually. The Blender exporter uses almost every feature of the material system in order to accomplish the normal/specular shading, like using several techniques, multiple passes for lighting, and shaders that jME does not have. The best way is to sort of have your own way of handling materials.

Thanks for the faith in my skills, but I guess I'm not experienced enough for doing that^^ It's not a problem that normal and specular mapping will not work. At the moment I'm just playing around. Maybe I've gathered enough experience in a few month, for writing my own MaterialLoader^^

On a side note, jME3 has it's own material system and those materials have "effects" like normal, specular, parallax, etc mapping or whatever have you.

But JME3 has no OgreImporter support yet. Am I right?

Apart from that, I got a new problem :slight_smile: I’ve created a Model including animations in Blender. The material file I’ve posted previousely belongs to it. The Model Exports without any errors. But when playing those animations in JME2 some animations play way to fast, others got stuck at the first frame. The animations got no constraints like Auto IK and stuff, ther are just simple IPOs, I guess^^. Because I’ve exported working animations before, similar to those wich are not working, I expect the error in my Blendfile. Newly the animations will not load. Ostensibly the BoneAnimationLoader gets a null object. Could somebody experienced have a look at the files an tell me what I’ve done wrong?



Thanks for the help

Edregol



And here are the Files: http://rapidshare.com/files/337206639/Model_with_Problems.rar.html

But JME3 has no OgreImporter support yet. Am I right?

Full support, almost. Animation system just needs to be properly ported from jME2, thats it.

I checked the model both in blender and the XML files and it looks fine, I'll try to check it further when I have time.

Thanks, I realy appreciate that :slight_smile:



Edregol

Hi again,

Lately I've found some time to face my problem again. I got some news, but they aren't good ones. Presumably I had my Problem, because I used the JME Version from the svn repository. I've switched to the downladable JME Version 2.0.1. now I got a New Error :


26.01.2010 14:26:52 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
CURRENT ROOT Hip.R
NEW ROOT Spine1
26.01.2010 14:26:52 class game.Game start()
SEVERE: Exception in game loop
java.lang.IllegalStateException: Cannot have more than one root bone in skeleton
   at com.jmex.model.ogrexml.anim.Skeleton.<init>(Skeleton.java:72)
   at com.jmex.model.ogrexml.anim.SkeletonLoader.loadSkeleton(SkeletonLoader.java:150)
   at com.jmex.model.ogrexml.OgreLoader.loadMesh(OgreLoader.java:598)
[...]


Obviousely the Error has changed. The SkelletonLoader changes the RootBone of my Model, but I don't know why.

For testing, I created a new Model and tried to import it to JME. When doing this, I get the old Error.


26.01.2010 14:35:19 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
26.01.2010 14:35:19 class game.Game start()
SEVERE: Exception in game loop
java.lang.NullPointerException
   at com.jmex.model.ogrexml.anim.BoneAnimationLoader.loadAnimation(BoneAnimationLoader.java:143)
   at com.jmex.model.ogrexml.anim.BoneAnimationLoader.loadAnimations(BoneAnimationLoader.java:243)
   at com.jmex.model.ogrexml.OgreLoader.loadMesh(OgreLoader.java:602)
[...]



Any Idea?

Thanks
Edregol

I had this problem too. The exception:



java.lang.IllegalStateException: Cannot have more than one root bone in skeleton



seems to happen because in the skeleton.xml file the bone hierarchy section doesnt' list all the bones. Manually editing the xml file to complete the hiearchy solved the problem for me but it isn't a very practical solution.

Thanks for the Anser. What exactly do I need to do? I'm not familiar with these xml files :slight_smile:



Edit: Okay, I recognized the problem. I got more than 1 bone without a parent. OgreExporter couldnt handle this properly. Now the problem is the old one:



SEVERE: Exception in game loop
java.lang.NullPointerException
   at com.jmex.model.ogrexml.anim.BoneAnimationLoader.loadAnimation(BoneAnimationLoader.java:143)
   at com.jmex.model.ogrexml.anim.BoneAnimationLoader.loadAnimations(BoneAnimationLoader.java:243)
   at com.jmex.model.ogrexml.OgreLoader.loadMesh(OgreLoader.java:602)
[...]


Is it possible, that the animationLoader doesn't find the*.skeleton file?

My *.skeleteon file is in the same directory as the *.mesh file is.

EDIT 2:
I've remembered that I've played around a bit with my model loading class:


SimpleResourceLocator locator = new SimpleResourceLocator(ModelLoader.class.getClassLoader().getResource(
            "models/"));
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, locator);
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, locator);

      URL material = ModelLoader.class.getClassLoader().getResource("models/"+name+".material");
      URL model = ModelLoader.class.getClassLoader().getResource("models/"+name+".mesh.xml");
      logger.info("Loading Model: "+name);

      OgreEntityNode mesh = null;
      if (material != null && model != null)
      {
         matLoader.load(material.openStream());
         if (matLoader.getMaterials().size() > 0)
            loader.setMaterials(matLoader.getMaterials());
         mesh = loader.loadModel(model);

         mesh.setName(name);
         List<Spatial> list = mesh.getChildren();
         logger.info("In "+ mesh.getName()+" Included Children"+ list.size());
         for (int i = 0; i < list.size(); i++)
         {
            logger.info("Child "+i+" : "+mesh.getChild(i).getName());
         }

         mesh.setModelBound(new BoundingBox());
         mesh.updateModelBound();
         mesh.updateWorldBound();

         return mesh;
      }
      else
      {
         new FileNotFoundException("Unable to load model: Material: " + material + " Model: " + model);
         System.exit(0);
      }


But this code seems to work properly. Or does anyone see a mistake in there?

I think it finds the skeleton file (because of the previous exception: it tries to rebuild the bone hierarchy and that is defined in the skeleton file).



I get the same exception if i try to import a ogre xml file where the .skeleton.xml file has an empty "animation" node. This node is a child of the "animations" node (near the end of the skeleton.xml file) and i think it should contain the keyframes of the animation.

I am not sure if the error you're having is actually related… jME SVN includes an updated ogreloader that supports more than one root bone. I strongly recommend that you use the ogreloader in jME SVN (everything else can be 2.0.1) since it fixes some common issues.

Sorry about not checking your model yet, I haven't touched anything programming related in the last weeks due to university.

pgi said:

I think it finds the skeleton file (because of the previous exception: it tries to rebuild the bone hierarchy and that is defined in the skeleton file).

I get the same exception if i try to import a ogre xml file where the .skeleton.xml file has an empty "animation" node. This node is a child of the "animations" node (near the end of the skeleton.xml file) and i think it should contain the keyframes of the animation.

Thank god. This was the problem. I've created a static "animation" in both of the files. Its much easier to model the mesh if its in its origin position. I've exported this animation because I thought it might be helpful, dont ask me why^^ Well those animations where exported from frame 1 to frame 1, so they got an animation length of, yeah you guess it, 0^^ Not exporting these animations solved the problem.

BUT, the animations are playing way to fast. maybe I need to alter the animation length in the xml file by hand? Setting the AnimationController.setspeed doesn't change anything.

Momoko_Fan said:

I am not sure if the error you're having is actually related.. jME SVN includes an updated ogreloader that supports more than one root bone. I strongly recommend that you use the ogreloader in jME SVN (everything else can be 2.0.1) since it fixes some common issues.
Sorry about not checking your model yet, I haven't touched anything programming related in the last weeks due to university.


Yes you're right the problem isn't JME related.
Never mind. Because of this great community I got a bunch of problems solved. At least a few of them need to be solved by myself :)

greetings and thanks for the help

Edregol
Edregol said:
BUT, the animations are playing way to fast. maybe I need to alter the animation length in the xml file by hand? Setting the AnimationController.setspeed doesn't change anything.


Editing the xml could be a solution. The problem is that you have to alter the keyframe nodes and there are a lot of them (there's not a single field that states "ok, this animation takes N seconds" but a set of steps occurring in an imaginary timeline, for each bone in the skeleton. Or something like that. So you will have to "resample" the entire keyframe list).

Unfortunately i can't suggest you a valid alternative (I discarded ogre files as a viable solution for animated models). Maybe playing a bit with the ogre exporter settings or changing something in the animation inside the editor will fix stuff.

@pgi: Did you ever try hottbj-exporter? It is a great exporter.



http://www.jmonkeyengine.com/wiki/doku.php/blenderjme_basics_tutorial