Index: OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp
===================================================================
--- OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp (revision 10556)
+++ OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp (revision 11009)
@@ -11,12 +11,11 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  * OpenSceneGraph Public License for more details.
-*/
-
-
-#include <osgDB/Registry>
+ */
+
+
 #include <osgDB/FileNameUtils>
 #include <osgDB/FileUtils>
 #include <osgDB/ReaderWriter>
-
+#include <osg/io_utils>
 #include <osgAnimation/AnimationManagerBase>
 #include <osgAnimation/BasicAnimationManager>
@@ -25,8 +24,15 @@
 #include <osgAnimation/Animation>
 #include <osgAnimation/Bone>
+#include <osgAnimation/UpdateBone>
+#include <osgAnimation/UpdateMatrixTransform>
 #include <osgAnimation/Skeleton>
 #include <osgAnimation/RigGeometry>
 #include <osgAnimation/MorphGeometry>
-#include <osgAnimation/UpdateCallback>
+#include <osgAnimation/StackedTransform>
+#include <osgAnimation/StackedTranslateElement>
+#include <osgAnimation/StackedRotateAxisElement>
+#include <osgAnimation/StackedMatrixElement>
+#include <osgAnimation/StackedScaleElement>
+#include "Matrix.h"
 
 #include <osgDB/Registry>
@@ -43,5 +49,5 @@
     osg::Quat att;
     bool iteratorAdvanced = false;
-    if (fr.matchSequence("bindQuaternion %f %f %f %f")) 
+    if (fr.matchSequence("bindQuaternion %f %f %f %f"))
     {
         fr[1].getFloat(att[0]);
@@ -52,8 +58,9 @@
         fr += 5;
         iteratorAdvanced = true;
+        osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
     }
 
     osg::Vec3d pos(0,0,0);
-    if (fr.matchSequence("bindPosition %f %f %f")) 
+    if (fr.matchSequence("bindPosition %f %f %f"))
     {
         fr[1].getFloat(pos[0]);
@@ -63,8 +70,9 @@
         fr += 4;
         iteratorAdvanced = true;
+        osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
     }
 
     osg::Vec3d scale(1,1,1);
-    if (fr.matchSequence("bindScale %f %f %f")) 
+    if (fr.matchSequence("bindScale %f %f %f"))
     {
         fr[1].getFloat(scale[0]);
@@ -74,29 +82,43 @@
         fr += 4;
         iteratorAdvanced = true;
-    }
-
-    bone.setBindMatrixInBoneSpace( osg::Matrix(att) * osg::Matrix::translate(pos));
+        osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
+    }
+
+    if (fr.matchSequence("InvBindMatrixInSkeletonSpace {"))
+    {
+        Matrix matrix; 
+        if (readMatrix(matrix,fr, "InvBindMatrixInSkeletonSpace"))
+        {
+            bone.setInvBindMatrixInSkeletonSpace(matrix);
+            iteratorAdvanced = true;
+        }
+    }
+    if (fr.matchSequence("MatrixInSkeletonSpace {"))
+    {
+        Matrix matrix; 
+        if (readMatrix(matrix,fr, "MatrixInSkeletonSpace"))
+        {
+            bone.setMatrixInSkeletonSpace(matrix);
+            iteratorAdvanced = true;
+        }
+    }
     return iteratorAdvanced;
 }
 
-bool Bone_writeLocalData(const Object& obj, Output& fw) 
+bool Bone_writeLocalData(const Object& obj, Output& fw)
 {
     const osgAnimation::Bone& bone = dynamic_cast<const osgAnimation::Bone&>(obj);
-    osg::Vec3 t;
-    osg::Quat r;
-    osg::Vec3 s;
-    osg::Quat rs;
-    bone.getBindMatrixInBoneSpace().decompose(t,r,s,rs);
-    fw.indent() << "bindQuaternion "  << r << std::endl;
-    fw.indent() << "bindPosition "  << t << std::endl;
-    fw.indent() << "bindScale "  << s << std::endl;
-    return true;
-}
-
-RegisterDotOsgWrapperProxy g_atkBoneProxy
+    bool res1 = writeMatrix(bone.getInvBindMatrixInSkeletonSpace(), fw, "InvBindMatrixInSkeletonSpace");
+    // write this field for debug only
+    // because it's recompute at each update
+    bool res2 = writeMatrix(bone.getMatrixInSkeletonSpace(), fw, "MatrixInSkeletonSpace");
+    return (res1 || res2);
+}
+
+RegisterDotOsgWrapperProxy g_BoneProxy
 (
     new osgAnimation::Bone,
     "osgAnimation::Bone",
-    "Object Node Transform osgAnimation::Bone Group",
+    "Object Node MatrixTransform osgAnimation::Bone Group",
     &Bone_readLocalData,
     &Bone_writeLocalData
@@ -113,9 +135,9 @@
     return true; 
 }
