#include "xsunlightparseparams.h"
#include "xstring.h"

XSunLightParseParams::XSunLightParseParams()
    : XAsset()
    , mName("")
    , mAmbientScale(1.0f)
    , mAmbientColor()
    , mDiffuseFraction(0.0f)
    , mSunLight(0.0f)
    , mSunColor()
    , mDiffuseColor()
    , mDiffuseColorHasBeenSet(false)
    , mAngles()
{
    SetName("Sunlight Parse Parameters");
}

XSunLightParseParams::~XSunLightParseParams()
{

}

void XSunLightParseParams::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        mName = XString::ParseCustom(aStream);

        quint32 ambientR, ambientG, ambientB,
            sunR, sunG, sunB,
            diffuseR, diffuseG, diffuseB;
        *aStream
            >> mAmbientScale
            >> ambientR
            >> ambientG
            >> ambientB
            >> mDiffuseFraction
            >> mSunLight
            >> sunR
            >> sunG
            >> sunB
            >> diffuseR
            >> diffuseG
            >> diffuseB
            >> mDiffuseColorHasBeenSet
            >> mAngles[0]
            >> mAngles[1]
            >> mAngles[2];
        mAmbientColor = QColor(ambientR, ambientG, ambientB);
        mSunColor = QColor(sunR, sunG, sunB);
        mDiffuseColor = QColor(diffuseR, diffuseG, diffuseB);
    }
}

void XSunLightParseParams::Clear()
{
    mName.clear();
    mAmbientScale = 1.0f;
    mAmbientColor = QColor();
    mDiffuseFraction = 0.0f;
    mSunLight = 0.0f;
    mSunColor = QColor();
    mDiffuseColor = QColor();
    mDiffuseColorHasBeenSet = false;
    mAngles = QVector3D();
}
