[committed] Quaternion not serializable with XMLEncoder unlike Vector3f


com.jme.math.Quaternion has no read and write accessors unlike Vector3f, it is not homogeneous and it prevents from using Java build-in XML serialization on it (there is no error but the values of x, y, z and w are not encoded).

I only add 8 accessors:

public float getX() {
        return x;

    public void setX(float x) {
        this.x = x;

    public float getY() {
        return y;

    public void setY(float y) {
        this.y = y;

    public float getZ() {
        return z;

    public void setZ(float z) {
        this.z = z;

    public float getW() {
        return w;

    public void setW(float w) {
        this.w = w;

the fields are public, can you not access them directly ?

Core-Dump said:

the fields are public, can you not access them directly ?

I can access directly in my own code but the Java build-in XML serialization cannot do it because it follows the convention of Java Beans, it tries to get the value of x by using getX() even though x is public, that's the problem when you use the source code below:

String filename="myFile.xml";
BufferedOutputStream bos=null;
        File file=new File(filename);  
                    throw new IOException("Unable to create the file "+filename);
            bos=new BufferedOutputStream(new FileOutputStream(file));
            XMLEncoder encoder=new XMLEncoder(bos);
            encoder.writeObject(new Quaternion(0.65328145f,-0.27059805f,-0.27059808f,0.6532815f));
        catch(IOException ioe)
        {throw new RuntimeException("Unable to encode the file "+filename,ioe);}
             catch(IOException ioe)
             {throw new RuntimeException("Unable to close the file "+filename,ioe);}

you get this (without my fix):

<void property="rotation">
       <object class="com.jme.math.Quaternion" />

you get this with my fix:

<void property="rotation">
       <object class="com.jme.math.Quaternion">
        <void property="w">
        <void property="x">
        <void property="y">
        <void property="z">

I submit my fix tomorrow if you don't see any objection.