[COMMITTED] Storing tangent, binormal buffer in .jme format

I frequently change the character's head and it uses normalmap.

If tangent is not saved together with head, I have to maintain another file and it seems to be weird.



How about storing tangent/binormal buffer in .jme format.

It seems to be useful especially when using shader.





Index: src/com/jme/scene/Geometry.java
===================================================================
--- src/com/jme/scene/Geometry.java   (revision 4087)
+++ src/com/jme/scene/Geometry.java   (working copy)
@@ -860,6 +860,8 @@
         capsule.write(vertBuf, "vertBuf", null);
         capsule.writeSavableArrayList(texBuf, "texBuf",
                 new ArrayList<TexCoords>(1));
+        capsule.write(tangentBuf, "tangentBuf", null);
+        capsule.write(binormalBuf, "binormalBuf", null);
         capsule.write(enabled, "enabled", true);
         capsule.write(castsShadows, "castsShadows", true);
         capsule.write(bound, "bound", null);
@@ -879,6 +881,8 @@
             vertQuantity = vertBuf.limit() / 3;
         else
             vertQuantity = 0;
+        tangentBuf = capsule.readFloatBuffer("tangentBuf", null);
+        binormalBuf = capsule.readFloatBuffer("binormalBuf", null);
         texBuf = capsule.readSavableArrayList("texBuf",
                 new ArrayList<TexCoords>(1));
         checkTextureCoordinates();



Hmm, I think that may cause issues for anyone currently using the jME format to save/load.



Is there anyway to set some flags before saving? (possibly w/ a try-catch for the read)

You mean the jme files saved before this patch?

If so, I think this patch doesn't make any problem who already use jme format like I do.

When there is no "tangent", "binormal" data, it will be set to null and will be read without exception.



or… Am I missing something else?

mulova said:

You mean the jme files saved before this patch?
If so, I think this patch doesn't make any problem who already use jme format like I do.
When there is no "tangent", "binormal" data, it will be set to null and will be read without exception.

or... Am I missing something else?

That should be correct. Thats why you provide default values when saving/loading from the capsule.