//---------------------------------------------------------------------
    size_t SkeletonSerializer::calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim, SkeletonVersion ver)
    {
        size_t size = SSTREAM_OVERHEAD_SIZE;

        // Name, including terminator
        size += calcStringSize(pAnim->getName());
        // length
        size += sizeof(float);

        if ((int)ver > (int)SKELETON_VERSION_1_0)
        {
            if (pAnim->getUseBaseKeyFrame())
            {
                size += SSTREAM_OVERHEAD_SIZE;
                // char* baseAnimationName (including terminator)
                size += calcStringSize(pAnim->getBaseKeyFrameAnimationName());
                // float baseKeyFrameTime
                size += sizeof(float);
            }
        }

        // Nested animation tracks
        Animation::NodeTrackIterator trackIt = pAnim->getNodeTrackIterator();
        while(trackIt.hasMoreElements())
        {
            size += calcAnimationTrackSize(pSkel, trackIt.getNext());
        }

        return size;
    }
    //---------------------------------------------------------------------
    void SkeletonSerializer::writeAnimationTrack(const Skeleton* pSkel, 
        const NodeAnimationTrack* track)
    {
        writeChunkHeader(SKELETON_ANIMATION_TRACK, calcAnimationTrackSize(pSkel, track));

        // unsigned short boneIndex     : Index of bone to apply to
        Bone* bone = (Bone*)track->getAssociatedNode();
        unsigned short boneid = bone->getHandle();
        writeShorts(&boneid, 1);

        // Write all keyframes
        for (unsigned short i = 0; i < track->getNumKeyFrames(); ++i)
        {
            writeKeyFrame(pSkel, track->getNodeKeyFrame(i));
        }

    }
    //---------------------------------------------------------------------
    size_t SkeletonSerializer::calcAnimationSize(const Skeleton* pSkel, 
        const Animation* pAnim)
    {
        size_t size = STREAM_OVERHEAD_SIZE;

        // Name, including terminator
        size += pAnim->getName().length() + 1;
        // length
        size += sizeof(float);

        // Nested animation tracks
		Animation::NodeTrackIterator trackIt = pAnim->getNodeTrackIterator();
		while(trackIt.hasMoreElements())
		{
            size += calcAnimationTrackSize(pSkel, trackIt.getNext());
        }

        return size;
    }