#include "xgfxpackedvertex.h"

XGfxPackedVertex::XGfxPackedVertex()
    : XAsset()
    , mXYZ()
    , mBinormalSign(0)
    , mColor()
    , mTexCoord()
    , mNormal()
    , mTangent()
{
    SetName("GFX Packed Vertex");
}

void XGfxPackedVertex::ParseData(XDataStream *aStream)
{
    if (GetPtr() == -1)
    {

        quint32 rawCoord;
        for (int i = 0; i < 3; i++)
        {
            *aStream >> rawCoord;
            memcpy(&mXYZ[i], &rawCoord, sizeof(mXYZ[i]));
            if (IsDebug())
            {
                qDebug() << QString("[%1] mXYZ[%2] = %3").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(i).arg(mXYZ[0]);
            }
        }

        *aStream >> mBinormalSign;
        if (IsDebug())
        {
            qDebug() << QString("[%1] mBinormalSign = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mBinormalSign);
        }

        mColor.ParseData(aStream);
        mTexCoord.ParseData(aStream);
        mNormal.ParseData(aStream);
        mTangent.ParseData(aStream);
    }
}

void XGfxPackedVertex::Clear()
{
    
}
