Importing TerrainQuad with JME

Hi there,

I am trying to export and import a TerrainQuad with the XMLExporter and XMLImporter of JME.

Exporting works fine, an XML file is created with the TerrainQuad and TerrainPatches. But when I try to import the TerrainQuad again, I get a ClassCastException.

I was debugging this a little bit and found out that the TerrainPatch member variable “offset” is of type Vector2f. And when the importer deserializes the TerrainPatch, it calles the TerrainPatch.read(JmeImporter im) method. In this method, the offset is being deserialized:

offset = (Vector2f) ic.readSavable(“offset”, Vector3f.UNIT_XYZ);

Unfortunately, the method passes a Vector3f to the readSavable method as default value. Some layers deeper, the deserialized variable will be created as object of the same class as the default value (Vector3f). Later the Vector3f variable is being cast to Vector2f as expected for the offset variable. This leads to the ClassCastException.

Any Ideas?

Hm this indeed looks like a bug in jme,

Does the same happen with the binary serializer?

Thanks for the fast reply!

The BinaryImporter does not throw any Exception, but my Application is stuck when I use it. So this is not really an alternative for me. If I think about it, the BinaryImporter should call the same deserialization method of TerrainPatch as the XMLImporter as this is the method to deserialize the TerrainPatch. So there should be the same behaviour in both Importers, not?

Regards

Yes basically it should be the same behavior,
also it should in theory be several times faster, instead of hanging, wich also leaves the question why it is slower?!

Yes indeed.

I will try to find out the reason, why the application is hanging with the BinaryImporter.

I finally fixed my problems with the BinaryImporter. I’ve had a dead lock in my coding when loading the Terrain :smile:

Now I just need to find out, why the changes to the terrain which I did before saving the terrain, are not being loaded.

Thanks for your help Empire_Phoenix!