#include "xgfxworldvertex.h"

XGfxWorldVertex::XGfxWorldVertex()
    : XAsset()
    , mXYZ()
    , mBinormalSign(0.0f)
    , mColor()
    , mTexCoord()
    , mLmapCoord()
    , mNormal()
    , mTangent()
{
    SetName("GFX World Vertex");
}

XGfxWorldVertex::~XGfxWorldVertex()
{

}

void XGfxWorldVertex::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        mXYZ.setX(aStream->ParseSingle(QString("%1 xyz x").arg(GetName())));
        mXYZ.setY(aStream->ParseSingle(QString("%1 xyz y").arg(GetName())));
        mXYZ.setZ(aStream->ParseSingle(QString("%1 xyz z").arg(GetName())));
        mBinormalSign = aStream->ParseSingle(QString("%1 binormal sign").arg(GetName()));

        quint8 r = aStream->ParseUInt8(QString("%1 color r").arg(GetName()));
        quint8 g = aStream->ParseUInt8(QString("%1 color g").arg(GetName()));
        quint8 b = aStream->ParseUInt8(QString("%1 color b").arg(GetName()));
        quint8 a = aStream->ParseUInt8(QString("%1 color a").arg(GetName()));
        mColor.SetColor(r, g, b, a);

        mTexCoord.setX(aStream->ParseSingle(QString("%1 texcoord u").arg(GetName())));
        mTexCoord.setY(aStream->ParseSingle(QString("%1 texcoord v").arg(GetName())));
        mLmapCoord.setX(aStream->ParseSingle(QString("%1 lmapcoord u").arg(GetName())));
        mLmapCoord.setY(aStream->ParseSingle(QString("%1 lmapcoord v").arg(GetName())));

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

void XGfxWorldVertex::Clear()
{

}
