//---------------------------------------------------------------------
    void SkeletonSerializer::writeAnimation(const Skeleton* pSkel, 
        const Animation* anim)
    {
        writeChunkHeader(SKELETON_ANIMATION, calcAnimationSize(pSkel, anim));

        // char* name                       : Name of the animation
        writeString(anim->getName());
        // float length                      : Length of the animation in seconds
        float len = anim->getLength();
        writeFloats(&len, 1);

        // Write all tracks
        Animation::NodeTrackIterator trackIt = anim->getNodeTrackIterator();
        while(trackIt.hasMoreElements())
        {
            writeAnimationTrack(pSkel, trackIt.getNext());
        }

    }
    //---------------------------------------------------------------------
    void SkeletonSerializer::writeAnimation(const Skeleton* pSkel, 
        const Animation* anim, SkeletonVersion ver)
    {
        writeChunkHeader(SKELETON_ANIMATION, calcAnimationSize(pSkel, anim, ver));

        // char* name                       : Name of the animation
        writeString(anim->getName());
        // float length                      : Length of the animation in seconds
        float len = anim->getLength();
        writeFloats(&len, 1);
        pushInnerChunk(mStream);
        {
        if ((int)ver > (int)SKELETON_VERSION_1_0)
        {
            if (anim->getUseBaseKeyFrame())
            {
                size_t size = SSTREAM_OVERHEAD_SIZE;
                // char* baseAnimationName (including terminator)
                    size += calcStringSize(anim->getBaseKeyFrameAnimationName());
                // float baseKeyFrameTime
                size += sizeof(float);
                
                writeChunkHeader(SKELETON_ANIMATION_BASEINFO, size);
                
                // char* baseAnimationName (blank for self)
                writeString(anim->getBaseKeyFrameAnimationName());
                
                // float baseKeyFrameTime
                float t = (float)anim->getBaseKeyFrameTime();
                writeFloats(&t, 1);
            }
        }

        // Write all tracks
        Animation::NodeTrackIterator trackIt = anim->getNodeTrackIterator();
        while(trackIt.hasMoreElements())
        {
            writeAnimationTrack(pSkel, trackIt.getNext());
        }
        }
        popInnerChunk(mStream);

    }