-RegisterDotOsgWrapperProxy g_atkRootSkeletonProxy
+RegisterDotOsgWrapperProxy g_SkeletonProxy
 (
     new osgAnimation::Skeleton,
     "osgAnimation::Skeleton",
-    "Object Node  Transform osgAnimation::Bone osgAnimation::Skeleton Group",
+    "Object Node MatrixTransform osgAnimation::Skeleton Group",
     &Skeleton_readLocalData,
     &Skeleton_writeLocalData,
@@ -724,5 +746,5 @@
 
     fw.indent() << "num_animations " << animList.size()  << std::endl;
-    for (osgAnimation::AnimationList::const_iterator it = animList.begin(); it != animList.end(); it++)
+    for (osgAnimation::AnimationList::const_iterator it = animList.begin(); it != animList.end(); ++it)
     {
         if (!fw.writeObject(**it))
@@ -817,4 +839,11 @@
         geom.setInfluenceMap(vmap.get());
 
+    if (fr.matchSequence("Geometry {"))
+    {
+        osg::Geometry* source = dynamic_cast<osg::Geometry*>(fr.readObject());
+        geom.setSourceGeometry(source);
+        iteratorAdvanced = true;
+    }
+
     return iteratorAdvanced;
 }
@@ -828,5 +857,5 @@
     fw.indent() << "num_influences "  << vm->size() << std::endl;
     fw.moveIn();
-    for (osgAnimation::VertexInfluenceMap::const_iterator it = vm->begin(); it != vm->end(); it++) 
+    for (osgAnimation::VertexInfluenceMap::const_iterator it = vm->begin(); it != vm->end(); ++it) 
     {
         std::string name = it->first;
@@ -844,4 +873,6 @@
     }
     fw.moveOut();
+
+    fw.writeObject(*geom.getSourceGeometry());
     return true;
 }
@@ -851,5 +882,5 @@
     new osgAnimation::RigGeometry,
     "osgAnimation::RigGeometry",
-    "Object Drawable osgAnimation::RigGeometry Geometry",
+    "Object osgAnimation::RigGeometry Drawable Geometry",
     &RigGeometry_readLocalData,
     &RigGeometry_writeLocalData,
@@ -976,5 +1007,8 @@
 
 
-bool UpdateBone_readLocalData(Object& obj, Input& fr) 
+
+
+
+bool UpdateBone_readLocalData(Object& obj, Input& fr)
 {
     bool iteratorAdvanced = false;
@@ -987,9 +1021,9 @@
 }
 
-RegisterDotOsgWrapperProxy g_atkUpdateBoneProxy
+RegisterDotOsgWrapperProxy g_UpdateBoneProxy
 (
-    new osgAnimation::Bone::UpdateBone,
+    new osgAnimation::UpdateBone,
     "osgAnimation::UpdateBone",
-    "Object NodeCallback osgAnimation::UpdateBone",
+    "Object NodeCallback osgAnimation::UpdateMatrixTransform osgAnimation::UpdateBone",
     &UpdateBone_readLocalData,
     &UpdateBone_writeLocalData,
@@ -1010,5 +1044,5 @@
 }
 
-RegisterDotOsgWrapperProxy g_atkUpdateSkeletonProxy
+RegisterDotOsgWrapperProxy g_UpdateSkeletonProxy
 (
     new osgAnimation::Skeleton::UpdateSkeleton,
@@ -1021,6 +1055,5 @@
 
 
-
-bool UpdateTransform_readLocalData(Object& obj, Input& fr) 
+bool UpdateMorph_readLocalData(Object& obj, Input& fr) 
 {
     bool iteratorAdvanced = false;
@@ -1028,54 +1061,10 @@
 }
 
-bool UpdateTransform_writeLocalData(const Object& obj, Output& fw)
+bool UpdateMorph_writeLocalData(const Object& obj, Output& fw)
 {
     return true;
 }
 
-RegisterDotOsgWrapperProxy g_atkUpdateTransformProxy
-(
-    new osgAnimation::UpdateTransform,
-    "osgAnimation::UpdateTransform",
-    "Object NodeCallback osgAnimation::UpdateTransform",
-    &UpdateTransform_readLocalData,
-    &UpdateTransform_writeLocalData,
-    DotOsgWrapper::READ_AND_WRITE
-);
-
-
-
-bool UpdateMaterial_readLocalData(Object& obj, Input& fr) 
-{
-    bool iteratorAdvanced = false;
-    return iteratorAdvanced;
-}
-
-bool UpdateMaterial_writeLocalData(const Object& obj, Output& fw)
-{
-    return true;
-}
-
-RegisterDotOsgWrapperProxy g_UpdateMaterialProxy
-(
-    new osgAnimation::UpdateMaterial,
-    "osgAnimation::UpdateMaterial",
-    "Object StateAttribute::Callback osgAnimation::UpdateMaterial",
-    &UpdateMaterial_readLocalData,
-    &UpdateMaterial_writeLocalData,
-    DotOsgWrapper::READ_AND_WRITE
-);
-
-bool UpdateMorph_readLocalData(Object& obj, Input& fr) 
-{
-    bool iteratorAdvanced = false;
-    return iteratorAdvanced;
-}
-
-bool UpdateMorph_writeLocalData(const Object& obj, Output& fw)
-{
-    return true;
-}
-
-RegisterDotOsgWrapperProxy g_atkUpdateMorphProxy
+RegisterDotOsgWrapperProxy g_UpdateMorphProxy
 (
  new osgAnimation::UpdateMorph,
